merlimat opened a new pull request, #25988:
URL: https://github.com/apache/pulsar/pull/25988

   ### Motivation
   
   `RangeEntryCacheManagerImpl.triggerEvictionWhenNeeded()` uses `updateAndGet` 
with a lambda that returns `null` when another eviction is already in progress. 
Since `updateAndGet` stores the lambda's result, a thread losing the race 
overwrites the running eviction's in-progress marker with `null`. On its next 
loop iteration that thread installs its own future and submits a duplicate 
eviction task, while the first cycle's cleanup then clears the second cycle's 
marker.
   
   With the cache sitting at the eviction trigger threshold and many 
managed-ledger threads inserting concurrently, this happens routinely: 
redundant tasks are queued on the single eviction executor (each re-checks the 
size, so the wasted work is bounded, but timer-driven eviction passes get 
delayed behind the no-op tasks), and the marker no longer reliably reflects 
whether an eviction is running.
   
   ### Modifications
   
   Use `compareAndSet(null, newEvictionFuture)` so only the winning thread 
installs the in-progress marker; losing threads loop and pick up the owner's 
future via `get()`. The owner remains the only one clearing the marker in 
`triggerEvictionToMakeSpace`'s `finally` block.


-- 
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]

Reply via email to