michaeljmarshall commented on code in PR #17483:
URL: https://github.com/apache/pulsar/pull/17483#discussion_r966562277
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentDispatcherMultipleConsumers.java:
##########
@@ -634,7 +634,9 @@ protected synchronized boolean
trySendMessagesToConsumers(ReadType readType, Lis
// round-robin dispatch batch size for this consumer
int availablePermits = c.isWritable() ? c.getAvailablePermits() :
1;
if (c.getMaxUnackedMessages() > 0) {
- availablePermits = Math.min(availablePermits,
c.getMaxUnackedMessages() - c.getUnackedMessages());
+ // Avoid negative number
+ int remainUnAckedMessages = Math.max(c.getMaxUnackedMessages()
- c.getUnackedMessages(), 0);
Review Comment:
Do we understand why `c.getUnackedMessages()` is greater than
`c.getMaxUnackedMessages()`? I read through the test, but I didn't see what is
causing the negative `availablePermits`.
Based on the names, that seems like there is another bug if
`c.getMaxUnackedMessages() - c.getUnackedMessages()` is negative. Perhaps the
idea that the `maxUnackedMessages` is just a soft limit that we shouldn't
exceed by too much?
--
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]