Repository navigation
[fix][client-cpp] Avoid returning permits for acknowledged batch indexes on redelivery - #625
Open
xqw2001-11 wants to merge 1 commit into
Open
xqw2001-11 wants to merge 1 commit into
xqw2001-11 wants to merge 1 commit into
Conversation
…xes on redelivery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
With batch index acknowledgments enabled, the broker charges one permit for each unacknowledged index in a redelivered batch. The C++ client also returns permits for indexes the broker already marked as acknowledged. Repeated partial-batch redelivery can therefore allow the broker to dispatch more messages than the configured receiver queue size.
The Java client addressed the same accounting issue in apache/pulsar#22091.
Modifications
Exclude indexes already acknowledged by the broker from the FLOW permits returned for skipped messages. Count them before the start-message and dead-letter checks so an overlapping skip cannot return a permit either. Keep counting all skipped messages when reporting how many messages reached the application.
Verifying this change
Added
AcknowledgeTest.testPermitsAfterPartialBatchRedelivery. A shared consumer with a queue of 16 receives one batch of eight, acknowledges seven indexes, and requests redelivery of the eighth. The test checks the redelivered message ID and redelivery count, acknowledges it, then queries the broker for available permits. The original batch triggered a refill of eight permits. Only one permit was charged on redelivery, and one consumed message is below the next refill threshold. The expected broker balance is 15. Unpatched main reports 23. With the fix, the new test and the existing batch index acknowledgment test both passed on three consecutive runs against a standalone broker.Documentation
doc-not-needed— restores the existing receiver queue behavior without changing any API or configuration.