danielsinai commented on a change in pull request #11446:
URL: https://github.com/apache/pulsar/pull/11446#discussion_r676317299



##########
File path: 
pulsar-common/src/main/java/org/apache/pulsar/common/util/RateLimiter.java
##########
@@ -257,14 +271,15 @@ public synchronized TimeUnit getRateTimeUnit() {
     }
 
     synchronized void renew() {
-        acquiredPermits = isDispatchRateLimiter ? Math.max(0, acquiredPermits 
- permits) : 0;
+        acquiredPermits = isDispatchOrPrecisePublishRateLimiter ? Math.max(0, 
acquiredPermits - permits) : 0;
         if (permitUpdater != null) {
             long newPermitRate = permitUpdater.get();
             if (newPermitRate > 0) {
                 setRate(newPermitRate);
             }
         }
-        if (rateLimitFunction != null) {
+        // release the back-pressure by applying the rateLimitFunction only 
when there are available permits
+        if (rateLimitFunction != null && this.getAvailablePermits() > 0) {

Review comment:
       It is necessary, without it every renew call the function will release 
the throttle.
   
   Not having it defeats the whole purpose of throttling a connection.




-- 
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: commits-unsubscr...@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to