[fix][broker]Fix removing replica clusters on topic-policies not take effect - #16144
Merged
codelipenghui merged 2 commits intoJul 4, 2022
Merged
Conversation
Contributor
|
/pulsarbot run-failure-checks |
Contributor
Author
|
Also modify the namespace-policy and topic-policy initialization order. PTAL @Jason918 |
Contributor
Author
|
/pulsarbot run-failure-checks |
Contributor
Author
Jason918
approved these changes
Jun 24, 2022
Contributor
Author
|
@gaozhangmin PTAL |
codelipenghui
approved these changes
Jul 4, 2022
Nicklee007
pushed a commit
to Nicklee007/pulsar
that referenced
this pull request
Jul 5, 2022
wuxuanqicn
pushed a commit
to wuxuanqicn/pulsar
that referenced
this pull request
Jul 14, 2022
10 tasks
lhotari
added a commit
to lhotari/pulsar
that referenced
this pull request
Jul 2, 2026
…-persistent topics PR apache#16144 added initTopicPolicy for PersistentTopic but not for non-persistent topics: a NonPersistentTopic registered its policy listener in the constructor and completed the listener wrapper with null policies, so it never applied its own topic-level policies on load and instead depended on the namespace-wide policy broadcast. Move the topicPolicyListener wrapper field and initTopicPolicy() up to AbstractTopic (getTopicPolicyListener() now returns the wrapper) and have NonPersistentTopic.initialize() call initTopicPolicy(), so a non-persistent topic registers its listener and applies its initial global and local policies on load, exactly like a persistent topic. This removes the need to re-broadcast every topic's policy when a namespace's policy cache finishes loading (handled in a follow-up commit). Assisted-by: Claude Code (Opus 4.8)
This was referenced Jul 2, 2026
[improve][broker] Load topic policies on non-persistent topic load and gate the policy replay
#26134
Merged
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
org.apache.pulsar.client.admin.Topics#removeReplicationClustersnot taking effect: Because we have usedHierarchyTopicPoliciesto save topic-level policies, so we shoud removingpolicies.getReplicationClusters() != null.Modifications
policies.getReplicationClusters() != nullwhen topic-level policies updatingPersistentTopic#initialize. The reason is that:Policies#replication_clusterswhen using adminV2.TopicPolicies#replicationClusters.TopicPoliciesTest#testGetSetSubscribeRatetest failure.admin.topics().createPartitionedTopic, which just create zookeeper nodes withoutPersistentTopiccreatingadmin.namespaces().setSubscribeRate, namespace-policy will be set with local cluster name inPolicies#replication_clusters. But because step.a just create zookeeper nodes, so the policy will not be applied toPersistentTopicnow.admin.topicPolicies().setSubscribeRate, topic-policy will be set with no local cluster name inTopicPolicies#replicationClusters.pulsarClient1.newConsumer().subscriptionName("sub1").topic(persistenceTopic).consumerName("test").subscribe(), will createPersistentTopicHierarchyTopicPolicies#replicationClusterswill be empty , and thePersistentTopicwill be deleted unexpectedly. line:1377pulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java
Lines 1357 to 1378 in 603a5cd
Verifying this change
This change added tests and can be verified as follows:
(example:)
org.apache.pulsar.broker.service.ReplicatorTopicPoliciesTest#testRemoveReplicationClustersDocumentation
doc-not-needed