Description
PagingStoreImpl#checkMemory takes a Runnable argument. It takes steps to ensure that the given Runnable is an org.apache.activemq.artemis.utils.runnables.AtomicRunnable, or wraps it as one, before adding it to the 'onMemoryFreedRunnables' queue for later execution in some cases.
There is a case where it does this and adds it to the queue [1], but then checks the paging state again to guard against a race and can decide to just run the action immediately [2]. However it uses the bare action to run it immediately, not the potentially-wrapped version it added to the queue by this point. If the passed Runnable was not already an AtomicRunnable, as it seems many wont be, then this will mean the original action is likely to be run more than once, immediately at this point and then again via the AtomicRunnable added to the queue (the next time the queue is processed).
It should use a reference to the same AtomicRunnable object it adds to the queue, ensuring the underlying task is either run immediately or later, and not both. It could additionally try to remove the entry from the queue after running it.
[1] https://github.com/apache/activemq-artemis/blob/f8472fd736eff21d21ca2ab0c5a4dd22f0f1d00e/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreImpl.java#L708
[2] https://github.com/apache/activemq-artemis/blob/f8472fd736eff21d21ca2ab0c5a4dd22f0f1d00e/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreImpl.java#L716
Attachments
Issue Links
- links to