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



##########
File path: 
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/PublishRateLimiterTest.java
##########
@@ -104,9 +104,13 @@ public void testPrecisePublishRateLimiterAcquire() throws 
Exception {
 
         // tryAcquire msgSizeInBytes exceeded
         assertFalse(precisPublishLimiter.tryAcquire(10, 101));
-        Thread.sleep(1100);
+        Thread.sleep(2100);

Review comment:
       This is a potential flaky test, and we cannot guarantee that it will be 
scheduled after 2100ms. Manual control of renew should be better

##########
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:
       I'm not sure if this is necessary
   Changed existing behavior




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