Uploaded image for project: 'ActiveMQ Classic'
  1. ActiveMQ Classic
  2. AMQ-4561

Deadlock in DemandForwardingBridgeSupport class if ConsumerInfo message has arrived before BrokerInfo message.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Incomplete
    • 5.6.0, 5.7.0
    • None
    • Broker
    • Patch Available

    Description

      To establish a connection a spoke broker sends some special messages to the hub:
      • BrokerInfo
      • ConnectionInfo
      • SessionInfo
      • ProducerInfo
      • ConsumerInfo
      In return hub gsends exactly the same set of messages:
      • BrokerInfo
      • ConnectionInfo
      • SessionInfo
      • ProducerInfo
      • ConsumerInfo

      All messages are sent asynchronously so message order is not guaranteed.

      However BrokerInfo message has to be delivered BEFORE ConsumerInfo message to the spoke broker because:
      1. ConsumerInfo processing logic is depended on some information provided in BrokerInfo message so spoke broker side has lock on it.
      2. All incoming messages are processed in the same thread including reading from tcp/nio stream.
      Short excerpt from DemandForwardingBridgeSupport class:
      private void startLocalBridge() throws Throwable

      {  BrokerInfo message processing ….. localStartedLatch.countDown(); }

      And ConsumerInfo message processing part has the lock:
      case ConsumerInfo.DATA_STRUCTURE_TYPE:
      localStartedLatch.await();
      So if ConsumerInfo message has been received before BrokerInfo message the consuming thread will be in dead lock:
      Name: ActiveMQ NIO Worker 13
      State: WAITING on java.util.concurrent.CountDownLatch$Sync@150b06b
      Total blocked: 1 Total waited: 3
      Stack trace:
      sun.misc.Unsafe.park(Native Method)
      java.util.concurrent.locks.LockSupport.park(LockSupport.java:156)
      java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:811)
      java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:969)
      java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1281)
      java.util.concurrent.CountDownLatch.await(CountDownLatch.java:207)
      org.apache.activemq.network.DemandForwardingBridgeSupport.serviceRemoteCommand(DemandForwardingBridgeSupport.java:534)

      Attachments

        1. patch.diff
          3 kB
          Yuriy Sidelnikov

        Issue Links

          Activity

            People

              Unassigned Unassigned
              sdcf Yuriy Sidelnikov
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: