You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by "Lorenz Quack (JIRA)" <ji...@apache.org> on 2015/08/13 16:58:45 UTC

[jira] [Updated] (QPID-6672) Message dispatching after dispatcher close can cause thread to terminate with IllegalStateException

     [ https://issues.apache.org/jira/browse/QPID-6672?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Lorenz Quack updated QPID-6672:
-------------------------------
    Attachment: 0001-QPID-6672-Java-Client-Message-dispatching-after-disp.patch

Here is a patch for this issue.
TBH, I'm not quite happy with it.
It should fix the IllegalStateException being thrown but opens the possibility for a RuntimeError being thrown instead :(
Problem continues to be a race between session.close and the dispatcher both synchronizing on the _messageDeliveryLock.
In the unlucky case a thread calls session.close() which acquires the _messageDeliveryLock but before setting the isClosed flag on the session the dispatcherThread tries to synchronize on the _messageDeliveryLock in Dispatcher#dispatchMessage().
    Obviously this will block and the await on the _closeCompleted latch in Dispatcher#close() will timeout throwing the RuntimeException.

I'll look further into it but I wanted to publish my WIP.

> Message dispatching after dispatcher close can cause thread to terminate with IllegalStateException
> ---------------------------------------------------------------------------------------------------
>
>                 Key: QPID-6672
>                 URL: https://issues.apache.org/jira/browse/QPID-6672
>             Project: Qpid
>          Issue Type: Bug
>          Components: Java Client
>            Reporter: Keith Wall
>            Priority: Minor
>         Attachments: 0001-QPID-6672-Java-Client-Message-dispatching-after-disp.patch, TEST-org.apache.qpid.test.unit.transacted.TransactionTimeoutTest.testConsumerIdleRollback.txt
>
>
> There is a race between the dispatcher thread and another thread closing a session.  In the unlucky case, the dispatcher thread can die with an ISE as below.
> The issue appears to be that the Dispatcher#close method does not await the shutdown for the dispatcher before returning, so the Dispatcher may run on for another iteration whilst the dispatcher reference has been nulled.
> This appears to be a longstanding issue (the fixme goes back to 2007) and is showing up now owing to r1693225, which makes uncaught exceptions fail the test.
> {noformat}
> 2015-07-29 18:16:37,498         ERROR [Dispatcher-4-Conn-32] o.a.q.t.LoggingUncaughtExceptionHandler Uncaught exception in thread "Dispatcher-4-Conn-32"
> java.lang.IllegalStateException: dispatcher is not started
> 	at org.apache.qpid.client.AMQSession.dispatch(AMQSession.java:3267) ~[qpid-client-6.0.0-SNAPSHOT.jar:na]
> 	at org.apache.qpid.client.message.UnprocessedMessage.dispatch(UnprocessedMessage.java:54) ~[qpid-client-6.0.0-SNAPSHOT.jar:na]
> 	at org.apache.qpid.client.AMQSession$Dispatcher.run(AMQSession.java:3408) ~[qpid-client-6.0.0-SNAPSHOT.jar:na]
> 	at java.lang.Thread.run(Thread.java:745) ~[na:1.7.0_67]
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org
For additional commands, e-mail: dev-help@qpid.apache.org