Repository navigation
[fix][broker] Do not enable replicated subscriptions on scalable topic segments - #26679
Merged
merlimat merged 2 commits intoSep 22, 2026
Conversation
…c segments A segment:// topic of a scalable topic lives in a namespace whose replication clusters apply to it, so a subscription created with replicateSubscriptionState enabled the ReplicatedSubscriptionsController on the segment. The segment DAG is independent per cluster (PIP-460, "Geo-Replication"), so no remote cluster can ever answer the snapshot requests the controller writes into the segment. On current master the classic replicator that a segment also starts never connects, which happens to keep the controller from writing; once segments stop starting classic replicators, a snapshot request marker lands in the segment ledger every snapshot period. Guard the controller enable path against segment topics. The subscribe is not rejected: the subscription is created and keeps its replicated flag, only the controller is withheld. Remove replicateSubscriptionState from the V5 StreamConsumerBuilder and QueueConsumerBuilder until replicated subscriptions for scalable topics are designed, and move the --replicated option of pulsar-client consume, pulsar-perf consume and pulsar-perf transaction to their -v4 variants, the only commands that can still honour it.
lhotari
approved these changes
Sep 22, 2026
lhotari
left a comment
Member
There was a problem hiding this comment.
Thanks for fixing replicated-subscription handling for scalable topic segments. The broker regression test passes, but the perf CLI option move leaves PulsarPerfTestToolTest.testV4CommandsOfferTheSameFlagsAsTheirV5Counterparts failing because its parity checks still require the new V4-only flags on the V5 commands. Please fix the test before merging.
…d transaction commands PulsarPerfTestToolTest required the V5 consume and transaction commands to offer every flag of their v4 counterparts. With --replicated moved to consume-v4 and transaction-v4, exclude it from that comparison and assert that only the v4 commands offer it.
lhotari
added a commit
to lhotari/pulsar
that referenced
this pull request
Sep 23, 2026
…e-v4-cmds Resolve conflicts with apache#26679, which made -rs/--replicated v4-only: in the merged commands it moves into the v4 client option group of pulsar-perf consume and transaction and of pulsar-client consume, and the V5 runners no longer set replicateSubscriptionState. Assisted-by: Claude Code (claude-opus-5-5)
1 of 10 tasks
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
A
segment://topic of a scalable topic lives in a namespace whosereplication_clustersapply to it.PersistentTopic.checkReplicatedSubscriptionControllerStateenables aReplicatedSubscriptionsControllerwhen a subscription is replicated,enableReplicatedSubscriptionsis on and the topic has more than one replication cluster — and that last check looks at the namespace policy, which cannot tell a segment apart from a regular topic. So a V5 consumer created withreplicateSubscriptionState(true)(forwarded to every per-segment v4 consumer) enabled the controller on each segment.The segment DAG of a scalable topic is independent per cluster (PIP-460, Geo-Replication), so no remote cluster can ever answer the snapshot requests the controller writes into the segment; replicated subscriptions for scalable topics are explicitly deferred to a future sub-PIP.
Reproduced on
masterwith the new test: the controller is present on the segment. On currentmasterthe classic replicator that a segment also starts never connects, which happens to trip the controller's "some cluster is not reachable" skip and keeps it from writing. A separate change stops segments from starting classic replicators; with that applied, aREPLICATED_SUBSCRIPTION_SNAPSHOT_REQUESTmarker lands in the segment ledger every snapshot period. The two changes belong together.Modifications
checkReplicatedSubscriptionControllerState(boolean)— the single choke point for all enable paths (subscribe, topic load, namespace/topic policy update, received-marker force path) — returns early for a segment topic, with a DEBUG log. Only enabling is skipped; the disable branch still runs.The subscribe request is not rejected: the flag still arrives on the wire from older V5 milestones or direct
subscribeSegmentAsyncusers, and aNotAllowedExceptionwould turn a harmless request into a failing consumer. The subscription is created and keeps its replicated flag; only the controller is withheld.replicateSubscriptionState(boolean)is removed fromStreamConsumerBuilderandQueueConsumerBuilder(and their implementations) until replicated subscriptions for scalable topics are designed. The method only shipped in the 5.0.0 milestones.-rs/--replicatedmoves from the base classes shared with the-v4commands intoconsume-v4(pulsar-client),consume-v4andtransaction-v4(pulsar-perf) — the only commands that can still honour it. The V5 commands no longer accept it.Verifying this change
This change added tests and can be verified as follows:
ScalableTopicSegmentReplicatedSubscriptionTest(two-clusterOneWayReplicatorTestBase): creates a scalable topic in the replicated namespace, publishes to its segment and subscribes to thesegment://topic withreplicateSubscriptionState=truethe way a V5 consumer does, then asserts over several snapshot periods that the segment has no replicated subscriptions controller and no marker messages in its ledger. Fails on unpatchedmaster(Expecting an empty Optional but was containing value: ReplicatedSubscriptionsController).ReplicatedSubscriptionsControllerTestandReplicatedSubscriptionTeststill pass for regular topics;TestCmdConsumeandPerformanceConsumerArgsTestpass.Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes
StreamConsumerBuilder#replicateSubscriptionStateandQueueConsumerBuilder#replicateSubscriptionStateare removed from the V5 client API (pulsar-client-api-v5, milestone-only so far).pulsar-client consumeandpulsar-perf consume/transactionno longer accept-rs/--replicated; the-v4variants keep it.