nodece commented on PR #25061:
URL: https://github.com/apache/pulsar/pull/25061#issuecomment-3639790022

   @lhotari The AsyncTokenBucket implementation itself is correct, but the 
dispatcher was not using this limiter correctly.  
   With the old behavior, when thread-1 and thread-2 both used the shared 
global limiter, they would both read the same available token value and only 
deduct tokens after sending messages to the client. This resulted in both 
threads consuming the same tokens, creating overshoot.
   
   The new behavior fixes this. When thread-1 and thread-2 access the global 
limiter, they still see the same available tokens, but now tokens are consumed 
before dispatch, ensuring that only one thread can actually acquire those 
tokens. This prevents overshoot and guarantees that only permitted messages are 
sent, improving dispatch correctness and avoiding unnecessary network traffic.


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