[
https://issues.apache.org/jira/browse/QPID-7368?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15398956#comment-15398956
]
Keith Wall edited comment on QPID-7368 at 8/2/16 4:43 PM:
----------------------------------------------------------
This is a race.
There is a race condition that allows this condition to happen. It affects
only the case where the Port is closed, so as it is not possible to lifecycle
Port object yet, it can occur only on Broker shutdown.
# {{AmqpPortImpl#onClose}} on the Broker config thread closes the
{{TCPandSSLTransport#close}} which:
## {{NonBlockingNetworkTransport#close}} organises asynchronously for the the
accepting socket selection key to be cancelled. The actual cancellation takes
place on the Selector-Port-amqp thread as a task.
## Closes the SelectorThread#close which causes the selector's run loop to
terminate and the thread exit.
There is an unlucky timing where the acceptor's selection key is cancelled but
the selector thread has not yet been marked as closed. If there is a selector
activity during this period, the exception will occur and the Broker will
shutdown ungracefully.
I think if we deregister our {{OP_ACCEPT}} interest from the accepting socket
channel before we cancel the selectionKey, we can avoid the possibility of the
race.
was (Author: k-wall):
I have done no analysis into this problem.
> CancelledKeyException from accepting socket during Broker shutdown
> ------------------------------------------------------------------
>
> Key: QPID-7368
> URL: https://issues.apache.org/jira/browse/QPID-7368
> Project: Qpid
> Issue Type: Bug
> Components: Java Broker
> Reporter: Keith Wall
> Fix For: qpid-java-6.1
>
> Attachments:
> TEST-org.apache.qpid.transport.ProtocolNegotiationTest.testWrongProtocolHeaderSent_BrokerRespondsWithSupportedProtocol.txt
>
>
> We saw the following test failure on trunk whilst the test was shutting down
> a Broker.
> https://builds.apache.org/view/M-R/view/Qpid/job/Qpid-Java-Java-Test-JDK1.8/lastCompletedBuild/testReport/org.apache.qpid.transport/ProtocolNegotiationTest/testWrongProtocolHeaderSent_BrokerRespondsWithSupportedProtocol/
> Thread terminated due to uncaught exception
> java.nio.channels.CancelledKeyException
> at sun.nio.ch.SelectionKeyImpl.ensureValid(SelectionKeyImpl.java:73)
> at sun.nio.ch.SelectionKeyImpl.readyOps(SelectionKeyImpl.java:87)
> at java.nio.channels.SelectionKey.isAcceptable(SelectionKey.java:360)
> at
> org.apache.qpid.server.transport.SelectorThread$SelectionTask.processSelectionKeys(SelectorThread.java:167)
> at
> org.apache.qpid.server.transport.SelectorThread$SelectionTask.performSelect(SelectorThread.java:305)
> at
> org.apache.qpid.server.transport.SelectorThread$SelectionTask.run(SelectorThread.java:87)
> at
> org.apache.qpid.server.transport.SelectorThread.run(SelectorThread.java:462)
> at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
> at java.lang.Thread.run(Thread.java:745)
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]