Repository navigation
[fix][broker] Spurious ERROR log for 307 redirect in getReplicatedSubscriptionStatus - #26706
Merged
Merged
Conversation
Contributor
Author
|
Could anyone review this? |
ascentstream-bot
pushed a commit
to ascentstream/pulsar
that referenced
this pull request
Oct 1, 2026
…scriptionStatus (apache#26706) Co-authored-by: Vyacheslav SHABLISTYY <[email protected]> Co-authored-by: Lari Hotari <[email protected]> (cherry picked from commit 776786b)
ascentstream-bot
pushed a commit
to ascentstream/pulsar
that referenced
this pull request
Oct 2, 2026
…scriptionStatus (apache#26706) Co-authored-by: Vyacheslav SHABLISTYY <[email protected]> Co-authored-by: Lari Hotari <[email protected]> (cherry picked from commit 776786b)
Radiancebobo
pushed a commit
to Radiancebobo/pulsar
that referenced
this pull request
Oct 8, 2026
…scriptionStatus (apache#26706) Co-authored-by: Vyacheslav SHABLISTYY <[email protected]> Co-authored-by: Lari Hotari <[email protected]>
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.
Fixes #26699
Motivation
PersistentTopicsBase#internalGetReplicatedSubscriptionStatusForNonPartitionedTopiclogs everyfailure of its future at ERROR level with a full stack trace. That includes the
WebApplicationException: HTTP 307 Temporary Redirectthrown byvalidateTopicOwnershipAsyncwhen this broker does not own the topic.
A 307 is not a failure. It is how a broker tells the caller which broker owns the partition; the
caller follows the redirect and the operation succeeds. Logging it at ERROR is misleading and
noisy:
The redirect is reached often in practice. For a partitioned topic,
internalGetReplicatedSubscriptionStatuschecks ownership per partition and forwards thepartitions this broker does not own to their owning brokers through the internal admin client.
The receiving broker takes the partitioned-name path into
internalGetReplicatedSubscriptionStatusForNonPartitionedTopic, and if ownership moved in themeantime — a bundle unload or a rebalance between the lookup and the call — it answers 307 and
logs the stack trace. With geo-replication, many partitions, and monitoring that polls
replicated subscription status, this fills broker logs with ERROR entries for healthy traffic.
Every comparable handler in the admin API already filters these out with
isNot307And404Exception, including the outerresultFuture.exceptionallyhandler in this verymethod. The guard is missing only in this inner handler.
Modifications
Wrap the
log.error(...)call ininternalGetReplicatedSubscriptionStatusForNonPartitionedTopicin an
isNot307And404Exception(cause)check, matching the pattern used throughoutPersistentTopicsBase.This is a logging-only change. The exception is still propagated to the caller unchanged through
resumeAsyncResponseExceptionally, so the 307 response, the redirect location, and clientbehaviour are all exactly as before. Genuine failures are still logged at ERROR; only 307 and 404
are suppressed.
Verifying this change
This change added tests and can be verified as follows:
PersistentTopicsTest#testGetReplicatedSubscriptionStatusDoesNotLogRedirectAsError,which stubs
NamespaceService#isServiceUnitOwnedAsyncto report the partition as not owned —the same state a concurrent bundle unload produces — then calls
getReplicatedSubscriptionStatuswith the partition name so the request routes directly intothe handler under test. It asserts both that the response is still
307 Temporary Redirectand that no ERROR event was logged for it.
PulsarWebResourcelogger rather thanPersistentTopicsBase: thelogfield used by this handler is inherited fromPulsarWebResourceand derived viaLOG.with().build(), and slog preserves the parentlogger's name when deriving. Registering on
PersistentTopicsBasewould capture nothing andthe test would pass vacuously.
fails with
AssertionError: A 307 redirect must not be logged at ERROR level.Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes