Skip to content

[fix][client] Fix ServerSideErrorException when PulsarAdminUtils#getConsumeStats reads a markDeletePosition - #28

Merged
zymap merged 1 commit into
apache:mainfrom
X-R-D:fix/fixServerSideErrorException
Sep 22, 2026
Merged

zymap merged 1 commit into
apache:mainfrom
X-R-D:fix/fixServerSideErrorException

Conversation

@StevenLuMT

@StevenLuMT StevenLuMT commented Sep 21, 2026 •

Copy link
Copy Markdown
Member

Motivation

PulsarAdminUtils#getConsumeStats may fail with PulsarAdminException.ServerSideErrorException when a subscription's markDeletePosition advances 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 LastConfirmedEntry error. 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

  1. Clamp consumedMessageId to maxMessageId (lastConfirmedEntry) before reading its index.
  2. Handle NotFoundException and ServerSideErrorException from getMessageById as no-valid-index cases.
  3. Return -1 consistently when:
    • the target message is not readable;
    • the message does not exist;
    • the message has no index;
    • the position points to an empty newly rolled-over ledger.
  4. Preserve the -1 sentinel value when converting a ledger-boundary position, avoiding an incorrect -2 offset.
  5. Add warning logs for degraded consume-stats lookup paths.

Verifying this change

This change can be verified by running the existing CI checks.

The expected behavior is that getConsumeStats returns -1 for an unavailable consumed-message index instead of throwing an exception when the markDeletePosition points to a ledger with no confirmed entries.

…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.
@zymap
zymap merged commit a623a47 into apache:main Sep 22, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants