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

Keith Wall edited comment on QPID-3704 at 1/5/12 8:58 AM:
----------------------------------------------------------

Problem is a race condition between an incoming enqueue and an outbound 
delivery. It is trigger by a particular data pattern.  I think the problem lies 
in OutOfOrderQueue#checkSubscriptionsNotAheadOfDelivery().

Imagine a set of messages with keys {3, 5, 4}.  Message 3 has been sent to a 
consumer, message 5 is in the process of being delivered, and message 4 is 
being enqueued.

When the unlucky timing strikes, the thread processing the enqueue observes 
_lastSeenEntry at 3, so does not update _releasedEntry.   A moment later the 
delivery thread sending Message 5 to the consumer calls #setLastSeenEntry 
setting _lastSeenEntry to 5.   This means message 4 becomes stuck and will 
remain undelivered to the consumer until a message with key less than 4 arrives.

I think the _lastSeenEntry optimisation is unsafe and incoming deliveries 
should always _releasedEntry backwards if necessary.  I attach a patch.  Any 
thoughts?



                
      was (Author: k-wall):
    Problem is a race condition between an incoming enqueue and an outbound 
delivery. It is trigger by a particular data pattern.  I think the problem lies 
in OutOfOrderQueue#checkSubscriptionsNotAheadOfDelivery().

Imagine a set of messages with keys {3, 5, 4}.  Message 3 has been sent to a 
consumer, message 5 is in the process of being delivered, and message 4 is 
being enqueued.

When the unlucky timing strikes, the thread processing the enqueue observes 
_lastSeenEntry at 3, so does not update _releasedEntry.   A moment later the 
delivery thread sending Message 5 to the consumer calls #setLastSeenEntry 
setting _lastSeenEntry to 5.   This means message 4 becomes stuck and will 
remain undelivered to the consumer until a message with key less than 4 arrives.

I think the _lastSeenEntry optimisation is unsafe and incoming deliveries 
should always move _releasedEntry backwards.  I attach a patch.  Any thoughts?



                  
> SortedQueueTest.testTransactedSortedQueue failing occasionally on 0-9-1 
> profile
> -------------------------------------------------------------------------------
>
>                 Key: QPID-3704
>                 URL: https://issues.apache.org/jira/browse/QPID-3704
>             Project: Qpid
>          Issue Type: Bug
>          Components: Java Broker, Java Tests
>            Reporter: Keith Wall
>             Fix For: 0.15
>
>         Attachments: 
> 0001-QPID-3704-OutOfOrderQueue-checkSubscriptionsNotAhead.patch
>
>
> Test appears to have begun failing after the performance improvement work.
> See 
> https://builds.apache.org/view/M-R/view/Qpid/job/Qpid-Java-Java-TestMatrix/188
>  and 
> https://builds.apache.org/view/M-R/view/Qpid/job/Qpid-Java-Java-TestMatrix/184
> {code}
> Incorrect number of messages received expected:<200> but was:<199>
> Stacktrace
> junit.framework.AssertionFailedError: Incorrect number of messages received 
> expected:<200> but was:<199>
>       at 
> org.apache.qpid.server.queue.SortedQueueTest.runThroughSortedQueueForSessionMode(SortedQueueTest.java:153)
>       at 
> org.apache.qpid.server.queue.SortedQueueTest.testTransactedSortedQueue(SortedQueueTest.java:115)
>       at 
> org.apache.qpid.test.utils.QpidBrokerTestCase.runBare(QpidBrokerTestCase.java:240)
>       at org.apache.qpid.test.utils.QpidTestCase.run(QpidTestCase.java:135)
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:[email protected]

Reply via email to