[ 
https://issues.apache.org/jira/browse/ARTEMIS-3591?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Robbie Gemmell resolved ARTEMIS-3591.
-------------------------------------
    Fix Version/s: 2.21.0
         Assignee: Robbie Gemmell
       Resolution: Fixed

> PagingStoreImpl#checkMemory can run the provided task more than once
> --------------------------------------------------------------------
>
>                 Key: ARTEMIS-3591
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-3591
>             Project: ActiveMQ Artemis
>          Issue Type: Bug
>          Components: Broker
>    Affects Versions: 2.19.0
>            Reporter: Robbie Gemmell
>            Assignee: Robbie Gemmell
>            Priority: Major
>             Fix For: 2.21.0
>
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> 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]|https://github.com/apache/activemq-artemis/blob/f8472fd736eff21d21ca2ab0c5a4dd22f0f1d00e/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreImpl.java#L708],
>  but then checks the paging state again to guard against a race and can 
> decide to just run the action immediately 
> [[2]|https://github.com/apache/activemq-artemis/blob/f8472fd736eff21d21ca2ab0c5a4dd22f0f1d00e/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreImpl.java#L716].
>  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]



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to