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

Message order can be broken for Topic under a high load when topicPrefetch=1 and comsumer is slow

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 5.6.0
    • 5.11.0
    • Transport
    • None

    Description

      For <amq:policyEntry topic=">" producerFlowControl="true" memoryLimit="30mb" topicPrefetch="1" blockedProducerWarningInterval="30">

      Short excerpt from TopicSubscription class:
      public void add(MessageReference node) throws Exception {

      …..
      if (!isFull() && matched.isEmpty() && !isSlave()) {
      // if maximumPendingMessages is set we will only discard messages which
      // have not been dispatched (i.e. we allow the prefetch buffer to be filled)
      dispatch(node); <- Second message will go this way and might be dispatched sooner than first one.
      setSlowConsumer(false);
      } else {
      …….
      if (matched.tryAddMessageLast(node, 10))

      { <- first message will be put in the VMCursor queue and might be dispatched later break; }

      .....
      dispatchMatched(); <- First message won't be dispatched immediately because !isFull() is still false
      }
      Possible scenario as I can see it from logs:
      1. First message has arrived and !isFull() is false because consumer didn't take some previous message yet.
      2. First message will be processed by tryAddMessageLast in VMPendingMessageCursor class and will be dispatched very lately because !isFull() is still false.
      3. Meanwhile consumer reads some previous message and !isFull() will return true.
      4. Second message will be dispatched immediately and might be first to be delivered.
      5. Then first message is dispatched.
      6. Message order is broken.

      Attachments

        1. 4107.diff
          3 kB
          Yuriy Sidelnikov
        2. ActiveMQ-5.9-AMQ-4107.patch
          3 kB
          Alexander Zobkov

        Activity

          People

            gtully Gary Tully
            sdcf Yuriy Sidelnikov
            Votes:
            2 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: