Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3319,6 +3319,12 @@ private CompletableFuture<Boolean> isAllowAutoTopicCreationAsync(final TopicName
}

public boolean isDefaultTopicTypePartitioned(final TopicName topicName, final Optional<Policies> policies) {
// system topics should be non-partitioned by default regardless of the broker config
// allowAutoTopicCreationType setting
if (SystemTopicNames.isSystemTopic(topicName)
|| NamespaceService.isSystemServiceNamespace(topicName.getNamespace())) {
return false;
}
Comment on lines +3322 to +3327

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why must it be non-partitioned?

Should it be configurable?

Should this be discussed in the mail list?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why must it be non-partitioned?

It's not "must", it's more about it being a bad default to make system topics such as the __change_events a partitioned topic. The amount of changes going into these topics isn't something that would justify using partitioned topics by default.

Should it be configurable?

If someone wants to use a specific amount of partitions, it's possible to create the system topics manually. Similarly as for transactions.

Should this be discussed in the mail list?

yes. I guess @michaeljmarshall had plans to open a discussion around this.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am pretty sure we want most, if not all, of these to be a single topic to ensure a specific ordering of events. It's worth discussing on the mailing list though. I can start something later today.

AutoTopicCreationOverride autoTopicCreationOverride = getAutoTopicCreationOverride(topicName, policies);
if (autoTopicCreationOverride != null) {
return TopicType.PARTITIONED.toString().equals(autoTopicCreationOverride.getTopicType());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import org.apache.pulsar.broker.service.BrokerTestBase;
import org.apache.pulsar.broker.service.Topic;
import org.apache.pulsar.broker.service.persistent.PersistentTopic;
import org.apache.pulsar.client.admin.ListTopicsOptions;
import org.apache.pulsar.client.admin.PulsarAdminException;
import org.apache.pulsar.client.api.Consumer;
import org.apache.pulsar.client.api.Message;
Expand Down Expand Up @@ -88,22 +87,16 @@ protected void cleanup() throws Exception {
}

@Test
public void testAutoCreatedPartitionedSystemTopic() throws Exception {
public void testAutoCreatedNonPartitionedSystemTopic() throws Exception {
final String ns = "prop/ns-test";
admin.namespaces().createNamespace(ns, 2);
NamespaceEventsSystemTopicFactory systemTopicFactory = new NamespaceEventsSystemTopicFactory(pulsarClient);
TopicPoliciesSystemTopicClient systemTopicClientForNamespace = systemTopicFactory
.createTopicPoliciesSystemTopicClient(NamespaceName.get(ns));
SystemTopicClient.Reader reader = systemTopicClientForNamespace.newReader();

int partitions = admin.topics().getPartitionedTopicMetadata(
String.format("persistent://%s/%s", ns, SystemTopicNames.NAMESPACE_EVENTS_LOCAL_NAME)).partitions;
List<String> partitionedTopicList = admin.topics().getPartitionedTopicList(ns,
ListTopicsOptions.builder().includeSystemTopic(true).build());
Assert.assertEquals(partitionedTopicList.size(), 1);
Assert.assertEquals(partitions, PARTITIONS);
Assert.assertEquals(admin.topics().getList(ns, null,
ListTopicsOptions.builder().includeSystemTopic(true).build()).size(), PARTITIONS);
Assert.assertEquals(partitions, 0);
reader.close();
}

Expand Down