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

Topic memory leak on message eviction using UniquePropertyMessageEvictionStrategy

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 5.16.0
    • 5.15.14, 5.16.1, 5.17.0
    • Broker
    • None
    • Patch Available
    • Patch

    Description

      The current implementation of UniquePropertyMessageEvictionStrategy does not conform to the expected behaviour of a MessageEvictionStrategySupport implementation resulting in a memory leak.

      All MessageEvictionStrategySupport implementations remove from the passed list of MessageReference objects the messages that should be evicted and then returns those items in an array. The calling code expects this to be the case and decrements message reference counters accordingly.

      The current implementation of UniquePropertyMessageEvictionStrategy does one of two things depending on the state of the buffered messages:

      1. If the buffer already contains a single message per unique property then the oldest message is returned in the array for message removal but is not removed from the passed message list. This leaves a reference to the message intended for removal in the passed message reference list - not intended behaviour. (i.e. intended behaviour is identical to OldestMessageEvictionStrategy)
      2. If the buffer contains more than one instance of a message with the same unique property then only the latest messages (largest timestamp) for each of those sets are removed from the passed list of message references. At this point, the passed list of message references contains all the messages we expect to be removed so it is converted to an array and returned. But this list should contain all those messages that should be retained - not intended behaviour.

      The patch contains the necessary changes to UniquePropertyMessageEvictionStrategy to prevent this memory leak and an assertion added to the UniquePropertyMessageEvictionStrategyTest.testEviction to demonstrate the memory is correctly freed after applying the fix.

      Attachments

        1. patchfile.txt
          4 kB
          Fraser Crossman

        Activity

          People

            jbonofre Jean-Baptiste Onofré
            fcrossman Fraser Crossman
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 20m
                20m