-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[improve][broker]Create missed subscriptions for createMissedPartitions #17946
base: master
Are you sure you want to change the base?
[improve][broker]Create missed subscriptions for createMissedPartitions #17946
Conversation
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
Outdated
Show resolved
Hide resolved
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.
LGTM, Can we add a unit test to verify this?
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
Outdated
Show resolved
Hide resolved
f9c629a
to
a3a4801
Compare
OK, have update UT, PTAL @Jason918 |
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.
LGTM
result.completeExceptionally(e1); | ||
return result; | ||
} | ||
admin.topics().getStatsAsync(topicName.getPartition(0).toString()).thenAccept(stats -> { |
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.
Nice catch!
The partition-0 maybe also created by the CreateMissedPartitions
, I think we should list the subscriptions of the partitioned topic.
And for Pulsar, users can subscription to a specific partition, which means partition-0, partition-1 might have different subscriptions.
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.
The partition-0 maybe also created by the
CreateMissedPartitions
, I think we should list the subscriptions of the partitioned topic.And for Pulsar, users can subscription to a specific partition, which means partition-0, partition-1 might have different subscriptions.
I think we can add a parameter to specify the subscription name list to be created, which can solve these two problems at the same time. How about this?
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.
@Pomelongan For the second one, it's not a problem. The partitions can have different subscriptions. The challenge is that we don't have subscriptions for the partitioned topic, right?
Hmmm, IMO, we can update the documentation to remind the user that "If you found the partitions is missed, you should use create missed partitions command to fix the missed partition issue and try to subscribe to the partitioned topic again to repair the part of the subscription missed issue"
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.
The challenge is that we don't have subscriptions for the partitioned topic, right?
@codelipenghui Yes, adding a parameter to specify the subscription list to be created can solve this problem. I have updated the code,PTAL
Hmmm, IMO, we can update the documentation to remind the user that "If you found the partitions is missed, you should use create missed partitions command to fix the missed partition issue and try to subscribe to the partitioned topic again to repair the part of the subscription missed issue"
Okay, I have updated the document.
f03b282
to
42fe79e
Compare
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
Outdated
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
Outdated
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
Outdated
Show resolved
Hide resolved
pulsar-client-tools-test/src/test/java/org/apache/pulsar/admin/cli/PulsarAdminToolTest.java
Show resolved
Hide resolved
pulsar-broker/src/test/java/org/apache/pulsar/client/api/PartitionCreationTest.java
Outdated
Show resolved
Hide resolved
pulsar-broker/src/test/java/org/apache/pulsar/client/api/PartitionCreationTest.java
Outdated
Show resolved
Hide resolved
42fe79e
to
10a7fa9
Compare
I have updated based on comments.PTAL @AnonHxy |
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
Outdated
Show resolved
Hide resolved
9f8e471
to
0a112d1
Compare
pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/NamespaceResources.java
Outdated
Show resolved
Hide resolved
0a112d1
to
5fdb237
Compare
for (int i = 0; i < numPartitions; i++) { | ||
CompletableFuture<Void> future = new CompletableFuture<>(); | ||
admin.topics().createSubscriptionAsync(topicName.getPartition(i).toString(), subscription, | ||
MessageId.latest).whenComplete((__, ex) -> { | ||
if (ex == null) { | ||
future.complete(null); | ||
} else { | ||
if (ex instanceof PulsarAdminException.ConflictException) { | ||
future.complete(null); | ||
} else { | ||
future.completeExceptionally(ex); | ||
} | ||
} | ||
}); | ||
subscriptionFutures.add(future); | ||
} |
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.
We have internalCreateSubscription
method which will handle the subscription creation. Can we just use the existing method to avoid duplicated code?
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.
@codelipenghui Okay~I have updated, PTAL.
Calling internalCreateSubscription
directly requires implementing the AsyncResponse interface first, which is troublesome. So I try to extract the common part of the two methods to avoid duplicated code.
5fdb237
to
e12b53e
Compare
e12b53e
to
a10b126
Compare
…ase#internalCreateMissedPartitions
…csBase#internalCreateMissedPartitions
a10b126
to
bb53b1e
Compare
The pr had no activity for 30 days, mark with Stale label. |
Motivation
org.apache.pulsar.broker.admin.impl.PersistentTopicsBase#internalCreateMissedPartitions
lacks the logic to create subscriptions.Modifications
org.apache.pulsar.broker.admin.impl.PersistentTopicsBase#createMissedSubscriptionsAsync
org.apache.pulsar.broker.admin.impl.PersistentTopicsBase#internalCreateMissedPartitions
Verifying this change
This change is a trivial rework / code cleanup without any test coverage.
Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes
Documentation
doc
doc-required
doc-not-needed
doc-complete
Matching PR in forked repository
PR in forked repository: Pomelongan#9