[fix][client] Fix ServerSideErrorException when PulsarAdminUtils#getConsumeStats reads a markDeletePosition - #28
Merged
Conversation
…onsumeStats reads a markDeletePosition that has advanced into a newly rolled-over ledger with no confirmed entries, by clamping the consumed position to lastConfirmedEntry and unifying all "no readable message / no valid index" cases to degrade gracefully to -1 instead of throwing.
AnonHxy
approved these changes
Sep 22, 2026
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
PulsarAdminUtils#getConsumeStatsmay fail withPulsarAdminException.ServerSideErrorExceptionwhen a subscription'smarkDeletePositionadvances to a newly rolled-over ledger that has no confirmed entries yet.In this case, attempting to read the message at the consumed position can fail with a
LastConfirmedEntryerror. Similar boundary cases, such as a missing message or missing broker entry metadata index, should not cause the whole consume-stats query to fail.Modifications
consumedMessageIdtomaxMessageId(lastConfirmedEntry) before reading its index.NotFoundExceptionandServerSideErrorExceptionfromgetMessageByIdas no-valid-index cases.-1consistently when:-1sentinel value when converting a ledger-boundary position, avoiding an incorrect-2offset.Verifying this change
This change can be verified by running the existing CI checks.
The expected behavior is that
getConsumeStatsreturns-1for an unavailable consumed-message index instead of throwing an exception when themarkDeletePositionpoints to a ledger with no confirmed entries.