Deadlock in SimpleAMQQueue
--------------------------

                 Key: QPID-1172
                 URL: https://issues.apache.org/jira/browse/QPID-1172
             Project: Qpid
          Issue Type: Bug
          Components: Java Broker
    Affects Versions: M3
            Reporter: Martin Ritchie
            Priority: Blocker


Summary:

If a QueueBrowser is Closed (BasicCancel) at the same time as the broker 
AutoCloses it then a deadlock can occur between the async delivery and the 
BasicCancel process:


The processQueue() of  the async process takes locks:

subcription.lock
then
SimpleAMQQueue lock

as shown in thread-1

Thread-2 shows that on receipt of BasicCancel it takes:

SimpleAMQQueue lock
then 
subcription.lock

Consolidating the flushSubscriber(sub,long) method with the processQueue() will 
resolve this issues as flushSusbcription releases the sub.lock before trying to 
call unregisterSubscription() which is what is currently causing the deadlock 
in processQueue().


Thread dumps:

Name: pool-1241-thread-1
State: WAITING on [EMAIL PROTECTED] owned by: pool-1241-thread-2
Total blocked: 1,079  Total waited: 6,142

Stack trace: 
sun.misc.Unsafe.park(Native Method)
java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:747)
java.util.concurrent.locks.Name: Thread-62
State: BLOCKED on [EMAIL PROTECTED] owned by: pool-1241-thread-1
Total blocked: 1  Total waited: 0

Stack trace: 
org.apache.qpid.server.queue.SimpleAMQQueue.unregisterSubscription(SimpleAMQQueue.java:287)
org.apache.qpid.server.AMQChannel.unsubscribeAllConsumers(AMQChannel.java:409)
org.apache.qpid.server.AMQChannel.close(AMQChannel.java:368)
org.apache.qpid.server.protocol.AMQMinaProtocolSession.closeAllChannels(AMQMinaProtocolSession.java:597)
org.apache.qpid.server.protocol.AMQMinaProtocolSession.closeSession(AMQMinaProtocolSession.java:619)
org.apache.qpid.server.protocol.AMQMinaProtocolSession.closeConnection(AMQMinaProtocolSession.java:640)
org.apache.qpid.server.connection.ConnectionRegistry.close(ConnectionRegistry.java:56)
org.apache.qpid.server.virtualhost.VirtualHost.close(VirtualHost.java:306)
org.apache.qpid.server.registry.ApplicationRegistry.close(ApplicationRegistry.java:200)
org.apache.qpid.server.registry.ApplicationRegistry.remove(ApplicationRegistry.java:128)
org.apache.qpid.server.registry.ApplicationRegistry.removeAll(ApplicationRegistry.java:148)
org.apache.qpid.server.registry.ApplicationRegistry$ShutdownService.run(ApplicationRegistry.java:83)
java.lang.Thread.run(Thread.java:619)


AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:778)
java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:1114)
java.util.concurrent.locks.ReentrantLock$NonfairSync.lock(ReentrantLock.java:186)
java.util.concurrent.locks.ReentrantLock.lock(ReentrantLock.java:262)
org.apache.qpid.server.subscription.SubscriptionImpl.close(SubscriptionImpl.java:444)
org.apache.qpid.server.queue.SimpleAMQQueue.unregisterSubscription(SimpleAMQQueue.java:298)
   - locked [EMAIL PROTECTED]
org.apache.qpid.server.AMQChannel.unsubscribeConsumer(AMQChannel.java:350)
org.apache.qpid.server.handler.BasicCancelMethodHandler.methodReceived(BasicCancelMethodHandler.java:66)
org.apache.qpid.server.handler.ServerMethodDispatcherImpl.dispatchBasicCancel(ServerMethodDispatcherImpl.java:131)
org.apache.qpid.framing.amqp_0_9.BasicCancelBodyImpl.execute(BasicCancelBodyImpl.java:127)
org.apache.qpid.server.state.AMQStateManager.methodReceived(AMQStateManager.java:204)
org.apache.qpid.server.protocol.AMQMinaProtocolSession.methodFrameReceived(AMQMinaProtocolSession.java:297)
org.apache.qpid.framing.AMQMethodBodyImpl.handle(AMQMethodBodyImpl.java:93)
org.apache.qpid.server.protocol.AMQMinaProtocolSession.frameReceived(AMQMinaProtocolSession.java:239)
org.apache.qpid.server.protocol.AMQMinaProtocolSession.dataBlockReceived(AMQMinaProtocolSession.java:196)
org.apache.qpid.server.protocol.AMQPFastProtocolHandler.messageReceived(AMQPFastProtocolHandler.java:244)
org.apache.mina.common.support.AbstractIoFilterChain$TailFilter.messageReceived(AbstractIoFilterChain.java:703)
org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(AbstractIoFilterChain.java:362)
org.apache.mina.common.support.AbstractIoFilterChain.access$1200(AbstractIoFilterChain.java:54)
org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.messageReceived(AbstractIoFilterChain.java:800)
org.apache.mina.filter.codec.support.SimpleProtocolDecoderOutput.flush(SimpleProtocolDecoderOutput.java:60)
org.apache.mina.filter.codec.QpidProtocolCodecFilter.messageReceived(QpidProtocolCodecFilter.java:174)
org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(AbstractIoFilterChain.java:362)
org.apache.mina.common.support.AbstractIoFilterChain.access$1200(AbstractIoFilterChain.java:54)
org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.messageReceived(AbstractIoFilterChain.java:800)
org.apache.qpid.pool.PoolingFilter.messageReceived(PoolingFilter.java:334)
org.apache.mina.filter.ReferenceCountingIoFilter.messageReceived(ReferenceCountingIoFilter.java:96)
org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(AbstractIoFilterChain.java:362)
org.apache.mina.common.support.AbstractIoFilterChain.access$1200(AbstractIoFilterChain.java:54)
org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.messageReceived(AbstractIoFilterChain.java:800)
org.apache.qpid.pool.Event$ReceivedEvent.process(Event.java:86)
org.apache.qpid.pool.Job.processAll(Job.java:114)
org.apache.qpid.pool.Job.run(Job.java:153)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
java.lang.Thread.run(Thread.java:619)





Name: pool-1241-thread-2
State: BLOCKED on [EMAIL PROTECTED] owned by: pool-1241-thread-1
Total blocked: 874  Total waited: 6,331

Stack trace: 
org.apache.qpid.server.queue.SimpleAMQQueue.unregisterSubscription(SimpleAMQQueue.java:287)
org.apache.qpid.server.queue.SimpleAMQQueue.processQueue(SimpleAMQQueue.java:1480)
org.apache.qpid.server.queue.SimpleAMQQueue.access$100(SimpleAMQQueue.java:51)
org.apache.qpid.server.queue.SimpleAMQQueue$Runner.run(SimpleAMQQueue.java:1176)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
java.lang.Thread.run(Thread.java:619)



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

Reply via email to