wangjialing218 commented on a change in pull request #11135: URL: https://github.com/apache/pulsar/pull/11135#discussion_r662740488
########## File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentDispatcherMultipleConsumers.java ########## @@ -331,13 +334,14 @@ protected int calculateNumOfMessageToRead(int currentTotalAvailablePermits) { } topic.getBrokerService().executor().schedule(() -> readMoreEntries(), MESSAGE_RATE_BACKOFF_MS, TimeUnit.MILLISECONDS); - return -1; + return Pair.of(-1, -1L); } else { - // if dispatch-rate is in msg then read only msg according to available permit - long availablePermitsOnMsg = dispatchRateLimiter.get().getAvailableDispatchRateLimitOnMsg(); - if (availablePermitsOnMsg > 0) { - messagesToRead = Math.min(messagesToRead, (int) availablePermitsOnMsg); - } + Pair<Integer, Long> calculateResult = computeReadLimits(messagesToRead, + (int) dispatchRateLimiter.get().getAvailableDispatchRateLimitOnMsg(), + bytesToRead, dispatchRateLimiter.get().getAvailableDispatchRateLimitOnByte()); + + messagesToRead = calculateResult.getLeft(); + bytesToRead = calculateResult.getRight(); Review comment: If topic level rate limiter and subscription level rate limiter both enabled, calculateResult for subscription level rate limiter seems overwrite the resul for topic level rate limiter -- 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