Qpid
  1. Qpid
  2. QPID-3604

If the connection is stopped the client should release all it's messages in the prefetch buffer

    Details

      Description

      When connection.stop() is called, the JMS client should release all it's messages in the prefetch buffer.
      For all we know, the connection may never be started (depending on application logic) and those messages will be stuck on the prefetch buffer. Releasing it will allow another consumer to get them (in the case of a shared queue case).

      Another less severe but nevertheless an undesirable side affect of this is the client getting more messages than required by the capacity or prefetch arguments. See QPID-3602
      This may not be a big issue if the client is prefetching a few messages, but if prefetching something like 5000 messages, this could potentially cause a lethal spike in the clients memory usage.
      Even in low capacity/prefetch values, if the messages are large (say in the mega byte range) this could potentially put the client under memory pressure.

        Activity

        Rajith Attapattu made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Robbie Gemmell made changes -
        Field Original Value New Value
        Labels possibly_complete
        Hide
        Rajith Attapattu added a comment -

        Robbie, I've now changed the order and removed the lock.
        All tests pass on both the cpp profile and the java 0-10 profile.

        Show
        Rajith Attapattu added a comment - Robbie, I've now changed the order and removed the lock. All tests pass on both the cpp profile and the java 0-10 profile.
        Hide
        Rajith Attapattu added a comment -

        Robbie, I agree with you there.

        The sequence should be,

        1. Issue message stops and sync, waiting for the broker to confirm. At this point we can safely assume that the broker will not be sending any more messages.
        2. Drain the dispatch queue
        3. Drain the individual consumer queues.

        So if I change the order then I agree we don't need the message MessageDeliveryLock.

        Rajith

        Show
        Rajith Attapattu added a comment - Robbie, I agree with you there. The sequence should be, 1. Issue message stops and sync, waiting for the broker to confirm. At this point we can safely assume that the broker will not be sending any more messages. 2. Drain the dispatch queue 3. Drain the individual consumer queues. So if I change the order then I agree we don't need the message MessageDeliveryLock. Rajith
        Hide
        Robbie Gemmell added a comment - - edited

        I'm still not entirely convinced of the need to hold the lock. The only seeming reason to do so would be to stop messages still in the dispatch queue (or any arriving after the stop completes, which shouldnt occur) from being moved by the Dispatcher into the consumer queues while you are draining them. If that were the case then it doesnt seem sufficient, because as soon as you think you have drained the consumer queues and move on to release that lock, any such messages still remaining in the dispatch queue can then potentially be put into the consumer queues before you hit the 'drainDispatchQueue' invocation.

        Messages shouldnt arrive after stop() returns, at which point the dispatch queue can be drained to ensure no more messages are able to be delivered into the consumer queues, and after that the consumer queues can be safely drained without the lock because the Dispatcher has nothing to do.

        +    @Override
        +    void stop() throws AMQException
        +    {
        +        super.stop();
        +        synchronized (getMessageDeliveryLock())
        +        {
        +	        for (BasicMessageConsumer consumer : _consumers.values())
        +	        {
        +	            List<Long> tags = consumer.drainReceiverQueueAndRetrieveDeliveryTags();
        +	            _prefetchedMessageTags.addAll(tags);
        +	        }
        +        }
        +        _usingDispatcherForCleanup = true;
        +        drainDispatchQueue();
        +        _usingDispatcherForCleanup = false;
        
        Show
        Robbie Gemmell added a comment - - edited I'm still not entirely convinced of the need to hold the lock. The only seeming reason to do so would be to stop messages still in the dispatch queue (or any arriving after the stop completes, which shouldnt occur) from being moved by the Dispatcher into the consumer queues while you are draining them. If that were the case then it doesnt seem sufficient, because as soon as you think you have drained the consumer queues and move on to release that lock, any such messages still remaining in the dispatch queue can then potentially be put into the consumer queues before you hit the 'drainDispatchQueue' invocation. Messages shouldnt arrive after stop() returns, at which point the dispatch queue can be drained to ensure no more messages are able to be delivered into the consumer queues, and after that the consumer queues can be safely drained without the lock because the Dispatcher has nothing to do. + @Override + void stop() throws AMQException + { + super.stop(); + synchronized (getMessageDeliveryLock()) + { + for (BasicMessageConsumer consumer : _consumers.values()) + { + List<Long> tags = consumer.drainReceiverQueueAndRetrieveDeliveryTags(); + _prefetchedMessageTags.addAll(tags); + } + } + _usingDispatcherForCleanup = true; + drainDispatchQueue(); + _usingDispatcherForCleanup = false;
        Hide
        Rajith Attapattu added a comment -

        Sorry I forgot to exclude this test from the non 0-10 profiles.
        I only made a fix to the 0-10 code path.

        Show
        Rajith Attapattu added a comment - Sorry I forgot to exclude this test from the non 0-10 profiles. I only made a fix to the 0-10 code path.
        Hide
        Rob Godfrey added a comment -

        Rajith, your latest commit seems to have broken the 0-9-1 build:

        java.lang.NullPointerException
        at org.apache.qpid.client.BasicMessageProducer_0_8.declareDestination(BasicMessageProducer_0_8.java:58)
        at org.apache.qpid.client.BasicMessageProducer.<init>(BasicMessageProducer.java:139)
        at org.apache.qpid.client.BasicMessageProducer_0_8.<init>(BasicMessageProducer_0_8.java:51)
        at org.apache.qpid.client.AMQSession_0_8.createMessageProducer(AMQSession_0_8.java:478)
        at org.apache.qpid.client.AMQSession_0_8.createMessageProducer(AMQSession_0_8.java:85)
        at org.apache.qpid.client.AMQSession$7.execute(AMQSession.java:2679)
        at org.apache.qpid.client.AMQSession$7.execute(AMQSession.java:2670)
        at org.apache.qpid.client.AMQConnectionDelegate_8_0.executeRetrySupport(AMQConnectionDelegate_8_0.java:349)
        at org.apache.qpid.client.AMQConnection.executeRetrySupport(AMQConnection.java:577)
        at org.apache.qpid.client.failover.FailoverRetrySupport.execute(FailoverRetrySupport.java:102)
        at org.apache.qpid.client.AMQSession.createProducerImpl(AMQSession.java:2668)
        at org.apache.qpid.client.AMQSession.createProducer(AMQSession.java:1199)
        at org.apache.qpid.client.AMQSession.createProducer(AMQSession.java:120)
        at org.apache.qpid.client.prefetch.PrefetchBehaviourTest.testConnectionStop(PrefetchBehaviourTest.java:212)
        at org.apache.qpid.test.utils.QpidBrokerTestCase.runBare(QpidBrokerTestCase.java:242)
        at org.apache.qpid.test.utils.QpidTestCase.run(QpidTestCase.java:135)

        Please run both the 0-9-1 and 0-10 builds before committing a change

        Show
        Rob Godfrey added a comment - Rajith, your latest commit seems to have broken the 0-9-1 build: java.lang.NullPointerException at org.apache.qpid.client.BasicMessageProducer_0_8.declareDestination(BasicMessageProducer_0_8.java:58) at org.apache.qpid.client.BasicMessageProducer.<init>(BasicMessageProducer.java:139) at org.apache.qpid.client.BasicMessageProducer_0_8.<init>(BasicMessageProducer_0_8.java:51) at org.apache.qpid.client.AMQSession_0_8.createMessageProducer(AMQSession_0_8.java:478) at org.apache.qpid.client.AMQSession_0_8.createMessageProducer(AMQSession_0_8.java:85) at org.apache.qpid.client.AMQSession$7.execute(AMQSession.java:2679) at org.apache.qpid.client.AMQSession$7.execute(AMQSession.java:2670) at org.apache.qpid.client.AMQConnectionDelegate_8_0.executeRetrySupport(AMQConnectionDelegate_8_0.java:349) at org.apache.qpid.client.AMQConnection.executeRetrySupport(AMQConnection.java:577) at org.apache.qpid.client.failover.FailoverRetrySupport.execute(FailoverRetrySupport.java:102) at org.apache.qpid.client.AMQSession.createProducerImpl(AMQSession.java:2668) at org.apache.qpid.client.AMQSession.createProducer(AMQSession.java:1199) at org.apache.qpid.client.AMQSession.createProducer(AMQSession.java:120) at org.apache.qpid.client.prefetch.PrefetchBehaviourTest.testConnectionStop(PrefetchBehaviourTest.java:212) at org.apache.qpid.test.utils.QpidBrokerTestCase.runBare(QpidBrokerTestCase.java:242) at org.apache.qpid.test.utils.QpidTestCase.run(QpidTestCase.java:135) Please run both the 0-9-1 and 0-10 builds before committing a change
        Hide
        Rajith Attapattu added a comment -

        Agreed. I'm in the process of reversing it.
        However I don't see some of the failures observed in jenkins on my local copy.
        Until I investigated this issue further, it's best I revert it.
        Thanks for your patience.

        Show
        Rajith Attapattu added a comment - Agreed. I'm in the process of reversing it. However I don't see some of the failures observed in jenkins on my local copy. Until I investigated this issue further, it's best I revert it. Thanks for your patience.
        Hide
        Rob Godfrey added a comment -

        The commit associated with this JIRA doesn't seem to completely match the description - rather than releasing all the messages only when connection.stop() is called, it instead does so every time the channel is asked to suspend. While connection.stop() is one occasion when this happens, it is by no means the only one (e.g it is called every time a new consumer is registered, or if flow control is activated on a "no-ack" session).

        I also note that one of the tests regularly failing after this commit is the new test added in the same commit.

        Can I suggest that this change is reverted since these failures are making it difficult test whether other new work is causing failures or not.

        Show
        Rob Godfrey added a comment - The commit associated with this JIRA doesn't seem to completely match the description - rather than releasing all the messages only when connection.stop() is called, it instead does so every time the channel is asked to suspend. While connection.stop() is one occasion when this happens, it is by no means the only one (e.g it is called every time a new consumer is registered, or if flow control is activated on a "no-ack" session). I also note that one of the tests regularly failing after this commit is the new test added in the same commit. Can I suggest that this change is reverted since these failures are making it difficult test whether other new work is causing failures or not.
        Hide
        Keith Wall added a comment -

        Hi Rajith

        It seems this commit is causing may failing tests for both the CPP and Java Brokers on many profiles. You can see the failures on Jenkins:

        eg.

        >>> org.apache.qpid.client.MessageListenerTest.testMessageListenerThrowsError 0.14 sec 1
        >>> org.apache.qpid.client.failover.AddressBasedFailoverBehaviourTest.testTransactedQueueBrowserCloseWhileFailover 0.21 sec 1
        >>> org.apache.qpid.client.prefetch.PrefetchBehaviourTest.testConnectionStop 1.1 sec 1
        >>> org.apache.qpid.server.queue.MessageGroupQueueTest.testConsumerCloseGroupAssignment 0.11 sec 1
        >>> org.apache.qpid.test.client.queue.LVQTest.testLVQQueue

        Could you take a look?

        Show
        Keith Wall added a comment - Hi Rajith It seems this commit is causing may failing tests for both the CPP and Java Brokers on many profiles. You can see the failures on Jenkins: eg. >>> org.apache.qpid.client.MessageListenerTest.testMessageListenerThrowsError 0.14 sec 1 >>> org.apache.qpid.client.failover.AddressBasedFailoverBehaviourTest.testTransactedQueueBrowserCloseWhileFailover 0.21 sec 1 >>> org.apache.qpid.client.prefetch.PrefetchBehaviourTest.testConnectionStop 1.1 sec 1 >>> org.apache.qpid.server.queue.MessageGroupQueueTest.testConsumerCloseGroupAssignment 0.11 sec 1 >>> org.apache.qpid.test.client.queue.LVQTest.testLVQQueue Could you take a look?
        Hide
        jiraposter@reviews.apache.org added a comment -

        -----------------------------------------------------------
        This is an automatically generated e-mail. To reply, visit:
        https://reviews.apache.org/r/2832/
        -----------------------------------------------------------

        (Updated 2012-01-10 03:52:44.305560)

        Review request for qpid, Gordon Sim, Robbie Gemmell, Weston Price, and Oleksandr Rudyy.

        Summary
        -------

        This attempts to fix one of the issues related to the handling of Message credits. See QPID-3602 for an overall picture of the various issues.

        This particular patch does the following.
        1. When the connection is stopped, it sends message.stop() & releases all messages in the prefetch buffer.
        2. It will also release any messages (that were in flight) that comes after the connection is stopped.

        This interferes with the immediate_prefetch feature. However I don't know if immediate prefetch is really required in the 0-10 path.

        As always comments, suggestions & criticisms are equally welcomed.

        This addresses bug QPID-3604.
        https://issues.apache.org/jira/browse/QPID-3604

        Diffs (updated)


        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java 1229466
        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java 1229466
        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/prefetch/PrefetchBehaviourTest.java 1229466

        Diff: https://reviews.apache.org/r/2832/diff

        Testing
        -------

        See PrefetchBehaviourTest#testConnectionStop for more details.

        Thanks,

        rajith

        Show
        jiraposter@reviews.apache.org added a comment - ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/2832/ ----------------------------------------------------------- (Updated 2012-01-10 03:52:44.305560) Review request for qpid, Gordon Sim, Robbie Gemmell, Weston Price, and Oleksandr Rudyy. Summary ------- This attempts to fix one of the issues related to the handling of Message credits. See QPID-3602 for an overall picture of the various issues. This particular patch does the following. 1. When the connection is stopped, it sends message.stop() & releases all messages in the prefetch buffer. 2. It will also release any messages (that were in flight) that comes after the connection is stopped. This interferes with the immediate_prefetch feature. However I don't know if immediate prefetch is really required in the 0-10 path. As always comments, suggestions & criticisms are equally welcomed. This addresses bug QPID-3604 . https://issues.apache.org/jira/browse/QPID-3604 Diffs (updated) http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java 1229466 http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java 1229466 http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/prefetch/PrefetchBehaviourTest.java 1229466 Diff: https://reviews.apache.org/r/2832/diff Testing ------- See PrefetchBehaviourTest#testConnectionStop for more details. Thanks, rajith
        Hide
        jiraposter@reviews.apache.org added a comment -

        -----------------------------------------------------------
        This is an automatically generated e-mail. To reply, visit:
        https://reviews.apache.org/r/2832/
        -----------------------------------------------------------

        (Updated 2012-01-09 19:27:40.039273)

        Review request for qpid, Gordon Sim, Robbie Gemmell, Weston Price, and Oleksandr Rudyy.

        Changes
        -------

        This reworked patch addresses some of the concerns raised with the original patch.
        The message-delivery lock is still taken to ensure that no message delivery is attempted while the 'stopping' is in progress.
        IMO this is a nessacery evil.

        The code now drains individual consumer queues as well as the dispatch queue (via syncDipatchQueue method) and releases both unacked and prefetched messages, while only the former being marked redelivered.
        Also all of these transfers are being marked as completed to ensure credits don't dry up.

        Summary
        -------

        This attempts to fix one of the issues related to the handling of Message credits. See QPID-3602 for an overall picture of the various issues.

        This particular patch does the following.
        1. When the connection is stopped, it sends message.stop() & releases all messages in the prefetch buffer.
        2. It will also release any messages (that were in flight) that comes after the connection is stopped.

        This interferes with the immediate_prefetch feature. However I don't know if immediate prefetch is really required in the 0-10 path.

        As always comments, suggestions & criticisms are equally welcomed.

        This addresses bug QPID-3604.
        https://issues.apache.org/jira/browse/QPID-3604

        Diffs (updated)


        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java 1229312
        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java 1229312
        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/prefetch/PrefetchBehaviourTest.java 1229312

        Diff: https://reviews.apache.org/r/2832/diff

        Testing
        -------

        See PrefetchBehaviourTest#testConnectionStop for more details.

        Thanks,

        rajith

        Show
        jiraposter@reviews.apache.org added a comment - ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/2832/ ----------------------------------------------------------- (Updated 2012-01-09 19:27:40.039273) Review request for qpid, Gordon Sim, Robbie Gemmell, Weston Price, and Oleksandr Rudyy. Changes ------- This reworked patch addresses some of the concerns raised with the original patch. The message-delivery lock is still taken to ensure that no message delivery is attempted while the 'stopping' is in progress. IMO this is a nessacery evil. The code now drains individual consumer queues as well as the dispatch queue (via syncDipatchQueue method) and releases both unacked and prefetched messages, while only the former being marked redelivered. Also all of these transfers are being marked as completed to ensure credits don't dry up. Summary ------- This attempts to fix one of the issues related to the handling of Message credits. See QPID-3602 for an overall picture of the various issues. This particular patch does the following. 1. When the connection is stopped, it sends message.stop() & releases all messages in the prefetch buffer. 2. It will also release any messages (that were in flight) that comes after the connection is stopped. This interferes with the immediate_prefetch feature. However I don't know if immediate prefetch is really required in the 0-10 path. As always comments, suggestions & criticisms are equally welcomed. This addresses bug QPID-3604 . https://issues.apache.org/jira/browse/QPID-3604 Diffs (updated) http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java 1229312 http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java 1229312 http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/prefetch/PrefetchBehaviourTest.java 1229312 Diff: https://reviews.apache.org/r/2832/diff Testing ------- See PrefetchBehaviourTest#testConnectionStop for more details. Thanks, rajith
        Hide
        jiraposter@reviews.apache.org added a comment -

        On 2011-11-15 16:41:28, Gordon Sim wrote:

        > http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java, line 126

        > <https://reviews.apache.org/r/2832/diff/1/?file=58393#file58393line126>

        >

        > What case(s) is this code required for? You are releasing a message you have just received, right? When is that required?

        rajith attapattu wrote:

        See the above for an explanation for why this is needed.

        Gordon Sim wrote:

        You mean this is here because of the lack of synchronization with the dispatcher thread? If so that seems a little nasty to me... anyway to do this more cleanly?

        rajith attapattu wrote:

        That is precisely the reason. This also makes the sync call redundant. I started with the sync() and realized that it wasn't sufficient, hence added this.

        As explained above, I'm not sure if there is a reasonable way to synchronize with the message delivery thread.

        One possible approach might be is to do something like the syncDispatchQueue() method. Where we push a certain marker message into the queue and then we get that we know there are no more messages in the pipeline. But I'm concerned about the safety and feasibility of such an approach.

        Robbie I believe is one person who have looked at this code more extensively in the last little while. So waiting to hear from him about his ideas as well. I'm open to suggestions on this area. Lets see if we can collectively figure out a better solution.

        Robbie Gemmell wrote:

        (just noticed I didnt press publish yesterday morning on this...oops)

        > One possible approach might be is to do something like the syncDispatchQueue() method.

        This is exactly the comment I was going to make. Its not the nicest thing in the world, but I think its better than holding yet more locks. Ensuring that the broker has finished sending you messages on the stopped session and then having the Dispatcher do the work and tell you that there isnt anything left to deliver seems the easiest to reason about, and we already do that elsewhere so reusing the idea seems like the way to go.

        Let me work this out and see how it goes.

        • rajith

        -----------------------------------------------------------
        This is an automatically generated e-mail. To reply, visit:
        https://reviews.apache.org/r/2832/#review3264
        -----------------------------------------------------------

        On 2011-11-15 15:36:36, rajith attapattu wrote:

        -----------------------------------------------------------

        This is an automatically generated e-mail. To reply, visit:

        https://reviews.apache.org/r/2832/

        -----------------------------------------------------------

        (Updated 2011-11-15 15:36:36)

        Review request for qpid, Gordon Sim, Robbie Gemmell, Weston Price, and Oleksandr Rudyy.

        Summary

        -------

        This attempts to fix one of the issues related to the handling of Message credits. See QPID-3602 for an overall picture of the various issues.

        This particular patch does the following.

        1. When the connection is stopped, it sends message.stop() & releases all messages in the prefetch buffer.

        2. It will also release any messages (that were in flight) that comes after the connection is stopped.

        This interferes with the immediate_prefetch feature. However I don't know if immediate prefetch is really required in the 0-10 path.

        As always comments, suggestions & criticisms are equally welcomed.

        This addresses bug QPID-3604.

        https://issues.apache.org/jira/browse/QPID-3604

        Diffs

        -----

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java 1202228

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java 1202228

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/prefetch/PrefetchBehaviourTest.java 1202228

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java 1202228

        Diff: https://reviews.apache.org/r/2832/diff

        Testing

        -------

        See PrefetchBehaviourTest#testConnectionStop for more details.

        Thanks,

        rajith

        Show
        jiraposter@reviews.apache.org added a comment - On 2011-11-15 16:41:28, Gordon Sim wrote: > http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java , line 126 > < https://reviews.apache.org/r/2832/diff/1/?file=58393#file58393line126 > > > What case(s) is this code required for? You are releasing a message you have just received, right? When is that required? rajith attapattu wrote: See the above for an explanation for why this is needed. Gordon Sim wrote: You mean this is here because of the lack of synchronization with the dispatcher thread? If so that seems a little nasty to me... anyway to do this more cleanly? rajith attapattu wrote: That is precisely the reason. This also makes the sync call redundant. I started with the sync() and realized that it wasn't sufficient, hence added this. As explained above, I'm not sure if there is a reasonable way to synchronize with the message delivery thread. One possible approach might be is to do something like the syncDispatchQueue() method. Where we push a certain marker message into the queue and then we get that we know there are no more messages in the pipeline. But I'm concerned about the safety and feasibility of such an approach. Robbie I believe is one person who have looked at this code more extensively in the last little while. So waiting to hear from him about his ideas as well. I'm open to suggestions on this area. Lets see if we can collectively figure out a better solution. Robbie Gemmell wrote: (just noticed I didnt press publish yesterday morning on this...oops) > One possible approach might be is to do something like the syncDispatchQueue() method. This is exactly the comment I was going to make. Its not the nicest thing in the world, but I think its better than holding yet more locks. Ensuring that the broker has finished sending you messages on the stopped session and then having the Dispatcher do the work and tell you that there isnt anything left to deliver seems the easiest to reason about, and we already do that elsewhere so reusing the idea seems like the way to go. Let me work this out and see how it goes. rajith ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/2832/#review3264 ----------------------------------------------------------- On 2011-11-15 15:36:36, rajith attapattu wrote: ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/2832/ ----------------------------------------------------------- (Updated 2011-11-15 15:36:36) Review request for qpid, Gordon Sim, Robbie Gemmell, Weston Price, and Oleksandr Rudyy. Summary ------- This attempts to fix one of the issues related to the handling of Message credits. See QPID-3602 for an overall picture of the various issues. This particular patch does the following. 1. When the connection is stopped, it sends message.stop() & releases all messages in the prefetch buffer. 2. It will also release any messages (that were in flight) that comes after the connection is stopped. This interferes with the immediate_prefetch feature. However I don't know if immediate prefetch is really required in the 0-10 path. As always comments, suggestions & criticisms are equally welcomed. This addresses bug QPID-3604 . https://issues.apache.org/jira/browse/QPID-3604 Diffs ----- http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java 1202228 http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java 1202228 http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/prefetch/PrefetchBehaviourTest.java 1202228 http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java 1202228 Diff: https://reviews.apache.org/r/2832/diff Testing ------- See PrefetchBehaviourTest#testConnectionStop for more details. Thanks, rajith
        Hide
        jiraposter@reviews.apache.org added a comment -

        On 2011-11-16 09:38:21, Keith Wall wrote:

        > http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java, line 128

        > <https://reviews.apache.org/r/2832/diff/1/?file=58393#file58393line128>

        >

        > Could this make use of AMQSession#rejectMessage?

        >

        > I wonder also if this logic sit better in AMQSession#notifyConsumer(). It already rejects messages if the consumer is closed. Could it not also reject messages if the connection is no longer started?

        rajith attapattu wrote:

        Keith if you look at the rejectMessage method, it sets the redelivery option. In this case we should not be setting the redelivery option bcos the the application did not even see the message.

        I think we need to make a clear distinction btw reject and this case. If we are rejecting a message then we need to set redelivery. In other words the application had a look at it but decided not to use it. However in JMS you can't reject a message. So I'm not sure if setting redelivery in the rejectMessage is correct either.

        IMO the only time we should mark a message redelivered is when the application has seen a message but has not yet acknowledged. Ex consuming a bunch of messages in CLIENT_ACK and closing the consumer without acking any of the messages.

        Messages in the prefetch buffer should not be marked redelivered. I see there a few places where the rejectMessage method being used, and I don't think this is correct. Ex when we set a MessageListener we remove all messages in the internal queue and release them by setting the redelivery option.

        rajith attapattu wrote:

        Actually disregard the above comment. I totally forgot that the broker will mark all released messages as redelivered. So what the client sets doesn't really matter.

        Gordon Sim wrote:

        Re: "the broker will mark all released messages as redelivered. So what the client sets doesn't really matter."

        That is not the case. The broker does what the client tells it to via the set-redelivered field of the message-release command.

        Gordon is correct. So in that case Keith we will have to have re-evaluate the way we set the REDELIVERY flag.
        For the time being I prefer to have a separate release method.

        • rajith

        -----------------------------------------------------------
        This is an automatically generated e-mail. To reply, visit:
        https://reviews.apache.org/r/2832/#review3294
        -----------------------------------------------------------

        On 2011-11-15 15:36:36, rajith attapattu wrote:

        -----------------------------------------------------------

        This is an automatically generated e-mail. To reply, visit:

        https://reviews.apache.org/r/2832/

        -----------------------------------------------------------

        (Updated 2011-11-15 15:36:36)

        Review request for qpid, Gordon Sim, Robbie Gemmell, Weston Price, and Oleksandr Rudyy.

        Summary

        -------

        This attempts to fix one of the issues related to the handling of Message credits. See QPID-3602 for an overall picture of the various issues.

        This particular patch does the following.

        1. When the connection is stopped, it sends message.stop() & releases all messages in the prefetch buffer.

        2. It will also release any messages (that were in flight) that comes after the connection is stopped.

        This interferes with the immediate_prefetch feature. However I don't know if immediate prefetch is really required in the 0-10 path.

        As always comments, suggestions & criticisms are equally welcomed.

        This addresses bug QPID-3604.

        https://issues.apache.org/jira/browse/QPID-3604

        Diffs

        -----

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java 1202228

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java 1202228

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/prefetch/PrefetchBehaviourTest.java 1202228

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java 1202228

        Diff: https://reviews.apache.org/r/2832/diff

        Testing

        -------

        See PrefetchBehaviourTest#testConnectionStop for more details.

        Thanks,

        rajith

        Show
        jiraposter@reviews.apache.org added a comment - On 2011-11-16 09:38:21, Keith Wall wrote: > http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java , line 128 > < https://reviews.apache.org/r/2832/diff/1/?file=58393#file58393line128 > > > Could this make use of AMQSession#rejectMessage? > > I wonder also if this logic sit better in AMQSession#notifyConsumer(). It already rejects messages if the consumer is closed. Could it not also reject messages if the connection is no longer started? rajith attapattu wrote: Keith if you look at the rejectMessage method, it sets the redelivery option. In this case we should not be setting the redelivery option bcos the the application did not even see the message. I think we need to make a clear distinction btw reject and this case. If we are rejecting a message then we need to set redelivery. In other words the application had a look at it but decided not to use it. However in JMS you can't reject a message. So I'm not sure if setting redelivery in the rejectMessage is correct either. IMO the only time we should mark a message redelivered is when the application has seen a message but has not yet acknowledged. Ex consuming a bunch of messages in CLIENT_ACK and closing the consumer without acking any of the messages. Messages in the prefetch buffer should not be marked redelivered. I see there a few places where the rejectMessage method being used, and I don't think this is correct. Ex when we set a MessageListener we remove all messages in the internal queue and release them by setting the redelivery option. rajith attapattu wrote: Actually disregard the above comment. I totally forgot that the broker will mark all released messages as redelivered. So what the client sets doesn't really matter. Gordon Sim wrote: Re: "the broker will mark all released messages as redelivered. So what the client sets doesn't really matter." That is not the case. The broker does what the client tells it to via the set-redelivered field of the message-release command. Gordon is correct. So in that case Keith we will have to have re-evaluate the way we set the REDELIVERY flag. For the time being I prefer to have a separate release method. rajith ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/2832/#review3294 ----------------------------------------------------------- On 2011-11-15 15:36:36, rajith attapattu wrote: ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/2832/ ----------------------------------------------------------- (Updated 2011-11-15 15:36:36) Review request for qpid, Gordon Sim, Robbie Gemmell, Weston Price, and Oleksandr Rudyy. Summary ------- This attempts to fix one of the issues related to the handling of Message credits. See QPID-3602 for an overall picture of the various issues. This particular patch does the following. 1. When the connection is stopped, it sends message.stop() & releases all messages in the prefetch buffer. 2. It will also release any messages (that were in flight) that comes after the connection is stopped. This interferes with the immediate_prefetch feature. However I don't know if immediate prefetch is really required in the 0-10 path. As always comments, suggestions & criticisms are equally welcomed. This addresses bug QPID-3604 . https://issues.apache.org/jira/browse/QPID-3604 Diffs ----- http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java 1202228 http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java 1202228 http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/prefetch/PrefetchBehaviourTest.java 1202228 http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java 1202228 Diff: https://reviews.apache.org/r/2832/diff Testing ------- See PrefetchBehaviourTest#testConnectionStop for more details. Thanks, rajith
        Hide
        jiraposter@reviews.apache.org added a comment -

        On 2011-11-16 09:38:21, Keith Wall wrote:

        > http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java, line 128

        > <https://reviews.apache.org/r/2832/diff/1/?file=58393#file58393line128>

        >

        > Could this make use of AMQSession#rejectMessage?

        >

        > I wonder also if this logic sit better in AMQSession#notifyConsumer(). It already rejects messages if the consumer is closed. Could it not also reject messages if the connection is no longer started?

        rajith attapattu wrote:

        Keith if you look at the rejectMessage method, it sets the redelivery option. In this case we should not be setting the redelivery option bcos the the application did not even see the message.

        I think we need to make a clear distinction btw reject and this case. If we are rejecting a message then we need to set redelivery. In other words the application had a look at it but decided not to use it. However in JMS you can't reject a message. So I'm not sure if setting redelivery in the rejectMessage is correct either.

        IMO the only time we should mark a message redelivered is when the application has seen a message but has not yet acknowledged. Ex consuming a bunch of messages in CLIENT_ACK and closing the consumer without acking any of the messages.

        Messages in the prefetch buffer should not be marked redelivered. I see there a few places where the rejectMessage method being used, and I don't think this is correct. Ex when we set a MessageListener we remove all messages in the internal queue and release them by setting the redelivery option.

        rajith attapattu wrote:

        Actually disregard the above comment. I totally forgot that the broker will mark all released messages as redelivered. So what the client sets doesn't really matter.

        Re: "the broker will mark all released messages as redelivered. So what the client sets doesn't really matter."

        That is not the case. The broker does what the client tells it to via the set-redelivered field of the message-release command.

        • Gordon

        -----------------------------------------------------------
        This is an automatically generated e-mail. To reply, visit:
        https://reviews.apache.org/r/2832/#review3294
        -----------------------------------------------------------

        On 2011-11-15 15:36:36, rajith attapattu wrote:

        -----------------------------------------------------------

        This is an automatically generated e-mail. To reply, visit:

        https://reviews.apache.org/r/2832/

        -----------------------------------------------------------

        (Updated 2011-11-15 15:36:36)

        Review request for qpid, Gordon Sim, Robbie Gemmell, Weston Price, and Oleksandr Rudyy.

        Summary

        -------

        This attempts to fix one of the issues related to the handling of Message credits. See QPID-3602 for an overall picture of the various issues.

        This particular patch does the following.

        1. When the connection is stopped, it sends message.stop() & releases all messages in the prefetch buffer.

        2. It will also release any messages (that were in flight) that comes after the connection is stopped.

        This interferes with the immediate_prefetch feature. However I don't know if immediate prefetch is really required in the 0-10 path.

        As always comments, suggestions & criticisms are equally welcomed.

        This addresses bug QPID-3604.

        https://issues.apache.org/jira/browse/QPID-3604

        Diffs

        -----

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java 1202228

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java 1202228

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/prefetch/PrefetchBehaviourTest.java 1202228

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java 1202228

        Diff: https://reviews.apache.org/r/2832/diff

        Testing

        -------

        See PrefetchBehaviourTest#testConnectionStop for more details.

        Thanks,

        rajith

        Show
        jiraposter@reviews.apache.org added a comment - On 2011-11-16 09:38:21, Keith Wall wrote: > http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java , line 128 > < https://reviews.apache.org/r/2832/diff/1/?file=58393#file58393line128 > > > Could this make use of AMQSession#rejectMessage? > > I wonder also if this logic sit better in AMQSession#notifyConsumer(). It already rejects messages if the consumer is closed. Could it not also reject messages if the connection is no longer started? rajith attapattu wrote: Keith if you look at the rejectMessage method, it sets the redelivery option. In this case we should not be setting the redelivery option bcos the the application did not even see the message. I think we need to make a clear distinction btw reject and this case. If we are rejecting a message then we need to set redelivery. In other words the application had a look at it but decided not to use it. However in JMS you can't reject a message. So I'm not sure if setting redelivery in the rejectMessage is correct either. IMO the only time we should mark a message redelivered is when the application has seen a message but has not yet acknowledged. Ex consuming a bunch of messages in CLIENT_ACK and closing the consumer without acking any of the messages. Messages in the prefetch buffer should not be marked redelivered. I see there a few places where the rejectMessage method being used, and I don't think this is correct. Ex when we set a MessageListener we remove all messages in the internal queue and release them by setting the redelivery option. rajith attapattu wrote: Actually disregard the above comment. I totally forgot that the broker will mark all released messages as redelivered. So what the client sets doesn't really matter. Re: "the broker will mark all released messages as redelivered. So what the client sets doesn't really matter." That is not the case. The broker does what the client tells it to via the set-redelivered field of the message-release command. Gordon ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/2832/#review3294 ----------------------------------------------------------- On 2011-11-15 15:36:36, rajith attapattu wrote: ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/2832/ ----------------------------------------------------------- (Updated 2011-11-15 15:36:36) Review request for qpid, Gordon Sim, Robbie Gemmell, Weston Price, and Oleksandr Rudyy. Summary ------- This attempts to fix one of the issues related to the handling of Message credits. See QPID-3602 for an overall picture of the various issues. This particular patch does the following. 1. When the connection is stopped, it sends message.stop() & releases all messages in the prefetch buffer. 2. It will also release any messages (that were in flight) that comes after the connection is stopped. This interferes with the immediate_prefetch feature. However I don't know if immediate prefetch is really required in the 0-10 path. As always comments, suggestions & criticisms are equally welcomed. This addresses bug QPID-3604 . https://issues.apache.org/jira/browse/QPID-3604 Diffs ----- http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java 1202228 http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java 1202228 http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/prefetch/PrefetchBehaviourTest.java 1202228 http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java 1202228 Diff: https://reviews.apache.org/r/2832/diff Testing ------- See PrefetchBehaviourTest#testConnectionStop for more details. Thanks, rajith
        Hide
        jiraposter@reviews.apache.org added a comment -

        On 2011-11-15 16:41:28, Gordon Sim wrote:

        > http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java, line 126

        > <https://reviews.apache.org/r/2832/diff/1/?file=58393#file58393line126>

        >

        > What case(s) is this code required for? You are releasing a message you have just received, right? When is that required?

        rajith attapattu wrote:

        See the above for an explanation for why this is needed.

        Gordon Sim wrote:

        You mean this is here because of the lack of synchronization with the dispatcher thread? If so that seems a little nasty to me... anyway to do this more cleanly?

        rajith attapattu wrote:

        That is precisely the reason. This also makes the sync call redundant. I started with the sync() and realized that it wasn't sufficient, hence added this.

        As explained above, I'm not sure if there is a reasonable way to synchronize with the message delivery thread.

        One possible approach might be is to do something like the syncDispatchQueue() method. Where we push a certain marker message into the queue and then we get that we know there are no more messages in the pipeline. But I'm concerned about the safety and feasibility of such an approach.

        Robbie I believe is one person who have looked at this code more extensively in the last little while. So waiting to hear from him about his ideas as well. I'm open to suggestions on this area. Lets see if we can collectively figure out a better solution.

        (just noticed I didnt press publish yesterday morning on this...oops)

        One possible approach might be is to do something like the syncDispatchQueue() method.

        This is exactly the comment I was going to make. Its not the nicest thing in the world, but I think its better than holding yet more locks. Ensuring that the broker has finished sending you messages on the stopped session and then having the Dispatcher do the work and tell you that there isnt anything left to deliver seems the easiest to reason about, and we already do that elsewhere so reusing the idea seems like the way to go.

        • Robbie

        -----------------------------------------------------------
        This is an automatically generated e-mail. To reply, visit:
        https://reviews.apache.org/r/2832/#review3264
        -----------------------------------------------------------

        On 2011-11-15 15:36:36, rajith attapattu wrote:

        -----------------------------------------------------------

        This is an automatically generated e-mail. To reply, visit:

        https://reviews.apache.org/r/2832/

        -----------------------------------------------------------

        (Updated 2011-11-15 15:36:36)

        Review request for qpid, Gordon Sim, Robbie Gemmell, Weston Price, and Oleksandr Rudyy.

        Summary

        -------

        This attempts to fix one of the issues related to the handling of Message credits. See QPID-3602 for an overall picture of the various issues.

        This particular patch does the following.

        1. When the connection is stopped, it sends message.stop() & releases all messages in the prefetch buffer.

        2. It will also release any messages (that were in flight) that comes after the connection is stopped.

        This interferes with the immediate_prefetch feature. However I don't know if immediate prefetch is really required in the 0-10 path.

        As always comments, suggestions & criticisms are equally welcomed.

        This addresses bug QPID-3604.

        https://issues.apache.org/jira/browse/QPID-3604

        Diffs

        -----

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java 1202228

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java 1202228

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/prefetch/PrefetchBehaviourTest.java 1202228

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java 1202228

        Diff: https://reviews.apache.org/r/2832/diff

        Testing

        -------

        See PrefetchBehaviourTest#testConnectionStop for more details.

        Thanks,

        rajith

        Show
        jiraposter@reviews.apache.org added a comment - On 2011-11-15 16:41:28, Gordon Sim wrote: > http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java , line 126 > < https://reviews.apache.org/r/2832/diff/1/?file=58393#file58393line126 > > > What case(s) is this code required for? You are releasing a message you have just received, right? When is that required? rajith attapattu wrote: See the above for an explanation for why this is needed. Gordon Sim wrote: You mean this is here because of the lack of synchronization with the dispatcher thread? If so that seems a little nasty to me... anyway to do this more cleanly? rajith attapattu wrote: That is precisely the reason. This also makes the sync call redundant. I started with the sync() and realized that it wasn't sufficient, hence added this. As explained above, I'm not sure if there is a reasonable way to synchronize with the message delivery thread. One possible approach might be is to do something like the syncDispatchQueue() method. Where we push a certain marker message into the queue and then we get that we know there are no more messages in the pipeline. But I'm concerned about the safety and feasibility of such an approach. Robbie I believe is one person who have looked at this code more extensively in the last little while. So waiting to hear from him about his ideas as well. I'm open to suggestions on this area. Lets see if we can collectively figure out a better solution. (just noticed I didnt press publish yesterday morning on this...oops) One possible approach might be is to do something like the syncDispatchQueue() method. This is exactly the comment I was going to make. Its not the nicest thing in the world, but I think its better than holding yet more locks. Ensuring that the broker has finished sending you messages on the stopped session and then having the Dispatcher do the work and tell you that there isnt anything left to deliver seems the easiest to reason about, and we already do that elsewhere so reusing the idea seems like the way to go. Robbie ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/2832/#review3264 ----------------------------------------------------------- On 2011-11-15 15:36:36, rajith attapattu wrote: ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/2832/ ----------------------------------------------------------- (Updated 2011-11-15 15:36:36) Review request for qpid, Gordon Sim, Robbie Gemmell, Weston Price, and Oleksandr Rudyy. Summary ------- This attempts to fix one of the issues related to the handling of Message credits. See QPID-3602 for an overall picture of the various issues. This particular patch does the following. 1. When the connection is stopped, it sends message.stop() & releases all messages in the prefetch buffer. 2. It will also release any messages (that were in flight) that comes after the connection is stopped. This interferes with the immediate_prefetch feature. However I don't know if immediate prefetch is really required in the 0-10 path. As always comments, suggestions & criticisms are equally welcomed. This addresses bug QPID-3604 . https://issues.apache.org/jira/browse/QPID-3604 Diffs ----- http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java 1202228 http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java 1202228 http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/prefetch/PrefetchBehaviourTest.java 1202228 http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java 1202228 Diff: https://reviews.apache.org/r/2832/diff Testing ------- See PrefetchBehaviourTest#testConnectionStop for more details. Thanks, rajith
        Hide
        jiraposter@reviews.apache.org added a comment -

        On 2011-11-16 09:38:21, Keith Wall wrote:

        > http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java, line 128

        > <https://reviews.apache.org/r/2832/diff/1/?file=58393#file58393line128>

        >

        > Could this make use of AMQSession#rejectMessage?

        >

        > I wonder also if this logic sit better in AMQSession#notifyConsumer(). It already rejects messages if the consumer is closed. Could it not also reject messages if the connection is no longer started?

        rajith attapattu wrote:

        Keith if you look at the rejectMessage method, it sets the redelivery option. In this case we should not be setting the redelivery option bcos the the application did not even see the message.

        I think we need to make a clear distinction btw reject and this case. If we are rejecting a message then we need to set redelivery. In other words the application had a look at it but decided not to use it. However in JMS you can't reject a message. So I'm not sure if setting redelivery in the rejectMessage is correct either.

        IMO the only time we should mark a message redelivered is when the application has seen a message but has not yet acknowledged. Ex consuming a bunch of messages in CLIENT_ACK and closing the consumer without acking any of the messages.

        Messages in the prefetch buffer should not be marked redelivered. I see there a few places where the rejectMessage method being used, and I don't think this is correct. Ex when we set a MessageListener we remove all messages in the internal queue and release them by setting the redelivery option.

        Actually disregard the above comment. I totally forgot that the broker will mark all released messages as redelivered. So what the client sets doesn't really matter.

        • rajith

        -----------------------------------------------------------
        This is an automatically generated e-mail. To reply, visit:
        https://reviews.apache.org/r/2832/#review3294
        -----------------------------------------------------------

        On 2011-11-15 15:36:36, rajith attapattu wrote:

        -----------------------------------------------------------

        This is an automatically generated e-mail. To reply, visit:

        https://reviews.apache.org/r/2832/

        -----------------------------------------------------------

        (Updated 2011-11-15 15:36:36)

        Review request for qpid, Gordon Sim, Robbie Gemmell, Weston Price, and Oleksandr Rudyy.

        Summary

        -------

        This attempts to fix one of the issues related to the handling of Message credits. See QPID-3602 for an overall picture of the various issues.

        This particular patch does the following.

        1. When the connection is stopped, it sends message.stop() & releases all messages in the prefetch buffer.

        2. It will also release any messages (that were in flight) that comes after the connection is stopped.

        This interferes with the immediate_prefetch feature. However I don't know if immediate prefetch is really required in the 0-10 path.

        As always comments, suggestions & criticisms are equally welcomed.

        This addresses bug QPID-3604.

        https://issues.apache.org/jira/browse/QPID-3604

        Diffs

        -----

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java 1202228

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java 1202228

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/prefetch/PrefetchBehaviourTest.java 1202228

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java 1202228

        Diff: https://reviews.apache.org/r/2832/diff

        Testing

        -------

        See PrefetchBehaviourTest#testConnectionStop for more details.

        Thanks,

        rajith

        Show
        jiraposter@reviews.apache.org added a comment - On 2011-11-16 09:38:21, Keith Wall wrote: > http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java , line 128 > < https://reviews.apache.org/r/2832/diff/1/?file=58393#file58393line128 > > > Could this make use of AMQSession#rejectMessage? > > I wonder also if this logic sit better in AMQSession#notifyConsumer(). It already rejects messages if the consumer is closed. Could it not also reject messages if the connection is no longer started? rajith attapattu wrote: Keith if you look at the rejectMessage method, it sets the redelivery option. In this case we should not be setting the redelivery option bcos the the application did not even see the message. I think we need to make a clear distinction btw reject and this case. If we are rejecting a message then we need to set redelivery. In other words the application had a look at it but decided not to use it. However in JMS you can't reject a message. So I'm not sure if setting redelivery in the rejectMessage is correct either. IMO the only time we should mark a message redelivered is when the application has seen a message but has not yet acknowledged. Ex consuming a bunch of messages in CLIENT_ACK and closing the consumer without acking any of the messages. Messages in the prefetch buffer should not be marked redelivered. I see there a few places where the rejectMessage method being used, and I don't think this is correct. Ex when we set a MessageListener we remove all messages in the internal queue and release them by setting the redelivery option. Actually disregard the above comment. I totally forgot that the broker will mark all released messages as redelivered. So what the client sets doesn't really matter. rajith ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/2832/#review3294 ----------------------------------------------------------- On 2011-11-15 15:36:36, rajith attapattu wrote: ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/2832/ ----------------------------------------------------------- (Updated 2011-11-15 15:36:36) Review request for qpid, Gordon Sim, Robbie Gemmell, Weston Price, and Oleksandr Rudyy. Summary ------- This attempts to fix one of the issues related to the handling of Message credits. See QPID-3602 for an overall picture of the various issues. This particular patch does the following. 1. When the connection is stopped, it sends message.stop() & releases all messages in the prefetch buffer. 2. It will also release any messages (that were in flight) that comes after the connection is stopped. This interferes with the immediate_prefetch feature. However I don't know if immediate prefetch is really required in the 0-10 path. As always comments, suggestions & criticisms are equally welcomed. This addresses bug QPID-3604 . https://issues.apache.org/jira/browse/QPID-3604 Diffs ----- http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java 1202228 http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java 1202228 http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/prefetch/PrefetchBehaviourTest.java 1202228 http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java 1202228 Diff: https://reviews.apache.org/r/2832/diff Testing ------- See PrefetchBehaviourTest#testConnectionStop for more details. Thanks, rajith
        Hide
        jiraposter@reviews.apache.org added a comment -

        On 2011-11-16 09:38:21, Keith Wall wrote:

        > http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java, line 128

        > <https://reviews.apache.org/r/2832/diff/1/?file=58393#file58393line128>

        >

        > Could this make use of AMQSession#rejectMessage?

        >

        > I wonder also if this logic sit better in AMQSession#notifyConsumer(). It already rejects messages if the consumer is closed. Could it not also reject messages if the connection is no longer started?

        Keith if you look at the rejectMessage method, it sets the redelivery option. In this case we should not be setting the redelivery option bcos the the application did not even see the message.

        I think we need to make a clear distinction btw reject and this case. If we are rejecting a message then we need to set redelivery. In other words the application had a look at it but decided not to use it. However in JMS you can't reject a message. So I'm not sure if setting redelivery in the rejectMessage is correct either.

        IMO the only time we should mark a message redelivered is when the application has seen a message but has not yet acknowledged. Ex consuming a bunch of messages in CLIENT_ACK and closing the consumer without acking any of the messages.

        Messages in the prefetch buffer should not be marked redelivered. I see there a few places where the rejectMessage method being used, and I don't think this is correct. Ex when we set a MessageListener we remove all messages in the internal queue and release them by setting the redelivery option.

        On 2011-11-16 09:38:21, Keith Wall wrote:

        > http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/prefetch/PrefetchBehaviourTest.java, line 135

        > <https://reviews.apache.org/r/2832/diff/1/?file=58394#file58394line135>

        >

        > Could you not use the test utility method for the production of these messages?

        > QpidBrokerTestCase#sendMessage

        that could be done.

        On 2011-11-16 09:38:21, Keith Wall wrote:

        > http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/prefetch/PrefetchBehaviourTest.java, line 140

        > <https://reviews.apache.org/r/2832/diff/1/?file=58394#file58394line140>

        >

        > I think using a timeout here would be preferable. IMHO we should avoid writing unit tests that can hang indefinitely in favour of those that will always fail with a useful assertion-fail.

        >

        > Also typo in assertion message (once -> one).

        Ah, I did have a timeout and the typo was correct (as it was pointed out by someone else too), it seems like I generated the patches before these changes.
        Definitely we should always use a timeout. This will be corrected.

        On 2011-11-16 09:38:21, Keith Wall wrote:

        > http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/prefetch/PrefetchBehaviourTest.java, line 152

        > <https://reviews.apache.org/r/2832/diff/1/?file=58394#file58394line152>

        >

        > You've got a couple of whitespace issues that make the patch slightly larger than need be

        It seems eclipse is doing this. I tried using the AnyEdit plugging and it made matters worse. I will try to edit this on the command line before I do the final commit

        • rajith

        -----------------------------------------------------------
        This is an automatically generated e-mail. To reply, visit:
        https://reviews.apache.org/r/2832/#review3294
        -----------------------------------------------------------

        On 2011-11-15 15:36:36, rajith attapattu wrote:

        -----------------------------------------------------------

        This is an automatically generated e-mail. To reply, visit:

        https://reviews.apache.org/r/2832/

        -----------------------------------------------------------

        (Updated 2011-11-15 15:36:36)

        Review request for qpid, Gordon Sim, Robbie Gemmell, Weston Price, and Oleksandr Rudyy.

        Summary

        -------

        This attempts to fix one of the issues related to the handling of Message credits. See QPID-3602 for an overall picture of the various issues.

        This particular patch does the following.

        1. When the connection is stopped, it sends message.stop() & releases all messages in the prefetch buffer.

        2. It will also release any messages (that were in flight) that comes after the connection is stopped.

        This interferes with the immediate_prefetch feature. However I don't know if immediate prefetch is really required in the 0-10 path.

        As always comments, suggestions & criticisms are equally welcomed.

        This addresses bug QPID-3604.

        https://issues.apache.org/jira/browse/QPID-3604

        Diffs

        -----

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java 1202228

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java 1202228

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/prefetch/PrefetchBehaviourTest.java 1202228

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java 1202228

        Diff: https://reviews.apache.org/r/2832/diff

        Testing

        -------

        See PrefetchBehaviourTest#testConnectionStop for more details.

        Thanks,

        rajith

        Show
        jiraposter@reviews.apache.org added a comment - On 2011-11-16 09:38:21, Keith Wall wrote: > http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java , line 128 > < https://reviews.apache.org/r/2832/diff/1/?file=58393#file58393line128 > > > Could this make use of AMQSession#rejectMessage? > > I wonder also if this logic sit better in AMQSession#notifyConsumer(). It already rejects messages if the consumer is closed. Could it not also reject messages if the connection is no longer started? Keith if you look at the rejectMessage method, it sets the redelivery option. In this case we should not be setting the redelivery option bcos the the application did not even see the message. I think we need to make a clear distinction btw reject and this case. If we are rejecting a message then we need to set redelivery. In other words the application had a look at it but decided not to use it. However in JMS you can't reject a message. So I'm not sure if setting redelivery in the rejectMessage is correct either. IMO the only time we should mark a message redelivered is when the application has seen a message but has not yet acknowledged. Ex consuming a bunch of messages in CLIENT_ACK and closing the consumer without acking any of the messages. Messages in the prefetch buffer should not be marked redelivered. I see there a few places where the rejectMessage method being used, and I don't think this is correct. Ex when we set a MessageListener we remove all messages in the internal queue and release them by setting the redelivery option. On 2011-11-16 09:38:21, Keith Wall wrote: > http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/prefetch/PrefetchBehaviourTest.java , line 135 > < https://reviews.apache.org/r/2832/diff/1/?file=58394#file58394line135 > > > Could you not use the test utility method for the production of these messages? > QpidBrokerTestCase#sendMessage that could be done. On 2011-11-16 09:38:21, Keith Wall wrote: > http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/prefetch/PrefetchBehaviourTest.java , line 140 > < https://reviews.apache.org/r/2832/diff/1/?file=58394#file58394line140 > > > I think using a timeout here would be preferable. IMHO we should avoid writing unit tests that can hang indefinitely in favour of those that will always fail with a useful assertion-fail. > > Also typo in assertion message (once -> one). Ah, I did have a timeout and the typo was correct (as it was pointed out by someone else too), it seems like I generated the patches before these changes. Definitely we should always use a timeout. This will be corrected. On 2011-11-16 09:38:21, Keith Wall wrote: > http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/prefetch/PrefetchBehaviourTest.java , line 152 > < https://reviews.apache.org/r/2832/diff/1/?file=58394#file58394line152 > > > You've got a couple of whitespace issues that make the patch slightly larger than need be It seems eclipse is doing this. I tried using the AnyEdit plugging and it made matters worse. I will try to edit this on the command line before I do the final commit rajith ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/2832/#review3294 ----------------------------------------------------------- On 2011-11-15 15:36:36, rajith attapattu wrote: ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/2832/ ----------------------------------------------------------- (Updated 2011-11-15 15:36:36) Review request for qpid, Gordon Sim, Robbie Gemmell, Weston Price, and Oleksandr Rudyy. Summary ------- This attempts to fix one of the issues related to the handling of Message credits. See QPID-3602 for an overall picture of the various issues. This particular patch does the following. 1. When the connection is stopped, it sends message.stop() & releases all messages in the prefetch buffer. 2. It will also release any messages (that were in flight) that comes after the connection is stopped. This interferes with the immediate_prefetch feature. However I don't know if immediate prefetch is really required in the 0-10 path. As always comments, suggestions & criticisms are equally welcomed. This addresses bug QPID-3604 . https://issues.apache.org/jira/browse/QPID-3604 Diffs ----- http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java 1202228 http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java 1202228 http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/prefetch/PrefetchBehaviourTest.java 1202228 http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java 1202228 Diff: https://reviews.apache.org/r/2832/diff Testing ------- See PrefetchBehaviourTest#testConnectionStop for more details. Thanks, rajith
        Hide
        jiraposter@reviews.apache.org added a comment -

        -----------------------------------------------------------
        This is an automatically generated e-mail. To reply, visit:
        https://reviews.apache.org/r/2832/#review3294
        -----------------------------------------------------------

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java
        <https://reviews.apache.org/r/2832/#comment7376>

        Could this make use of AMQSession#rejectMessage?

        I wonder also if this logic sit better in AMQSession#notifyConsumer(). It already rejects messages if the consumer is closed. Could it not also reject messages if the connection is no longer started?

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/prefetch/PrefetchBehaviourTest.java
        <https://reviews.apache.org/r/2832/#comment7374>

        Could you not use the test utility method for the production of these messages?
        QpidBrokerTestCase#sendMessage

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/prefetch/PrefetchBehaviourTest.java
        <https://reviews.apache.org/r/2832/#comment7375>

        I think using a timeout here would be preferable. IMHO we should avoid writing unit tests that can hang indefinitely in favour of those that will always fail with a useful assertion-fail.

        Also typo in assertion message (once -> one).

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/prefetch/PrefetchBehaviourTest.java
        <https://reviews.apache.org/r/2832/#comment7377>

        You've got a couple of whitespace issues that make the patch slightly larger than need be

        • Keith

        On 2011-11-15 15:36:36, rajith attapattu wrote:

        -----------------------------------------------------------

        This is an automatically generated e-mail. To reply, visit:

        https://reviews.apache.org/r/2832/

        -----------------------------------------------------------

        (Updated 2011-11-15 15:36:36)

        Review request for qpid, Gordon Sim, Robbie Gemmell, Weston Price, and Oleksandr Rudyy.

        Summary

        -------

        This attempts to fix one of the issues related to the handling of Message credits. See QPID-3602 for an overall picture of the various issues.

        This particular patch does the following.

        1. When the connection is stopped, it sends message.stop() & releases all messages in the prefetch buffer.

        2. It will also release any messages (that were in flight) that comes after the connection is stopped.

        This interferes with the immediate_prefetch feature. However I don't know if immediate prefetch is really required in the 0-10 path.

        As always comments, suggestions & criticisms are equally welcomed.

        This addresses bug QPID-3604.

        https://issues.apache.org/jira/browse/QPID-3604

        Diffs

        -----

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java 1202228

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java 1202228

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/prefetch/PrefetchBehaviourTest.java 1202228

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java 1202228

        Diff: https://reviews.apache.org/r/2832/diff

        Testing

        -------

        See PrefetchBehaviourTest#testConnectionStop for more details.

        Thanks,

        rajith

        Show
        jiraposter@reviews.apache.org added a comment - ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/2832/#review3294 ----------------------------------------------------------- http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java < https://reviews.apache.org/r/2832/#comment7376 > Could this make use of AMQSession#rejectMessage? I wonder also if this logic sit better in AMQSession#notifyConsumer(). It already rejects messages if the consumer is closed. Could it not also reject messages if the connection is no longer started? http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/prefetch/PrefetchBehaviourTest.java < https://reviews.apache.org/r/2832/#comment7374 > Could you not use the test utility method for the production of these messages? QpidBrokerTestCase#sendMessage http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/prefetch/PrefetchBehaviourTest.java < https://reviews.apache.org/r/2832/#comment7375 > I think using a timeout here would be preferable. IMHO we should avoid writing unit tests that can hang indefinitely in favour of those that will always fail with a useful assertion-fail. Also typo in assertion message (once -> one). http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/prefetch/PrefetchBehaviourTest.java < https://reviews.apache.org/r/2832/#comment7377 > You've got a couple of whitespace issues that make the patch slightly larger than need be Keith On 2011-11-15 15:36:36, rajith attapattu wrote: ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/2832/ ----------------------------------------------------------- (Updated 2011-11-15 15:36:36) Review request for qpid, Gordon Sim, Robbie Gemmell, Weston Price, and Oleksandr Rudyy. Summary ------- This attempts to fix one of the issues related to the handling of Message credits. See QPID-3602 for an overall picture of the various issues. This particular patch does the following. 1. When the connection is stopped, it sends message.stop() & releases all messages in the prefetch buffer. 2. It will also release any messages (that were in flight) that comes after the connection is stopped. This interferes with the immediate_prefetch feature. However I don't know if immediate prefetch is really required in the 0-10 path. As always comments, suggestions & criticisms are equally welcomed. This addresses bug QPID-3604 . https://issues.apache.org/jira/browse/QPID-3604 Diffs ----- http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java 1202228 http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java 1202228 http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/prefetch/PrefetchBehaviourTest.java 1202228 http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java 1202228 Diff: https://reviews.apache.org/r/2832/diff Testing ------- See PrefetchBehaviourTest#testConnectionStop for more details. Thanks, rajith
        Hide
        jiraposter@reviews.apache.org added a comment -

        On 2011-11-15 16:41:28, Gordon Sim wrote:

        > http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java, line 787

        > <https://reviews.apache.org/r/2832/diff/1/?file=58392#file58392line787>

        >

        > Are there any other locks acquired as part of the block here? If so are there any lock ordering issues where you could be introducing a deadlock?

        rajith attapattu wrote:

        Not that I could think of. The message-delivery-lock is taken to ensure that no messages are being served while we start pulling them out of the queue.

        In my tests so far, I haven't encountered any issues. However I plan to have more manual tests - ex. Trying to stop the connection while the message consumers are in full flight.

        Gordon Sim wrote:

        What about the failover mutex? Could the release trigger a codepath that attempts to acquire that? What about an asynchronous exception occurring concurrently; would that ever need to acquire the message-delivery-lock?

        rajith attapattu wrote:

        Certainly possible as mentioned in the comment below. The failover and the synchronous exceptions are things that could trigger a deadlock.

        Testing is the best way to eliminate these possibilities. However IMO acquiring the message-delivery-lock is a must to ensure unwanted interaction between messages delivery & releasing.

        Testing is certainly vital, however with threading issues a thorough analysis is as well given the non-deterministic nature of potential problems.

        • Gordon

        -----------------------------------------------------------
        This is an automatically generated e-mail. To reply, visit:
        https://reviews.apache.org/r/2832/#review3264
        -----------------------------------------------------------

        On 2011-11-15 15:36:36, rajith attapattu wrote:

        -----------------------------------------------------------

        This is an automatically generated e-mail. To reply, visit:

        https://reviews.apache.org/r/2832/

        -----------------------------------------------------------

        (Updated 2011-11-15 15:36:36)

        Review request for qpid, Gordon Sim, Robbie Gemmell, Weston Price, and Oleksandr Rudyy.

        Summary

        -------

        This attempts to fix one of the issues related to the handling of Message credits. See QPID-3602 for an overall picture of the various issues.

        This particular patch does the following.

        1. When the connection is stopped, it sends message.stop() & releases all messages in the prefetch buffer.

        2. It will also release any messages (that were in flight) that comes after the connection is stopped.

        This interferes with the immediate_prefetch feature. However I don't know if immediate prefetch is really required in the 0-10 path.

        As always comments, suggestions & criticisms are equally welcomed.

        This addresses bug QPID-3604.

        https://issues.apache.org/jira/browse/QPID-3604

        Diffs

        -----

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java 1202228

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java 1202228

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/prefetch/PrefetchBehaviourTest.java 1202228

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java 1202228

        Diff: https://reviews.apache.org/r/2832/diff

        Testing

        -------

        See PrefetchBehaviourTest#testConnectionStop for more details.

        Thanks,

        rajith

        Show
        jiraposter@reviews.apache.org added a comment - On 2011-11-15 16:41:28, Gordon Sim wrote: > http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java , line 787 > < https://reviews.apache.org/r/2832/diff/1/?file=58392#file58392line787 > > > Are there any other locks acquired as part of the block here? If so are there any lock ordering issues where you could be introducing a deadlock? rajith attapattu wrote: Not that I could think of. The message-delivery-lock is taken to ensure that no messages are being served while we start pulling them out of the queue. In my tests so far, I haven't encountered any issues. However I plan to have more manual tests - ex. Trying to stop the connection while the message consumers are in full flight. Gordon Sim wrote: What about the failover mutex? Could the release trigger a codepath that attempts to acquire that? What about an asynchronous exception occurring concurrently; would that ever need to acquire the message-delivery-lock? rajith attapattu wrote: Certainly possible as mentioned in the comment below. The failover and the synchronous exceptions are things that could trigger a deadlock. Testing is the best way to eliminate these possibilities. However IMO acquiring the message-delivery-lock is a must to ensure unwanted interaction between messages delivery & releasing. Testing is certainly vital, however with threading issues a thorough analysis is as well given the non-deterministic nature of potential problems. Gordon ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/2832/#review3264 ----------------------------------------------------------- On 2011-11-15 15:36:36, rajith attapattu wrote: ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/2832/ ----------------------------------------------------------- (Updated 2011-11-15 15:36:36) Review request for qpid, Gordon Sim, Robbie Gemmell, Weston Price, and Oleksandr Rudyy. Summary ------- This attempts to fix one of the issues related to the handling of Message credits. See QPID-3602 for an overall picture of the various issues. This particular patch does the following. 1. When the connection is stopped, it sends message.stop() & releases all messages in the prefetch buffer. 2. It will also release any messages (that were in flight) that comes after the connection is stopped. This interferes with the immediate_prefetch feature. However I don't know if immediate prefetch is really required in the 0-10 path. As always comments, suggestions & criticisms are equally welcomed. This addresses bug QPID-3604 . https://issues.apache.org/jira/browse/QPID-3604 Diffs ----- http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java 1202228 http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java 1202228 http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/prefetch/PrefetchBehaviourTest.java 1202228 http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java 1202228 Diff: https://reviews.apache.org/r/2832/diff Testing ------- See PrefetchBehaviourTest#testConnectionStop for more details. Thanks, rajith
        Hide
        jiraposter@reviews.apache.org added a comment -

        On 2011-11-15 16:41:28, Gordon Sim wrote:

        > http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java, line 787

        > <https://reviews.apache.org/r/2832/diff/1/?file=58392#file58392line787>

        >

        > Are there any other locks acquired as part of the block here? If so are there any lock ordering issues where you could be introducing a deadlock?

        rajith attapattu wrote:

        Not that I could think of. The message-delivery-lock is taken to ensure that no messages are being served while we start pulling them out of the queue.

        In my tests so far, I haven't encountered any issues. However I plan to have more manual tests - ex. Trying to stop the connection while the message consumers are in full flight.

        Gordon Sim wrote:

        What about the failover mutex? Could the release trigger a codepath that attempts to acquire that? What about an asynchronous exception occurring concurrently; would that ever need to acquire the message-delivery-lock?

        Certainly possible as mentioned in the comment below. The failover and the synchronous exceptions are things that could trigger a deadlock.
        Testing is the best way to eliminate these possibilities. However IMO acquiring the message-delivery-lock is a must to ensure unwanted interaction between messages delivery & releasing.

        On 2011-11-15 16:41:28, Gordon Sim wrote:

        > http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java, line 796

        > <https://reviews.apache.org/r/2832/diff/1/?file=58392#file58392line796>

        >

        > You are syncing here while holding the delivery lock, could that cause any problems?

        rajith attapattu wrote:

        So far I haven't encountered any issues. However things like failover, session exceptions etc..could cause issues. I'm planning more thorough longer running tests.

        Another thing I am considering is to not use a sync() at all. I'm not quite convinced that it's of much value here.

        I've noticed that the client continues to get messages into it's queue even after the code returns from the sync call. Hence the code snippet to release any messages received after the connection is stopped. I was expecting the brokers response to the sync command to be received after the client has got all the messages that were in flight. So after I sync I could just release the messages in the queue and be done with it. But that's not the case.

        It seems that the dispatcher thread takes a bit of time to process the UnprocessedMessages into the correct JMSMessages and put them onto the queue. So the sync() really doesn't add much value here.

        Gordon Sim wrote:

        It sounds like it is necessary but not sufficient. You need to know that the stop has been processed by the broker and it will not send any further, but you also need to synchronise with the thread actually processing incoming messages.

        I looked at it the other way . Since it's not sufficient, it's not necessary. All though it sounds wrong, not having the sync doesn't influence the outcome of the patch at all (Bcos we release any messages we receive after the connection is stopped).

        It's not ideal, but with the absence of a proper mechanism to synchronize with the message processing dispatcher thread this seems a reasonable approach.

        Another reason why I shied away from attempting that was due to the nasty interactions we may have with threading. The dispatcher thread does use the message delivery lock and that route could increase the potential for a deadlock.

        On 2011-11-15 16:41:28, Gordon Sim wrote:

        > http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java, line 126

        > <https://reviews.apache.org/r/2832/diff/1/?file=58393#file58393line126>

        >

        > What case(s) is this code required for? You are releasing a message you have just received, right? When is that required?

        rajith attapattu wrote:

        See the above for an explanation for why this is needed.

        Gordon Sim wrote:

        You mean this is here because of the lack of synchronization with the dispatcher thread? If so that seems a little nasty to me... anyway to do this more cleanly?

        That is precisely the reason. This also makes the sync call redundant. I started with the sync() and realized that it wasn't sufficient, hence added this.
        As explained above, I'm not sure if there is a reasonable way to synchronize with the message delivery thread.

        One possible approach might be is to do something like the syncDispatchQueue() method. Where we push a certain marker message into the queue and then we get that we know there are no more messages in the pipeline. But I'm concerned about the safety and feasibility of such an approach.

        Robbie I believe is one person who have looked at this code more extensively in the last little while. So waiting to hear from him about his ideas as well. I'm open to suggestions on this area. Lets see if we can collectively figure out a better solution.

        • rajith

        -----------------------------------------------------------
        This is an automatically generated e-mail. To reply, visit:
        https://reviews.apache.org/r/2832/#review3264
        -----------------------------------------------------------

        On 2011-11-15 15:36:36, rajith attapattu wrote:

        -----------------------------------------------------------

        This is an automatically generated e-mail. To reply, visit:

        https://reviews.apache.org/r/2832/

        -----------------------------------------------------------

        (Updated 2011-11-15 15:36:36)

        Review request for qpid, Gordon Sim, Robbie Gemmell, Weston Price, and Oleksandr Rudyy.

        Summary

        -------

        This attempts to fix one of the issues related to the handling of Message credits. See QPID-3602 for an overall picture of the various issues.

        This particular patch does the following.

        1. When the connection is stopped, it sends message.stop() & releases all messages in the prefetch buffer.

        2. It will also release any messages (that were in flight) that comes after the connection is stopped.

        This interferes with the immediate_prefetch feature. However I don't know if immediate prefetch is really required in the 0-10 path.

        As always comments, suggestions & criticisms are equally welcomed.

        This addresses bug QPID-3604.

        https://issues.apache.org/jira/browse/QPID-3604

        Diffs

        -----

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java 1202228

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java 1202228

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/prefetch/PrefetchBehaviourTest.java 1202228

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java 1202228

        Diff: https://reviews.apache.org/r/2832/diff

        Testing

        -------

        See PrefetchBehaviourTest#testConnectionStop for more details.

        Thanks,

        rajith

        Show
        jiraposter@reviews.apache.org added a comment - On 2011-11-15 16:41:28, Gordon Sim wrote: > http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java , line 787 > < https://reviews.apache.org/r/2832/diff/1/?file=58392#file58392line787 > > > Are there any other locks acquired as part of the block here? If so are there any lock ordering issues where you could be introducing a deadlock? rajith attapattu wrote: Not that I could think of. The message-delivery-lock is taken to ensure that no messages are being served while we start pulling them out of the queue. In my tests so far, I haven't encountered any issues. However I plan to have more manual tests - ex. Trying to stop the connection while the message consumers are in full flight. Gordon Sim wrote: What about the failover mutex? Could the release trigger a codepath that attempts to acquire that? What about an asynchronous exception occurring concurrently; would that ever need to acquire the message-delivery-lock? Certainly possible as mentioned in the comment below. The failover and the synchronous exceptions are things that could trigger a deadlock. Testing is the best way to eliminate these possibilities. However IMO acquiring the message-delivery-lock is a must to ensure unwanted interaction between messages delivery & releasing. On 2011-11-15 16:41:28, Gordon Sim wrote: > http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java , line 796 > < https://reviews.apache.org/r/2832/diff/1/?file=58392#file58392line796 > > > You are syncing here while holding the delivery lock, could that cause any problems? rajith attapattu wrote: So far I haven't encountered any issues. However things like failover, session exceptions etc..could cause issues. I'm planning more thorough longer running tests. Another thing I am considering is to not use a sync() at all. I'm not quite convinced that it's of much value here. I've noticed that the client continues to get messages into it's queue even after the code returns from the sync call. Hence the code snippet to release any messages received after the connection is stopped. I was expecting the brokers response to the sync command to be received after the client has got all the messages that were in flight. So after I sync I could just release the messages in the queue and be done with it. But that's not the case. It seems that the dispatcher thread takes a bit of time to process the UnprocessedMessages into the correct JMSMessages and put them onto the queue. So the sync() really doesn't add much value here. Gordon Sim wrote: It sounds like it is necessary but not sufficient. You need to know that the stop has been processed by the broker and it will not send any further, but you also need to synchronise with the thread actually processing incoming messages . I looked at it the other way . Since it's not sufficient, it's not necessary. All though it sounds wrong, not having the sync doesn't influence the outcome of the patch at all (Bcos we release any messages we receive after the connection is stopped). It's not ideal, but with the absence of a proper mechanism to synchronize with the message processing dispatcher thread this seems a reasonable approach. Another reason why I shied away from attempting that was due to the nasty interactions we may have with threading. The dispatcher thread does use the message delivery lock and that route could increase the potential for a deadlock. On 2011-11-15 16:41:28, Gordon Sim wrote: > http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java , line 126 > < https://reviews.apache.org/r/2832/diff/1/?file=58393#file58393line126 > > > What case(s) is this code required for? You are releasing a message you have just received, right? When is that required? rajith attapattu wrote: See the above for an explanation for why this is needed. Gordon Sim wrote: You mean this is here because of the lack of synchronization with the dispatcher thread? If so that seems a little nasty to me... anyway to do this more cleanly? That is precisely the reason. This also makes the sync call redundant. I started with the sync() and realized that it wasn't sufficient, hence added this. As explained above, I'm not sure if there is a reasonable way to synchronize with the message delivery thread. One possible approach might be is to do something like the syncDispatchQueue() method. Where we push a certain marker message into the queue and then we get that we know there are no more messages in the pipeline. But I'm concerned about the safety and feasibility of such an approach. Robbie I believe is one person who have looked at this code more extensively in the last little while. So waiting to hear from him about his ideas as well. I'm open to suggestions on this area. Lets see if we can collectively figure out a better solution. rajith ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/2832/#review3264 ----------------------------------------------------------- On 2011-11-15 15:36:36, rajith attapattu wrote: ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/2832/ ----------------------------------------------------------- (Updated 2011-11-15 15:36:36) Review request for qpid, Gordon Sim, Robbie Gemmell, Weston Price, and Oleksandr Rudyy. Summary ------- This attempts to fix one of the issues related to the handling of Message credits. See QPID-3602 for an overall picture of the various issues. This particular patch does the following. 1. When the connection is stopped, it sends message.stop() & releases all messages in the prefetch buffer. 2. It will also release any messages (that were in flight) that comes after the connection is stopped. This interferes with the immediate_prefetch feature. However I don't know if immediate prefetch is really required in the 0-10 path. As always comments, suggestions & criticisms are equally welcomed. This addresses bug QPID-3604 . https://issues.apache.org/jira/browse/QPID-3604 Diffs ----- http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java 1202228 http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java 1202228 http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/prefetch/PrefetchBehaviourTest.java 1202228 http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java 1202228 Diff: https://reviews.apache.org/r/2832/diff Testing ------- See PrefetchBehaviourTest#testConnectionStop for more details. Thanks, rajith
        Hide
        jiraposter@reviews.apache.org added a comment -

        On 2011-11-15 16:41:28, Gordon Sim wrote:

        > http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java, line 796

        > <https://reviews.apache.org/r/2832/diff/1/?file=58392#file58392line796>

        >

        > You are syncing here while holding the delivery lock, could that cause any problems?

        rajith attapattu wrote:

        So far I haven't encountered any issues. However things like failover, session exceptions etc..could cause issues. I'm planning more thorough longer running tests.

        Another thing I am considering is to not use a sync() at all. I'm not quite convinced that it's of much value here.

        I've noticed that the client continues to get messages into it's queue even after the code returns from the sync call. Hence the code snippet to release any messages received after the connection is stopped. I was expecting the brokers response to the sync command to be received after the client has got all the messages that were in flight. So after I sync I could just release the messages in the queue and be done with it. But that's not the case.

        It seems that the dispatcher thread takes a bit of time to process the UnprocessedMessages into the correct JMSMessages and put them onto the queue. So the sync() really doesn't add much value here.

        It sounds like it is necessary but not sufficient. You need to know that the stop has been processed by the broker and it will not send any further, but you also need to synchronise with the thread actually processing incoming messages.

        On 2011-11-15 16:41:28, Gordon Sim wrote:

        > http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java, line 126

        > <https://reviews.apache.org/r/2832/diff/1/?file=58393#file58393line126>

        >

        > What case(s) is this code required for? You are releasing a message you have just received, right? When is that required?

        rajith attapattu wrote:

        See the above for an explanation for why this is needed.

        You mean this is here because of the lack of synchronization with the dispatcher thread? If so that seems a little nasty to me... anyway to do this more cleanly?

        On 2011-11-15 16:41:28, Gordon Sim wrote:

        > http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java, line 787

        > <https://reviews.apache.org/r/2832/diff/1/?file=58392#file58392line787>

        >

        > Are there any other locks acquired as part of the block here? If so are there any lock ordering issues where you could be introducing a deadlock?

        rajith attapattu wrote:

        Not that I could think of. The message-delivery-lock is taken to ensure that no messages are being served while we start pulling them out of the queue.

        In my tests so far, I haven't encountered any issues. However I plan to have more manual tests - ex. Trying to stop the connection while the message consumers are in full flight.

        What about the failover mutex? Could the release trigger a codepath that attempts to acquire that? What about an asynchronous exception occurring concurrently; would that ever need to acquire the message-delivery-lock?

        • Gordon

        -----------------------------------------------------------
        This is an automatically generated e-mail. To reply, visit:
        https://reviews.apache.org/r/2832/#review3264
        -----------------------------------------------------------

        On 2011-11-15 15:36:36, rajith attapattu wrote:

        -----------------------------------------------------------

        This is an automatically generated e-mail. To reply, visit:

        https://reviews.apache.org/r/2832/

        -----------------------------------------------------------

        (Updated 2011-11-15 15:36:36)

        Review request for qpid, Gordon Sim, Robbie Gemmell, Weston Price, and Oleksandr Rudyy.

        Summary

        -------

        This attempts to fix one of the issues related to the handling of Message credits. See QPID-3602 for an overall picture of the various issues.

        This particular patch does the following.

        1. When the connection is stopped, it sends message.stop() & releases all messages in the prefetch buffer.

        2. It will also release any messages (that were in flight) that comes after the connection is stopped.

        This interferes with the immediate_prefetch feature. However I don't know if immediate prefetch is really required in the 0-10 path.

        As always comments, suggestions & criticisms are equally welcomed.

        This addresses bug QPID-3604.

        https://issues.apache.org/jira/browse/QPID-3604

        Diffs

        -----

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java 1202228

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java 1202228

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/prefetch/PrefetchBehaviourTest.java 1202228

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java 1202228

        Diff: https://reviews.apache.org/r/2832/diff

        Testing

        -------

        See PrefetchBehaviourTest#testConnectionStop for more details.

        Thanks,

        rajith

        Show
        jiraposter@reviews.apache.org added a comment - On 2011-11-15 16:41:28, Gordon Sim wrote: > http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java , line 796 > < https://reviews.apache.org/r/2832/diff/1/?file=58392#file58392line796 > > > You are syncing here while holding the delivery lock, could that cause any problems? rajith attapattu wrote: So far I haven't encountered any issues. However things like failover, session exceptions etc..could cause issues. I'm planning more thorough longer running tests. Another thing I am considering is to not use a sync() at all. I'm not quite convinced that it's of much value here. I've noticed that the client continues to get messages into it's queue even after the code returns from the sync call. Hence the code snippet to release any messages received after the connection is stopped. I was expecting the brokers response to the sync command to be received after the client has got all the messages that were in flight. So after I sync I could just release the messages in the queue and be done with it. But that's not the case. It seems that the dispatcher thread takes a bit of time to process the UnprocessedMessages into the correct JMSMessages and put them onto the queue. So the sync() really doesn't add much value here. It sounds like it is necessary but not sufficient. You need to know that the stop has been processed by the broker and it will not send any further, but you also need to synchronise with the thread actually processing incoming messages . On 2011-11-15 16:41:28, Gordon Sim wrote: > http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java , line 126 > < https://reviews.apache.org/r/2832/diff/1/?file=58393#file58393line126 > > > What case(s) is this code required for? You are releasing a message you have just received, right? When is that required? rajith attapattu wrote: See the above for an explanation for why this is needed. You mean this is here because of the lack of synchronization with the dispatcher thread? If so that seems a little nasty to me... anyway to do this more cleanly? On 2011-11-15 16:41:28, Gordon Sim wrote: > http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java , line 787 > < https://reviews.apache.org/r/2832/diff/1/?file=58392#file58392line787 > > > Are there any other locks acquired as part of the block here? If so are there any lock ordering issues where you could be introducing a deadlock? rajith attapattu wrote: Not that I could think of. The message-delivery-lock is taken to ensure that no messages are being served while we start pulling them out of the queue. In my tests so far, I haven't encountered any issues. However I plan to have more manual tests - ex. Trying to stop the connection while the message consumers are in full flight. What about the failover mutex? Could the release trigger a codepath that attempts to acquire that? What about an asynchronous exception occurring concurrently; would that ever need to acquire the message-delivery-lock? Gordon ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/2832/#review3264 ----------------------------------------------------------- On 2011-11-15 15:36:36, rajith attapattu wrote: ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/2832/ ----------------------------------------------------------- (Updated 2011-11-15 15:36:36) Review request for qpid, Gordon Sim, Robbie Gemmell, Weston Price, and Oleksandr Rudyy. Summary ------- This attempts to fix one of the issues related to the handling of Message credits. See QPID-3602 for an overall picture of the various issues. This particular patch does the following. 1. When the connection is stopped, it sends message.stop() & releases all messages in the prefetch buffer. 2. It will also release any messages (that were in flight) that comes after the connection is stopped. This interferes with the immediate_prefetch feature. However I don't know if immediate prefetch is really required in the 0-10 path. As always comments, suggestions & criticisms are equally welcomed. This addresses bug QPID-3604 . https://issues.apache.org/jira/browse/QPID-3604 Diffs ----- http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java 1202228 http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java 1202228 http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/prefetch/PrefetchBehaviourTest.java 1202228 http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java 1202228 Diff: https://reviews.apache.org/r/2832/diff Testing ------- See PrefetchBehaviourTest#testConnectionStop for more details. Thanks, rajith
        Hide
        jiraposter@reviews.apache.org added a comment -

        On 2011-11-15 16:41:28, Gordon Sim wrote:

        > I don't have a clear enough mental picture of the code you are modifying, so am really only able to ask some questions...

        Thanks a lot for taking the time to review. I really appreciate it.

        On 2011-11-15 16:41:28, Gordon Sim wrote:

        > http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java, line 787

        > <https://reviews.apache.org/r/2832/diff/1/?file=58392#file58392line787>

        >

        > Are there any other locks acquired as part of the block here? If so are there any lock ordering issues where you could be introducing a deadlock?

        Not that I could think of. The message-delivery-lock is taken to ensure that no messages are being served while we start pulling them out of the queue.
        In my tests so far, I haven't encountered any issues. However I plan to have more manual tests - ex. Trying to stop the connection while the message consumers are in full flight.

        On 2011-11-15 16:41:28, Gordon Sim wrote:

        > http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java, line 796

        > <https://reviews.apache.org/r/2832/diff/1/?file=58392#file58392line796>

        >

        > You are syncing here while holding the delivery lock, could that cause any problems?

        So far I haven't encountered any issues. However things like failover, session exceptions etc..could cause issues. I'm planning more thorough longer running tests.
        Another thing I am considering is to not use a sync() at all. I'm not quite convinced that it's of much value here.

        I've noticed that the client continues to get messages into it's queue even after the code returns from the sync call. Hence the code snippet to release any messages received after the connection is stopped. I was expecting the brokers response to the sync command to be received after the client has got all the messages that were in flight. So after I sync I could just release the messages in the queue and be done with it. But that's not the case.

        It seems that the dispatcher thread takes a bit of time to process the UnprocessedMessages into the correct JMSMessages and put them onto the queue. So the sync() really doesn't add much value here.

        On 2011-11-15 16:41:28, Gordon Sim wrote:

        > http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java, line 126

        > <https://reviews.apache.org/r/2832/diff/1/?file=58393#file58393line126>

        >

        > What case(s) is this code required for? You are releasing a message you have just received, right? When is that required?

        See the above for an explanation for why this is needed.

        • rajith

        -----------------------------------------------------------
        This is an automatically generated e-mail. To reply, visit:
        https://reviews.apache.org/r/2832/#review3264
        -----------------------------------------------------------

        On 2011-11-15 15:36:36, rajith attapattu wrote:

        -----------------------------------------------------------

        This is an automatically generated e-mail. To reply, visit:

        https://reviews.apache.org/r/2832/

        -----------------------------------------------------------

        (Updated 2011-11-15 15:36:36)

        Review request for qpid, Gordon Sim, Robbie Gemmell, Weston Price, and Oleksandr Rudyy.

        Summary

        -------

        This attempts to fix one of the issues related to the handling of Message credits. See QPID-3602 for an overall picture of the various issues.

        This particular patch does the following.

        1. When the connection is stopped, it sends message.stop() & releases all messages in the prefetch buffer.

        2. It will also release any messages (that were in flight) that comes after the connection is stopped.

        This interferes with the immediate_prefetch feature. However I don't know if immediate prefetch is really required in the 0-10 path.

        As always comments, suggestions & criticisms are equally welcomed.

        This addresses bug QPID-3604.

        https://issues.apache.org/jira/browse/QPID-3604

        Diffs

        -----

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java 1202228

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java 1202228

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/prefetch/PrefetchBehaviourTest.java 1202228

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java 1202228

        Diff: https://reviews.apache.org/r/2832/diff

        Testing

        -------

        See PrefetchBehaviourTest#testConnectionStop for more details.

        Thanks,

        rajith

        Show
        jiraposter@reviews.apache.org added a comment - On 2011-11-15 16:41:28, Gordon Sim wrote: > I don't have a clear enough mental picture of the code you are modifying, so am really only able to ask some questions... Thanks a lot for taking the time to review. I really appreciate it. On 2011-11-15 16:41:28, Gordon Sim wrote: > http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java , line 787 > < https://reviews.apache.org/r/2832/diff/1/?file=58392#file58392line787 > > > Are there any other locks acquired as part of the block here? If so are there any lock ordering issues where you could be introducing a deadlock? Not that I could think of. The message-delivery-lock is taken to ensure that no messages are being served while we start pulling them out of the queue. In my tests so far, I haven't encountered any issues. However I plan to have more manual tests - ex. Trying to stop the connection while the message consumers are in full flight. On 2011-11-15 16:41:28, Gordon Sim wrote: > http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java , line 796 > < https://reviews.apache.org/r/2832/diff/1/?file=58392#file58392line796 > > > You are syncing here while holding the delivery lock, could that cause any problems? So far I haven't encountered any issues. However things like failover, session exceptions etc..could cause issues. I'm planning more thorough longer running tests. Another thing I am considering is to not use a sync() at all. I'm not quite convinced that it's of much value here. I've noticed that the client continues to get messages into it's queue even after the code returns from the sync call. Hence the code snippet to release any messages received after the connection is stopped. I was expecting the brokers response to the sync command to be received after the client has got all the messages that were in flight. So after I sync I could just release the messages in the queue and be done with it. But that's not the case. It seems that the dispatcher thread takes a bit of time to process the UnprocessedMessages into the correct JMSMessages and put them onto the queue. So the sync() really doesn't add much value here. On 2011-11-15 16:41:28, Gordon Sim wrote: > http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java , line 126 > < https://reviews.apache.org/r/2832/diff/1/?file=58393#file58393line126 > > > What case(s) is this code required for? You are releasing a message you have just received, right? When is that required? See the above for an explanation for why this is needed. rajith ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/2832/#review3264 ----------------------------------------------------------- On 2011-11-15 15:36:36, rajith attapattu wrote: ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/2832/ ----------------------------------------------------------- (Updated 2011-11-15 15:36:36) Review request for qpid, Gordon Sim, Robbie Gemmell, Weston Price, and Oleksandr Rudyy. Summary ------- This attempts to fix one of the issues related to the handling of Message credits. See QPID-3602 for an overall picture of the various issues. This particular patch does the following. 1. When the connection is stopped, it sends message.stop() & releases all messages in the prefetch buffer. 2. It will also release any messages (that were in flight) that comes after the connection is stopped. This interferes with the immediate_prefetch feature. However I don't know if immediate prefetch is really required in the 0-10 path. As always comments, suggestions & criticisms are equally welcomed. This addresses bug QPID-3604 . https://issues.apache.org/jira/browse/QPID-3604 Diffs ----- http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java 1202228 http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java 1202228 http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/prefetch/PrefetchBehaviourTest.java 1202228 http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java 1202228 Diff: https://reviews.apache.org/r/2832/diff Testing ------- See PrefetchBehaviourTest#testConnectionStop for more details. Thanks, rajith
        Hide
        jiraposter@reviews.apache.org added a comment -

        -----------------------------------------------------------
        This is an automatically generated e-mail. To reply, visit:
        https://reviews.apache.org/r/2832/#review3264
        -----------------------------------------------------------

        I don't have a clear enough mental picture of the code you are modifying, so am really only able to ask some questions...

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java
        <https://reviews.apache.org/r/2832/#comment7291>

        Are there any other locks acquired as part of the block here? If so are there any lock ordering issues where you could be introducing a deadlock?

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java
        <https://reviews.apache.org/r/2832/#comment7292>

        You are syncing here while holding the delivery lock, could that cause any problems?

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java
        <https://reviews.apache.org/r/2832/#comment7293>

        What case(s) is this code required for? You are releasing a message you have just received, right? When is that required?

        • Gordon

        On 2011-11-15 15:36:36, rajith attapattu wrote:

        -----------------------------------------------------------

        This is an automatically generated e-mail. To reply, visit:

        https://reviews.apache.org/r/2832/

        -----------------------------------------------------------

        (Updated 2011-11-15 15:36:36)

        Review request for qpid, Gordon Sim, Robbie Gemmell, Weston Price, and Oleksandr Rudyy.

        Summary

        -------

        This attempts to fix one of the issues related to the handling of Message credits. See QPID-3602 for an overall picture of the various issues.

        This particular patch does the following.

        1. When the connection is stopped, it sends message.stop() & releases all messages in the prefetch buffer.

        2. It will also release any messages (that were in flight) that comes after the connection is stopped.

        This interferes with the immediate_prefetch feature. However I don't know if immediate prefetch is really required in the 0-10 path.

        As always comments, suggestions & criticisms are equally welcomed.

        This addresses bug QPID-3604.

        https://issues.apache.org/jira/browse/QPID-3604

        Diffs

        -----

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java 1202228

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java 1202228

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/prefetch/PrefetchBehaviourTest.java 1202228

        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java 1202228

        Diff: https://reviews.apache.org/r/2832/diff

        Testing

        -------

        See PrefetchBehaviourTest#testConnectionStop for more details.

        Thanks,

        rajith

        Show
        jiraposter@reviews.apache.org added a comment - ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/2832/#review3264 ----------------------------------------------------------- I don't have a clear enough mental picture of the code you are modifying, so am really only able to ask some questions... http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java < https://reviews.apache.org/r/2832/#comment7291 > Are there any other locks acquired as part of the block here? If so are there any lock ordering issues where you could be introducing a deadlock? http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java < https://reviews.apache.org/r/2832/#comment7292 > You are syncing here while holding the delivery lock, could that cause any problems? http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java < https://reviews.apache.org/r/2832/#comment7293 > What case(s) is this code required for? You are releasing a message you have just received, right? When is that required? Gordon On 2011-11-15 15:36:36, rajith attapattu wrote: ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/2832/ ----------------------------------------------------------- (Updated 2011-11-15 15:36:36) Review request for qpid, Gordon Sim, Robbie Gemmell, Weston Price, and Oleksandr Rudyy. Summary ------- This attempts to fix one of the issues related to the handling of Message credits. See QPID-3602 for an overall picture of the various issues. This particular patch does the following. 1. When the connection is stopped, it sends message.stop() & releases all messages in the prefetch buffer. 2. It will also release any messages (that were in flight) that comes after the connection is stopped. This interferes with the immediate_prefetch feature. However I don't know if immediate prefetch is really required in the 0-10 path. As always comments, suggestions & criticisms are equally welcomed. This addresses bug QPID-3604 . https://issues.apache.org/jira/browse/QPID-3604 Diffs ----- http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java 1202228 http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java 1202228 http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/prefetch/PrefetchBehaviourTest.java 1202228 http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java 1202228 Diff: https://reviews.apache.org/r/2832/diff Testing ------- See PrefetchBehaviourTest#testConnectionStop for more details. Thanks, rajith
        Hide
        jiraposter@reviews.apache.org added a comment -

        -----------------------------------------------------------
        This is an automatically generated e-mail. To reply, visit:
        https://reviews.apache.org/r/2832/
        -----------------------------------------------------------

        Review request for qpid, Gordon Sim, Robbie Gemmell, Weston Price, and Oleksandr Rudyy.

        Summary
        -------

        This attempts to fix one of the issues related to the handling of Message credits. See QPID-3602 for an overall picture of the various issues.

        This particular patch does the following.
        1. When the connection is stopped, it sends message.stop() & releases all messages in the prefetch buffer.
        2. It will also release any messages (that were in flight) that comes after the connection is stopped.

        This interferes with the immediate_prefetch feature. However I don't know if immediate prefetch is really required in the 0-10 path.

        As always comments, suggestions & criticisms are equally welcomed.

        This addresses bug QPID-3604.
        https://issues.apache.org/jira/browse/QPID-3604

        Diffs


        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java 1202228
        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java 1202228
        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/prefetch/PrefetchBehaviourTest.java 1202228
        http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java 1202228

        Diff: https://reviews.apache.org/r/2832/diff

        Testing
        -------

        See PrefetchBehaviourTest#testConnectionStop for more details.

        Thanks,

        rajith

        Show
        jiraposter@reviews.apache.org added a comment - ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/2832/ ----------------------------------------------------------- Review request for qpid, Gordon Sim, Robbie Gemmell, Weston Price, and Oleksandr Rudyy. Summary ------- This attempts to fix one of the issues related to the handling of Message credits. See QPID-3602 for an overall picture of the various issues. This particular patch does the following. 1. When the connection is stopped, it sends message.stop() & releases all messages in the prefetch buffer. 2. It will also release any messages (that were in flight) that comes after the connection is stopped. This interferes with the immediate_prefetch feature. However I don't know if immediate prefetch is really required in the 0-10 path. As always comments, suggestions & criticisms are equally welcomed. This addresses bug QPID-3604 . https://issues.apache.org/jira/browse/QPID-3604 Diffs http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java 1202228 http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java 1202228 http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/prefetch/PrefetchBehaviourTest.java 1202228 http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java 1202228 Diff: https://reviews.apache.org/r/2832/diff Testing ------- See PrefetchBehaviourTest#testConnectionStop for more details. Thanks, rajith
        Rajith Attapattu created issue -

          People

          • Assignee:
            Rajith Attapattu
            Reporter:
            Rajith Attapattu
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development