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

Robbie Gemmell commented on QPID-2418:
--------------------------------------

On line 1086 (after patching) this code segment needs updated: 
           if (_subscriptionTopics.containsKey(name) && 
_subscriptionSelectors.containsKey(name))
            {
                if (!_subscriptionTopics.get(name).equals(topic) || 
!_subscriptionSelectors.get(name).equals(messageSelector))
                {
                    _logger.info("Unsubscribing from topic " + topic + " with 
subscription exchange " + name
                                    + " and selector " + messageSelector);
                    unsubscribe(name);
                }
            }

If the subscription name has been seen before but used without a selector, then 
in the outer if statement the first test will success but the second will fail, 
causing the inner if statement to detect subscription change not to be 
evaluated. However, if the new subscription with reused name happens to be 
adding a selector then this should be classified as a selector change (from no 
selector) and cause unsubscription before proceeding.

Also, there is possibility of deadlock when creation of a new durable 
subscriber occurs with the same subscription name as an existing open 
subscriber, which will cause unsubscribe+closure of the old subscriber. The 
create method will hold the new lock added, but closing the subscription will 
contact the broker, which will reply and then a different thread will execute 
the returned BasicCancelOK method and try to aquire the lock in 
deregisterConsumer() in order to complete the closure, causing the first thread 
executing the close to timeout and throw an exception. Looking at the map 
usages it seems there is actually no need to acquire the same lock in 
deregisterConsumer(), only a need to govern access to the subscriptions and 
reverseSubscriptionMaps, which could be achieved using a second lock that 
doesnt encompass the subscriber.close() operation.

>  Existing durable subscription with selector is not unsubscribed during 
> change to new subscription
> --------------------------------------------------------------------------------------------------
>
>                 Key: QPID-2418
>                 URL: https://issues.apache.org/jira/browse/QPID-2418
>             Project: Qpid
>          Issue Type: Bug
>          Components: Java Client
>    Affects Versions: M4, 0.5, 0.6
>            Reporter: Robbie Gemmell
>            Assignee: Robbie Gemmell
>             Fix For: 0.7
>
>         Attachments: 0001-QPID-2418-branch.patch, 0001-QPID-2418-trunk.patch
>
>
> AMQSession.createDurableSubscriber(topic, name, messageSelector, noLocal) 
> does not unsubscribe existing durable subscriptions. Whilst it does check for 
> existing durable subscriptions in use by the client with the same name, it 
> instead simply closes the subscriptions then creates a new one. As a result 
> of not unsubscribing, the queue backing the subscription is not deleted 
> before being used by the updated subscription as it should be (and as happens 
> in the 0_8 and 0_10 subclasses when using durable subscriptions without 
> selectors).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscr...@qpid.apache.org

Reply via email to