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

   ### Motivation
   
   `Consumer.redeliverUnacknowledgedMessages` has race conditions with the 
expire path (`readMoreEntries → removeAllUpTo`), which can corrupt the 
`unackedMessages` counter:
   
   * The epoch-based variant resets the counter to 0, while expire may 
concurrently decrement it to a negative value.
   * The list-based variant performs `get` and `remove` separately, allowing 
expire to remove entries in between and causing incorrect redelivery counting.
   
   ### Modifications
   
   * Make redelivery operations atomic with respect to expire:
   
     * Add `PendingAcksMap.forEachAndClear()` to atomically iterate and clear 
all entries under a single lock.
     * Add `PendingAcksMap.removeAndGet()` to atomically get and remove entries.


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