You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/07/26 02:30:11 UTC
[GitHub] [pulsar] 315157973 commented on a change in pull request #11446: [issue #13351] Solving precise rate limiting does not takes effect
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-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org