BewareMyPower commented on PR #18491:
URL: https://github.com/apache/pulsar/pull/18491#issuecomment-1318224636

   Got it. Thanks. The motivation part is a little confusing. The root cause is 
that the consumer won't be removed from `pausedConsumers` if the incoming 
messages are greater than half of the receiver queue size. Therefore, 
`resumeReceivingFromPausedConsumersIfNeeded` must be called after 
`clearIncomingMessages`.
   
   BTW, it's not a race condition in `redeliverUnacknowledgedMessages` for 
previous code:
   
   ```java
       public void redeliverUnacknowledgedMessages() {
           internalPinnedExecutor.execute(() -> {
               /* ... */
               clearIncomingMessages();
               unAckedMessageTracker.clear();
           });
           resumeReceivingFromPausedConsumersIfNeeded();
       }
   ```
   
   `internalPinnedExecutor` is a single thread executor, when 
`redeliverUnacknowledgedMessages` is called in `internalPinnedExecutor`, 
`resumeReceivingFromPausedConsumersIfNeeded` will always be called before 
`clearIncomingMessages()`.
   


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