[
https://issues.apache.org/jira/browse/QPID-1871?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12712015#action_12712015
]
Martin Ritchie commented on QPID-1871:
--------------------------------------
What I was thinking at the end there was that simply signallying to the
dispatcher to stop is not enough. This is partially the problem we have just
now.
We need to know that it as finished processing and hit the wait L2877 before we
can safely complete rollback.
I think the best thing to do would be to push all the rollback code in to the
dispatcher and have the dispatcher thread process the rollback. As the Rollback
has session wide effect it makes sence to me that the dispatcher thread is the
right place to do this work. Otherwise we have to ensure that we have stopped
the dispatcher before proceeding. The logic around that stopping will become
complex when we have to handle the onMessage case.
Making the dispatcher thread responsible should make the locking far simpler.
It should also be clearer that a call from a different thread should request
rollback from the dispatcher and block whilst the dispatcher thread (from
onMessage) can perform the rollback.
To ensure message order is preserved we will need to have a method in to the
Transport Layer to know that all buffers have been purged. This will then allow
the dispatcher to reject all the messages with confidence that it will not miss
one.
The dispatcher will know when it has procesed all the messages on the session
and can safely send the TxRollback.
> During Rollback Client Rejects Message after sending TxRollback
> ---------------------------------------------------------------
>
> Key: QPID-1871
> URL: https://issues.apache.org/jira/browse/QPID-1871
> Project: Qpid
> Issue Type: Bug
> Components: Java Broker, Java Client
> Affects Versions: M4, 0.5
> Reporter: Martin Ritchie
>
> Summary:
> See QPID-1864 for annotated log output.
> The log output is from a run with the Java broker, but highlights that the
> client dispatcher thread is not synchronized with the main thread during
> rollback.
> As a result the main thread sends the TxRollback before the Dispatcher has
> sent its Reject message. This results, on the java broker, of the unrejected
> message being redelivered, which may be out of order depending on what other
> messages have been released on the message queue.
> If we are to continue to rely on the dispatcher thread rejecting/releasing
> the message it is currently processing (i.e. the message that is neither in
> the _queue preDispatchQueue nor the _synchronousQueue for receiver delivery)
> then we will need to synchronize with the main thread's rollback/recover
> calls so that the dispatcher can finish processing its message before the
> rollback/recover completes.
> The message that the Dispatcher thread has can be seen in AMQSession
> L:2866:dispatchMessage().
> On Rollback we stop the dispatcher (L2763) which can result in the dispatcher
> thread stopping on L2877 and holding on the the message it is in the middle
> of delivery.
> When the dispatcher is restarted (L2792) it is then free to reject its
> message. However, the thread that restarted the dispatcher's next call is to
> send the rollback command(L1553) Which is where the race condition occurs.
> Potential Fix:
> Message Rejection should be performed BEFORE we stop the dispatcher.
> On L:2825 we remove the message from the _queue (preDispatchQueue) and then
> potentailly sit on the message L:2877 when we get stopped.
> If the reject call in L:2888 was before the wait then we could reject the
> message rather than sit on it.
> Note: Now that I look at this a bit more the rollback (L2754) code looks to
> be over synchronized. I'm not sure the dispatcher will actually ever stop on
> the wait L2877 during rollback as the dispatcher is stopped and started again
> inside the one syncronisation which would prevent the dispatcher getting to
> the wait.
> Moving the setConnectionStopped calls out of the sync block along and
> ensuring that the _rollbackMark is updated before the connection is stopped
> then we should ok.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:[email protected]