[fix][broker] Move pending acks cleanup to selected mark-delete callbacks - #25592
Merged
Conversation
lhotari
reviewed
Apr 28, 2026
lhotari
approved these changes
Apr 29, 2026
poorbarcode
pushed a commit
to poorbarcode/pulsar
that referenced
this pull request
May 6, 2026
Technoboy-
added a commit
that referenced
this pull request
May 12, 2026
nodece
added a commit
to ascentstream/pulsar
that referenced
this pull request
May 27, 2026
…acks (apache#25592) (cherry-pick from commit 138595f) Signed-off-by: Zixuan Liu <nodeces@gmail.com>
priyanshu-ctds
pushed a commit
to datastax/pulsar
that referenced
this pull request
Jun 9, 2026
…acks (apache#25592) (cherry-pick from commit 138595f) (cherry picked from commit 4330c2f)
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
Pending-ack cleanup was previously executed in the
readMoreEntriesdispatch path. This introduced unnecessary overhead in a hot path and also risked concurrent access to the same pending-ack entries from both dispatch and ack threads.
Cleanup is only required when messages are removed through mark-delete advancing operations such as expiry, skip, or clear-backlog. Ack-triggered mark-delete operations are much more frequent and should avoid carrying additional cleanup work.
Modifications
Introduced atomic remaining-unacked tracking for both non-batch and batch messages.
PendingAcksMapnow stores and updates the actualremainingUnackedcount instead of relying on batch size–based accounting.updateRemainingUnackedandremovePendingAckAndGetto simplify and centralize unacked-message accounting.Refactored pending-ack cleanup to leverage the existing
markDeletePositionMoveForwardhook.Removed pending-ack cleanup from the
readMoreEntriesdispatch path.Cleanup of pending acks and redelivery state is now triggered only after mark-delete advancement operations such as:
Ack-triggered paths do not invoke
markDeletePositionMoveForward; they continue usingafterAckMessagesto avoid additional overhead on the high-frequency ack path.Updated pending-ack iteration and removal paths to consistently use the maintained
remainingUnackedcount directly, improving correctness and concurrency handling for partial batch acknowledgments.