Repository navigation
[fix][broker] pre-create non-partitioned system topics for load balance extension #20370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -79,6 +79,7 @@ | |
| import org.apache.pulsar.broker.loadbalance.extensions.strategy.LeastResourceUsageWithWeight; | ||
| import org.apache.pulsar.broker.loadbalance.impl.LoadManagerShared; | ||
| import org.apache.pulsar.broker.loadbalance.impl.SimpleResourceAllocationPolicies; | ||
| import org.apache.pulsar.client.admin.PulsarAdminException; | ||
| import org.apache.pulsar.common.naming.NamespaceBundle; | ||
| import org.apache.pulsar.common.naming.NamespaceBundleSplitAlgorithm; | ||
| import org.apache.pulsar.common.naming.NamespaceName; | ||
|
|
@@ -213,6 +214,19 @@ public static boolean debug(ServiceConfiguration config, Logger log) { | |
| return config.isLoadBalancerDebugModeEnabled() || log.isDebugEnabled(); | ||
| } | ||
|
|
||
| public static void createSystemTopic(PulsarService pulsar, String topic) throws PulsarServerException { | ||
| try { | ||
| pulsar.getAdminClient().topics().createNonPartitionedTopic(topic); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What are the consequences of spurious failures here. Does an error lead the broker to need to restart? Also, how does this work in a system where there is just one broker running in a new cluster? I have not kept up with the load balancing work, but is there any chance of deadlock because creating this topic early requires a leader to already be selected? If this is covered by other documentation, definitely just point me to it. Thanks
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The broker needs to restart when an exception is thrown here. We elect the leader before creating this system topic.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for confirming. |
||
| log.info("Created topic {}.", topic); | ||
| } catch (PulsarAdminException.ConflictException ex) { | ||
| if (debug(pulsar.getConfiguration(), log)) { | ||
| log.info("Topic {} already exists.", topic, ex); | ||
|
michaeljmarshall marked this conversation as resolved.
Resolved
|
||
| } | ||
| } catch (PulsarAdminException e) { | ||
| throw new PulsarServerException(e); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void start() throws PulsarServerException { | ||
| if (this.started) { | ||
|
|
@@ -247,6 +261,9 @@ public void start() throws PulsarServerException { | |
| this.isolationPoliciesHelper = new IsolationPoliciesHelper(policies); | ||
| this.brokerFilterPipeline.add(new BrokerIsolationPoliciesFilter(isolationPoliciesHelper)); | ||
|
|
||
| createSystemTopic(pulsar, BROKER_LOAD_DATA_STORE_TOPIC); | ||
| createSystemTopic(pulsar, TOP_BUNDLES_LOAD_DATA_STORE_TOPIC); | ||
|
|
||
| try { | ||
| this.brokerLoadDataStore = LoadDataStoreFactory | ||
| .create(pulsar.getClient(), BROKER_LOAD_DATA_STORE_TOPIC, BrokerLoadData.class); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: why is this method
publicandstatic? It seems like it should beprivatesince it is used only within an instance of this class.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is used in ServiceUnitStateChannel, too, to create a system topic inside ServiceUnitStateChannel.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, I missed that reference. I still worry about misuse of this method because it is public and static--it's probably not a large concern though.