GeezerVison is showing github.com — [fix][broker] Preserve unacked backpressure for stale redelivery requests by Denovo1998 · Pull Request #26910 · apache/pulsar
Conversation
Denovo1998
commented
Oct 14, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Follow-up to #26797.
Motivation
A persistent Shared or Key_Shared consumer can reach its unacknowledged-message limit and become blocked. A selective-redelivery request containing only stale IDs or zero-count pending positions can clear the blocked state and transfer deferred flow permits without removing any unacknowledged messages. However, a zero remaining count does not prove that all batch indexes are acknowledged: a rejected conflicting transactional ACK can leave an untouched index that still needs replay. Such requests must preserve backpressure while retaining the replay path for matching positions.
Modifications
- Preserve unacked backpressure and deferred flow permits when a selective-redelivery request removes zero unacknowledged messages.
- Keep matching zero-count pending positions eligible for replay: a rejected transactional batch ACK can leave unacknowledged indexes at such a position. Release backpressure only when the request removes unacknowledged messages.
- Add regression coverage for Shared and Key_Shared consumers using real client, broker, and BookKeeper fixtures.
Verifying this change
- Make sure that the change passes the CI checks.
Added ConsumerRedeliveryTest.testStaleSelectiveRedeliveryDoesNotUnblockConsumer, testZeroCountSelectiveRedeliveryPreservesBackpressure, and testSelectiveRedeliveryAfterConflictingTransactionalBatchAck.
The tests verify that stale IDs and zero-count requests preserve unacked backpressure, and that a rejected conflicting transactional ACK does not prevent selective redelivery of untouched batch indexes. The conflict cases cover zero-count-only and mixed requests for Shared and Key_Shared consumers. The zero-count backpressure cases pause the transaction executor while a real batch-index ACK updates consumer accounting, keeping the pending entry present until the transaction ACK completes.
The four conflict variants pass on the original broker logic, fail with the zero-count replay filter, and pass after this fix.
./gradlew --no-parallel --max-workers=2 :pulsar-broker:test \
-PtestMaxParallelForks=1 -PtestRetryCount=0 \
--tests ConsumerRedeliveryTest.testStaleSelectiveRedeliveryDoesNotUnblockConsumer \
--tests ConsumerRedeliveryTest.testZeroCountSelectiveRedeliveryPreservesBackpressure \
--tests ConsumerRedeliveryTest.testSelectiveRedeliveryAfterConflictingTransactionalBatchAck \
--tests ConsumerBlockedPermitAccountingTest \
--tests SharedDispatcherPermitAccountingTest
./gradlew --no-parallel --max-workers=2 quickCheck
Does this pull request potentially affect one of the following parts:
- Dependencies (add or upgrade a dependency)
- The public API
- The schema
- The default values of configurations
- The threading model
- The binary protocol
- The REST endpoints
- The admin CLI options
- The metrics
- Anything that affects deployment
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed head: 9314cd405c8084ff6ee7ad710c788cd873e5513f.
The stale-request backpressure fix is appropriately scoped, but the new zero-count replay filter relies on an invariant that the current transactional ACK path does not guarantee. Requesting changes for the inline P2 finding: a rejected duplicate transactional batch ACK can reduce the remaining count to zero while another batch index is still unacknowledged, and this change discards its previously viable selective-redelivery path.
Please address that accounting/replay interaction and add a regression covering a conflicting transactional ACK followed by selective redelivery of the untouched batch index. The added zero-count test covers ACKs of different indexes that eventually succeed, not this rejected-ACK case.
Validation limitation: the finding is source-traced, not runtime-reproduced. Local focused validation encountered an out-of-worktree Kotlin daemon write denied with Operation not permitted; all validation launches were stopped. There are no independently verified test passes or assertion failures, and the unpatched baseline and the conflict scenario were not run.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re-reviewed cc3508f55005c6fd21b56c4bc03973ad5a7109d6 against the previously reviewed 9314cd405c8084ff6ee7ad710c788cd873e5513f.
The previous P2 is addressed. Matching zero-count positions remain eligible for replay, while a request that removes no unacknowledged messages no longer clears the blocked state or releases deferred permits. This preserves the recovery path without expanding the change into transactional accounting redesign.
No actionable findings identified within the reviewed scope.
Validation:
- All 8 targeted cases actually ran and passed on the current head: stale selective redelivery (2), zero-count backpressure (2), and conflicting transactional batch ACK replay (4).
- As a negative control, I temporarily restored only the previous production logic while retaining the new tests. The Shared/zero-count conflict case failed as expected because the untouched batch index was not redelivered. The run stopped at that first failure; the other baseline variants were not independently executed.
- The source was fully restored and verified against the current head. The final Gradle check succeeded using cached test results, so it is not counted as a second independent test execution.
- The full suite was not run.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
nodece
pushed a commit
to ascentstream/pulsar
that referenced
this pull request
Nov 16, 2026
Uh oh!
There was an error while loading. Please reload this page.
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|