This is an automated email from the ASF dual-hosted git repository.
yubiao pushed a commit to branch branch-2.10
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/branch-2.10 by this push:
new c1867f263f6 [fix][broker] Fix the issue of topics possibly being
deleted. (#21704)
c1867f263f6 is described below
commit c1867f263f6b94f2a1a6e4866c07a3962c618fc5
Author: crossoverJie <[email protected]>
AuthorDate: Thu Dec 14 21:45:37 2023 +0800
[fix][broker] Fix the issue of topics possibly being deleted. (#21704)
Co-authored-by: Jiwe Guo <[email protected]>
(cherry picked from commit 84ea1ca05decbcb5d3a3bd1812e53ad10773b259)
---
.../apache/pulsar/broker/service/persistent/PersistentTopic.java | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git
a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java
b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java
index 0c27be32be0..75633860583 100644
---
a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java
+++
b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java
@@ -76,6 +76,7 @@ import org.apache.bookkeeper.mledger.impl.ManagedCursorImpl;
import org.apache.bookkeeper.mledger.impl.ManagedLedgerImpl;
import org.apache.bookkeeper.mledger.impl.PositionImpl;
import org.apache.bookkeeper.net.BookieId;
+import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.pulsar.broker.PulsarServerException;
import
org.apache.pulsar.broker.resources.NamespaceResources.PartitionedTopicResources;
@@ -265,7 +266,6 @@ public class PersistentTopic extends AbstractTopic
implements Topic, AddEntryCal
.build();
this.backloggedCursorThresholdEntries =
brokerService.pulsar().getConfiguration().getManagedLedgerCursorBackloggedThreshold();
- registerTopicPolicyListener();
this.compactedTopic = new
CompactedTopicImpl(brokerService.pulsar().getBookKeeperClient());
@@ -1411,6 +1411,11 @@ public class PersistentTopic extends AbstractTopic
implements Topic, AddEntryCal
String localCluster =
brokerService.pulsar().getConfiguration().getClusterName();
+ if (CollectionUtils.isEmpty(configuredClusters)) {
+ log.warn("[{}] No replication clusters configured", name);
+ return CompletableFuture.completedFuture(null);
+ }
+
// if local cluster is removed from global namespace cluster-list :
then delete topic forcefully
// because pulsar doesn't serve global topic without local
repl-cluster configured.
if (TopicName.get(topic).isGlobal() &&
!configuredClusters.contains(localCluster)) {
@@ -3159,6 +3164,8 @@ public class PersistentTopic extends AbstractTopic
implements Topic, AddEntryCal
protected CompletableFuture<Void> initTopicPolicy() {
if (brokerService.pulsar().getConfig().isSystemTopicEnabled()
&&
brokerService.pulsar().getConfig().isTopicLevelPoliciesEnabled()) {
+ brokerService.getPulsar().getTopicPoliciesService()
+
.registerListener(TopicName.getPartitionedTopicName(topic), this);
return CompletableFuture.completedFuture(null).thenRunAsync(() ->
onUpdate(
brokerService.getPulsar().getTopicPoliciesService()
.getTopicPoliciesIfExists(TopicName.getPartitionedTopicName(topic))),