wangjialing218 opened a new pull request #8611:
URL: https://github.com/apache/pulsar/pull/8611


   Fixes #8599
   
   ### Motivation
   
   Pulsar current support topic level and subscription level dispatch rate 
limiter by using `DispatchRateLimiter`.  When consumers connected to broker and 
start reading entry, broker judge whether rate limit is exceeded before 
reading, and increasing the permits after reading finished by call 
tryAcquire().  When there are multi consumers using one `DispatchRateLimiter`, 
these consumers could start reading together and may increasing the 
`acquiredPermits` far more than `permits` after reading finished. As 
`acquiredPermits` will reset to 0 every second, all consumers could start 
reading in the next second and dispatch rate limiter will take no effect in 
such case.
   
   ### Modifications
   
   This PR change the behaviour of `DispatchRateLimiter`, minus `permits` every 
second instead of reset `acquiredPermits` to 0, and the reading will stop for a 
while until `acquiredPermits` return to a value less than  `permits` .
   
   ### Verifying this change
   RateLimiterTest.testDispatchRate()
   


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

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


Reply via email to