You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by "Alex Rudyy (JIRA)" <ji...@apache.org> on 2016/07/29 12:21:20 UTC

[jira] [Commented] (QPID-3289) Session exceptions should only be notified via the exception listener, if it cannot be thrown directly to the application.

    [ https://issues.apache.org/jira/browse/QPID-3289?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15399231#comment-15399231 ] 

Alex Rudyy commented on QPID-3289:
----------------------------------

Test MultiNodeTest.testInFlightTransactionsWhilstMajorityIsLost failed recently due to running into this issue .

SessionException  thrown on Session.commit() from AMQSession_0_10.sync() was re-thrown from commit method and forwarded into ExceptionListener by calling AMQSession_0_10.setCurrentException(SessionException).
The latter caused marking session as closed and removal of AMQSession from AMQConnection (the chain of calls: AMQSession.commit()->AMQSession.rollback()->AMQSession.suspendChannel()->AMQSession_0_10.sync()->AMQSession_0_10.setCurrentException(SessionException) ->AMQSession.closed(Throwable)->AMQConnection.deregisterSession(String))

As result. the test was not able to repeat a commit operation after successful connection re-establishment due to failover as Session was marked as closed and IlligalStateException was reported
{noformat}
javax.jms.IllegalStateException: Object org.apache.qpid.client.AMQSession_0_10@1771e108 has been closed
	at org.apache.qpid.client.Closeable.checkNotClosed(Closeable.java:62)
	at org.apache.qpid.client.AMQSession.checkNotClosed(AMQSession.java:474)
	at org.apache.qpid.client.AMQSession$9.execute(AMQSession.java:2778)
	at org.apache.qpid.client.AMQSession$9.execute(AMQSession.java:2775)
	at org.apache.qpid.client.AMQConnectionDelegate_0_10.executeRetrySupport(AMQConnectionDelegate_0_10.java:493)
	at org.apache.qpid.client.AMQConnection.executeRetrySupport(AMQConnection.java:809)
	at org.apache.qpid.client.failover.FailoverRetrySupport.execute(FailoverRetrySupport.java:90)
	at org.apache.qpid.client.AMQSession.createProducerImpl(AMQSession.java:2773)
	at org.apache.qpid.client.AMQSession.createProducer(AMQSession.java:1270)
	at org.apache.qpid.client.AMQSession.createProducer(AMQSession.java:98)
	at org.apache.qpid.server.store.berkeleydb.replication.MultiNodeTest.testInFlightTransactionsWhilstMajorityIsLost(MultiNodeTest.java:518)
{noformat}

It seem that call to  AMQSession_0_10.setCurrentException(SessionException) was harmful in this case (as it marked session as closed and remove AMQConnection in spite of the Exception being reported to the user from commit). It is a defect in current 0-10 client implementation.
Here is a stack trace which causes the removal:
{noformat}
 DEBUG [pool-126-thread-19] o.a.q.c.AMQConnection exceptionReceived done by:pool-126-thread-19
org.apache.qpid.AMQException: Session sync was interrupted by failover.
        at org.apache.qpid.client.AMQSession_0_10.setCurrentException(AMQSession_0_10.java:1061) [qpid-client-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
        at org.apache.qpid.client.AMQSession_0_10.sync(AMQSession_0_10.java:1041) [qpid-client-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
        at org.apache.qpid.client.AMQSession_0_10.sendSuspendChannel(AMQSession_0_10.java:820) [qpid-client-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
        at org.apache.qpid.client.AMQSession.suspendChannel(AMQSession.java:3244) ~[qpid-client-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
        at org.apache.qpid.client.AMQSession.rollback(AMQSession.java:1953) ~[qpid-client-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
        at org.apache.qpid.client.AMQSession.commit(AMQSession.java:896) ~[qpid-client-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
        at org.apache.qpid.server.store.berkeleydb.replication.MultiNodeTest$4.run(MultiNodeTest.java:575) ~[test-classes/:na]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) ~[na:1.7.0_25]
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) ~[na:1.7.0_25]
        at java.util.concurrent.FutureTask.run(FutureTask.java:166) ~[na:1.7.0_25]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) ~[na:1.7.0_25]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) ~[na:1.7.0_25]
        at java.lang.Thread.run(Thread.java:724) ~[na:1.7.0_25] 
{noformat}

If exception is reported via public JMS method we should not call .AMQSession_0_10.setCurrentException to report the exception into ExceptionListener.

> Session exceptions should only be notified via the exception listener, if it cannot be thrown directly to the application.
> --------------------------------------------------------------------------------------------------------------------------
>
>                 Key: QPID-3289
>                 URL: https://issues.apache.org/jira/browse/QPID-3289
>             Project: Qpid
>          Issue Type: Bug
>          Components: Java Client
>            Reporter: Rajith Attapattu
>            Assignee: Rajith Attapattu
>              Labels: exception-handling
>
> The 0-10 code path in the JMS client always notifies a session exception via the connection listener, even when it can throw a JMS exception for a synchronous method call.
> For example session.createConsumer(destination) could fail due to an ACL violation and the session gets closed with an execution exception.
> Currently the JMS client throws an exception and also notifies the connection listener which results in the connection (and any other sessions associated with that connection) being closed.
> Another undesirable effect of this is the potential for deadlocks happening around the failovermutex.
> A reasonable solution for this problem would be to not notify via the connection listener if there is a way of throwing an exception to the application directly.
> For example session.createConsumer/Producer is a synchronous call and we could easily throw a JMS exception. In this case there is little value in notifying this via the connection listener and it also has the undesirable effect of closing the connection.



--
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