[Bug] Spurious ERROR log for 307 redirect in getReplicatedSubscriptionStatus for partitioned topics
Discussed in https://github.com/apache/pulsar/discussions/26696
Originally posted by Goodkat September 23, 2026
Environment
- Pulsar version: 4.0.13 (also present on
main/ 5.0.0-M1-SNAPSHOT) - Setup: Multi-cluster geo-replication with Pulsar proxy, partitioned topics with replicated subscriptions
Problem
When calling the admin API to get replicated subscription status on a partitioned topic, the broker logs spurious ERROR-level entries with full stack traces for what is actually a normal 307 Temporary Redirect:
{"@timestamp":"2026-09-22T11:22:20.474Z","log.level":"ERROR",
"message":"[<clientID> Failed to get replicated subscription status on <topic-name> <subscription-name>",
"log.logger":"org.apache.pulsar.broker.admin.impl.PersistentTopicsBase",
"error.type":"javax.ws.rs.WebApplicationException",
"error.message":"HTTP 307 Temporary Redirect",
"error.stack_trace":"javax.ws.rs.WebApplicationException: HTTP 307 Temporary Redirect\n\tat org.apache.pulsar.broker.web.PulsarWebResource.lambda$validateTopicOwnershipAsync$27(PulsarWebResource.java:794)\n\t..."}The 307 is expected behavior — it means the broker doesn't own the topic partition and is redirecting the client to the correct broker. The operation succeeds after the redirect. However, it is logged at ERROR level, creating significant log noise in environments with many partitions spread across multiple brokers and frequent monitoring/admin calls.
Root cause
In PersistentTopicsBase.java:5207-5224, the method internalGetReplicatedSubscriptionStatusForNonPartitionedTopic has a .whenComplete handler that unconditionally logs any exception at ERROR level:
private void internalGetReplicatedSubscriptionStatusForNonPartitionedTopic(...) {
validateTopicOwnershipAsync(topicName, authoritative)
.thenCompose(__ -> getReplicatedSubscriptionStatusFromLocalBroker(topicName, subName))
.whenComplete((res, e) -> {
if (e != null) {
Throwable cause = FutureUtil.unwrapCompletionException(e);
log.error("[{}] Failed to get replicated subscription status on {} {}", clientAppId(),
topicName, subName, cause); // <-- missing isNot307And404Exception check
resumeAsyncResponseExceptionally(asyncResponse, e);
}
});
}Compare with the outer handler at line 5178 which correctly filters out 307 and 404:
resultFuture.exceptionally(ex -> {
if (isNot307And404Exception(ex)) {
log.error("[{}] Failed to get replicated subscription status on {} {}", clientAppId(),
topicName, subName, ex);
}
resumeAsyncResponseExceptionally(asyncResponse, ex);
return null;
});The isNot307And404Exception guard is used in ~60+ other places across the admin API. It is missing only in this specific method.
How to trigger
This method is called in two scenarios:
- Directly for non-partitioned topics when the request hits the wrong broker
- For individual partitions of a partitioned topic — when the partitioned topic code path (line 5119) fans out per-partition requests via the internal admin client, and the target broker's ownership has shifted (e.g., during rebalance or bundle unload) between the ownership check and the actual call
In a setup with a proxy, the proxy forwards the initial request to an arbitrary broker. That broker then fans out per-partition requests directly to other brokers (bypassing the proxy). If the target broker doesn't own the partition (stale metadata, concurrent rebalance), the 307 is thrown and incorrectly logged as ERROR.
Suggested fix
Add the isNot307And404Exception guard before the log.error call, matching the pattern used everywhere else:
.whenComplete((res, e) -> {
if (e != null) {
Throwable cause = FutureUtil.unwrapCompletionException(e);
if (isNot307And404Exception(cause)) {
log.error("[{}] Failed to get replicated subscription status on {} {}", clientAppId(),
topicName, subName, cause);
}
resumeAsyncResponseExceptionally(asyncResponse, e);
} else {
asyncResponse.resume(res);
}
});Impact
- No functional impact — the redirect works correctly, the client follows it, and the operation succeeds
- Log noise — frequent ERROR entries with full stack traces in environments with partitioned topics, geo-replication, and monitoring tools that poll replicated subscription status
Source: apache/pulsar