Skip to content
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

[fix][broker] pre-create non-partitioned system topics for load balance extension #20370

Merged
merged 2 commits into from
May 24, 2023

Conversation

heesung-sn
Copy link
Contributor

PIP: #16691

Motivation

We need to create system topics without partitions explicitly. Currently, we do not support partitioned system topics.

Modifications

create system topics without partitions explicitly

Verifying this change

  • Make sure that the change passes the CI checks.

(Please pick either of the following options)

This change is already covered by existing tests, such as (please describe tests).

Does this pull request potentially affect one of the following parts:

If the box was checked, please highlight the changes

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository:

@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label May 23, 2023
@Demogorgon314 Demogorgon314 self-requested a review May 23, 2023 04:30
@poorbarcode
Copy link
Contributor

@heesung-sn

Since this patch fixes a bug, can we add a test to reproduce it which the current PR fixed?

@heesung-sn
Copy link
Contributor Author

@heesung-sn

Since this patch fixes a bug, can we add a test to reproduce it which the current PR fixed?

conflictAndCompactionTest with this config covers this case.
ServiceUnitStateChannelTest.java

Copy link
Member

@michaeljmarshall michaeljmarshall left a comment

Choose a reason for hiding this comment

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

We need to create system topics without partitions explicitly. Currently, we do not support partitioned system topics.

Is this documented anywhere? It makes sense to me, but it seems like an important implementation detail.

@@ -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 {
Copy link
Member

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 public and static? It seems like it should be private since it is used only within an instance of this class.

Copy link
Contributor Author

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.

Copy link
Member

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.

@heesung-sn
Copy link
Contributor Author

heesung-sn commented May 23, 2023

We need to create system topics without partitions explicitly. Currently, we do not support partitioned system topics.

Is this documented anywhere? It makes sense to me, but it seems like an important implementation detail.

I added a comment in the pip, #16691 (comment)

This partitioned system topics has been scoped out in the first iteration(as we don't see strong demand for this), but to support really large clusters, we(or anybody) could easily expand the current behavior and support partitioned system topics with multi-leaders.

@heesung-sn
Copy link
Contributor Author

/pulsarbot rerun-failure-checks

1 similar comment
@heesung-sn
Copy link
Contributor Author

/pulsarbot rerun-failure-checks

@@ -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);
Copy link
Member

Choose a reason for hiding this comment

The 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

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

https://github.com/apache/pulsar/blob/master/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/ExtensibleLoadManagerImpl.java#L239-L240

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for confirming.

@codecov-commenter
Copy link

Codecov Report

Merging #20370 (11f217b) into master (548fd22) will increase coverage by 36.08%.
The diff coverage is 83.33%.

Impacted file tree graph

@@              Coverage Diff              @@
##             master   #20370       +/-   ##
=============================================
+ Coverage     36.89%   72.97%   +36.08%     
- Complexity    12053    31895    +19842     
=============================================
  Files          1687     1864      +177     
  Lines        128826   138397     +9571     
  Branches      14013    15184     +1171     
=============================================
+ Hits          47528   100999    +53471     
+ Misses        75040    29397    -45643     
- Partials       6258     8001     +1743     
Flag Coverage Δ
inttests 24.16% <0.00%> (-0.01%) ⬇️
systests 24.98% <0.00%> (-0.19%) ⬇️
unittests 72.23% <83.33%> (+40.28%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...dbalance/extensions/ExtensibleLoadManagerImpl.java 78.67% <81.81%> (+76.29%) ⬆️
...xtensions/channel/ServiceUnitStateChannelImpl.java 83.27% <100.00%> (+82.72%) ⬆️

... and 1430 files with indirect coverage changes

@@ -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);
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for confirming.

@michaeljmarshall michaeljmarshall merged commit 1080ad5 into apache:master May 24, 2023
poorbarcode pushed a commit that referenced this pull request May 30, 2023
…ce extension (#20370)

PIP: #16691

### Motivation

We need to create system topics without partitions explicitly. Currently, we do not support partitioned system topics.

### Modifications

 create system topics without partitions explicitly

(cherry picked from commit 1080ad5)
@heesung-sn heesung-sn deleted the pip-192-topic-pre-create branch April 2, 2024 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants