dragosvictor commented on code in PR #21682:
URL: https://github.com/apache/pulsar/pull/21682#discussion_r1426224174
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentDispatcherMultipleConsumers.java:
##########
@@ -665,15 +672,9 @@ protected synchronized boolean
trySendMessagesToConsumers(ReadType readType, Lis
long totalEntries = 0;
int avgBatchSizePerMsg = remainingMessages > 0 ?
Math.max(remainingMessages / entries.size(), 1) : 1;
- int firstAvailableConsumerPermits, currentTotalAvailablePermits;
- boolean dispatchMessage;
- while (entriesToDispatch > 0) {
- firstAvailableConsumerPermits = getFirstAvailableConsumerPermits();
- currentTotalAvailablePermits = Math.max(totalAvailablePermits,
firstAvailableConsumerPermits);
- dispatchMessage = currentTotalAvailablePermits > 0 &&
firstAvailableConsumerPermits > 0;
Review Comment:
I agree, it is a bit confusing. Here's the latest relevant change:
https://github.com/apache/pulsar/pull/10417. The idea was to always verify that
both the number of permits and at least one consumer's permits were positive.
This has been relaxed a bit, due to a case where the total number of permits
was negative for longer durations, due to any slow consumer. I think the
current code is correct, and can be simplified as described here.
cc @codelipenghui @lhotari
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]