jeanouii commented on code in PR #2276:
URL: https://github.com/apache/activemq/pull/2276#discussion_r4483267089


##########
activemq-client/src/main/java/org/apache/activemq/usage/Usage.java:
##########
@@ -276,6 +296,17 @@ protected void setPercentUsage(int value) {
         }
     }
 
+    /**
+     * Silently refresh the cached percentUsage (no listener events, no waiter 
signalling) -
+     * used by the internal recompute sites in waitForSpace(long,int) and 
isFull(int).
+     * Must be called with the usageLock write lock held. Subclasses that 
cache values derived
+     * from percentUsage override this to refresh them in the same critical 
section.
+     */
+    protected void refreshPercentUsage(int value) {
+        percentUsage = value;
+        bounds = PercentBounds.compute(value, limiter.getLimit(), 
percentUsageMinDelta);
+    }

Review Comment:
   Imagine we reached 100%, producers are blocked and waiting for space 
(waiting on the signalAll).
   
   Thread Consumer A sets the atomic value from 100 to 99 for example
   Thread Dispatch B (refreshPercentUsage) sees the change and updates the 
percent to 99%, but never does signalAll to wake up producers.
   Thread Consumer A (fireEvent) sees 99 before and 99 after, does not trigger 
the signalAll either
   
   All producers remain stuck until we reach again 100% so the fireEvent can 
see old 100, new (less) and do the signal. But if all producers are waiting, we 
never reach again 100%



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact


Reply via email to