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

[improve][broker]Create missed subscriptions for createMissedPartitions #17946

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

Pomelongan
Copy link
Contributor

@Pomelongan Pomelongan commented Oct 5, 2022

Motivation

org.apache.pulsar.broker.admin.impl.PersistentTopicsBase#internalCreateMissedPartitions lacks the logic to create subscriptions.

Modifications

  • add org.apache.pulsar.broker.admin.impl.PersistentTopicsBase#createMissedSubscriptionsAsync
  • add the logic for creating missed subscriptions for org.apache.pulsar.broker.admin.impl.PersistentTopicsBase#internalCreateMissedPartitions

Verifying this change

  • Make sure that the change passes the CI checks.

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

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

Documentation

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

Matching PR in forked repository

PR in forked repository: Pomelongan#9

Copy link
Contributor

@Jason918 Jason918 left a 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?

@Pomelongan Pomelongan force-pushed the update_createMissedPartitions branch from f9c629a to a3a4801 Compare October 8, 2022 09:15
@Pomelongan
Copy link
Contributor Author

LGTM, Can we add a unit test to verify this?

OK, have update UT, PTAL @Jason918

Copy link
Contributor

@Jason918 Jason918 left a comment

Choose a reason for hiding this comment

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

LGTM

@Jason918 Jason918 added type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages area/broker labels Oct 10, 2022
@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Oct 10, 2022
@Jason918 Jason918 added this to the 2.12.0 milestone Oct 10, 2022
result.completeExceptionally(e1);
return result;
}
admin.topics().getStatsAsync(topicName.getPartition(0).toString()).thenAccept(stats -> {
Copy link
Contributor

@codelipenghui codelipenghui Oct 10, 2022

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.

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 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?

Copy link
Contributor

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"

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

@Pomelongan Pomelongan force-pushed the update_createMissedPartitions branch 2 times, most recently from f03b282 to 42fe79e Compare October 18, 2022 11:48
@github-actions github-actions bot added doc-complete Your PR changes impact docs and the related docs have been already added. and removed doc-not-needed Your PR changes do not impact docs labels Oct 18, 2022
@Pomelongan Pomelongan force-pushed the update_createMissedPartitions branch from 42fe79e to 10a7fa9 Compare October 19, 2022 03:00
@Pomelongan
Copy link
Contributor Author

I have updated based on comments.PTAL @AnonHxy

@AnonHxy AnonHxy changed the title [improve][broker]add the logic for creating missed subscriptions for createMissedPartitions [improve][broker]Create missed subscriptions for createMissedPartitions Oct 19, 2022
@Pomelongan Pomelongan force-pushed the update_createMissedPartitions branch 2 times, most recently from 9f8e471 to 0a112d1 Compare October 21, 2022 08:49
@Pomelongan Pomelongan force-pushed the update_createMissedPartitions branch from 0a112d1 to 5fdb237 Compare October 31, 2022 06:58
Comment on lines 4592 to 4607
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);
}
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@Pomelongan Pomelongan force-pushed the update_createMissedPartitions branch from 5fdb237 to e12b53e Compare November 3, 2022 15:49
@Pomelongan Pomelongan force-pushed the update_createMissedPartitions branch from e12b53e to a10b126 Compare November 4, 2022 05:59
@Pomelongan Pomelongan force-pushed the update_createMissedPartitions branch from a10b126 to bb53b1e Compare November 12, 2022 09:01
@github-actions
Copy link

The pr had no activity for 30 days, mark with Stale label.

@github-actions github-actions bot added the Stale label Dec 13, 2022
@poorbarcode poorbarcode modified the milestones: 3.0.0, 3.1.0 Apr 10, 2023
@Technoboy- Technoboy- modified the milestones: 3.1.0, 3.2.0 Jul 31, 2023
@Technoboy- Technoboy- modified the milestones: 3.2.0, 3.3.0 Dec 22, 2023
@coderzc coderzc modified the milestones: 3.3.0, 3.4.0 May 8, 2024
@lhotari lhotari modified the milestones: 4.0.0, 4.1.0 Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/broker doc-complete Your PR changes impact docs and the related docs have been already added. Stale type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants