Skip to content

Commit 692c182

Browse files
heesung-snTechnoboy-
authored andcommitted
[fix][broker] new load balancer system topic should not be auto-created now (#20566)
1 parent b19ab1f commit 692c182

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java

+11-1
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
import org.apache.pulsar.broker.intercept.BrokerInterceptor;
101101
import org.apache.pulsar.broker.intercept.ManagedLedgerInterceptorImpl;
102102
import org.apache.pulsar.broker.loadbalance.LoadManager;
103+
import org.apache.pulsar.broker.loadbalance.extensions.channel.ServiceUnitStateChannelImpl;
103104
import org.apache.pulsar.broker.namespace.NamespaceService;
104105
import org.apache.pulsar.broker.resources.DynamicConfigurationResources;
105106
import org.apache.pulsar.broker.resources.LocalPoliciesResources;
@@ -3291,10 +3292,19 @@ private CompletableFuture<Boolean> isAllowAutoTopicCreationAsync(final TopicName
32913292
topicName.getNamespaceObject());
32923293
return CompletableFuture.completedFuture(false);
32933294
}
3294-
//System topic can always be created automatically
3295+
3296+
// ServiceUnitStateChannelImpl.TOPIC expects to be a non-partitioned-topic now.
3297+
// We don't allow the auto-creation here.
3298+
// ServiceUnitStateChannelImpl.start() is responsible to create the topic.
3299+
if (ServiceUnitStateChannelImpl.TOPIC.equals(topicName.toString())) {
3300+
return CompletableFuture.completedFuture(false);
3301+
}
3302+
3303+
//Other system topics can be created automatically
32953304
if (pulsar.getConfiguration().isSystemTopicEnabled() && isSystemTopic(topicName)) {
32963305
return CompletableFuture.completedFuture(true);
32973306
}
3307+
32983308
final boolean allowed;
32993309
AutoTopicCreationOverride autoTopicCreationOverride = getAutoTopicCreationOverride(topicName, policies);
33003310
if (autoTopicCreationOverride != null) {

pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BrokerServiceTest.java

+10
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
import org.apache.http.client.methods.HttpGet;
7373
import org.apache.http.impl.client.HttpClientBuilder;
7474
import org.apache.pulsar.broker.PulsarService;
75+
import org.apache.pulsar.broker.loadbalance.extensions.channel.ServiceUnitStateChannelImpl;
7576
import org.apache.pulsar.broker.namespace.NamespaceService;
7677
import org.apache.pulsar.broker.service.BrokerServiceException.PersistenceException;
7778
import org.apache.pulsar.broker.service.persistent.PersistentTopic;
@@ -1520,4 +1521,13 @@ public void testDynamicConfigurationsForceDeleteTenantAllowed() throws Exception
15201521
assertTrue(conf.isForceDeleteTenantAllowed());
15211522
});
15221523
}
1524+
1525+
@Test
1526+
public void testIsSystemTopicAllowAutoTopicCreationAsync() throws Exception {
1527+
BrokerService brokerService = pulsar.getBrokerService();
1528+
assertFalse(brokerService.isAllowAutoTopicCreationAsync(
1529+
ServiceUnitStateChannelImpl.TOPIC).get());
1530+
assertTrue(brokerService.isAllowAutoTopicCreationAsync(
1531+
"persistent://pulsar/system/my-system-topic").get());
1532+
}
15231533
}

0 commit comments

Comments
 (0)