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

[Issue 6043] Support force deleting subscription #6383

Merged
merged 6 commits into from
Mar 25, 2020

Conversation

murong00
Copy link
Contributor

Motivation

Fixes #6043

Modifications

Add method deleteForcefully to support force deleting subscription.

@murong00 murong00 requested review from sijie, massakam and rdhabalia and removed request for massakam February 21, 2020 04:03
@sijie sijie added this to the 2.6.0 milestone Feb 22, 2020
Copy link
Contributor

@codelipenghui codelipenghui left a comment

Choose a reason for hiding this comment

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

@murong00 Currently we don't have a flag to control to enable or disable the subscription auto-creation, and subscription auto-creation is enabled by default. So, if the subscription that has some active consumers, then delete the subscription forcefully, the subscription will create again when the consumer reconnects to the broker. Looks we'd better expose the ability for users to disable the subscription auto-creation.

admin.topics().deleteSubscription(persistentTopicName, subName, true);

// delete the subscription successfully
assertEquals(admin.topics().getSubscriptions(persistentTopicName).size(), 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

This will be a flaky test since the consumer can create a subscription when they reconnect to the broker.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, maybe we can disable this line in this pr first and then refine it later when the ability to disable the subscription auto-creation is available?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I hava fixed the unit test to cover this.

@murong00
Copy link
Contributor Author

@codelipenghui yes, I hava already opened an issue (#6394) to track this, I am planning to fix it by a seperated pull request.

@murong00
Copy link
Contributor Author

@codelipenghui please help to review again, thanks.

@murong00
Copy link
Contributor Author

murong00 commented Mar 5, 2020

@codelipenghui @sijie @jiazhai Since #6394 is already fixed, I hava refined the unit test. Please help to review it again, thanks.

Copy link
Contributor

@codelipenghui codelipenghui left a comment

Choose a reason for hiding this comment

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

Left some comments, please take a look.

}

private void internalDeleteSubscriptionForNonPartitionedTopicForcefully(AsyncResponse asyncResponse, String subName, boolean authoritative) {
validateAdminAccessForSubscriber(subName, authoritative);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should handle exception here since we need to resume the asyncResponse

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

if (topicName.isPartitioned()) {
internalDeleteSubscriptionForNonPartitionedTopicForcefully(asyncResponse, subName, authoritative);
} else {
PartitionedTopicMetadata partitionMetadata = getPartitionedTopicMetadata(topicName, authoritative, false);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should handle exception here since we need to resume the asyncResponse

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

@codelipenghui
Copy link
Contributor

@murong00 There are some problems related to the async method in PersistentTopicsBase.java. I have sent a PR #6483 to fix them, please also help take a look.

@murong00
Copy link
Contributor Author

murong00 commented Mar 6, 2020

@codelipenghui ok, I will refine this pr after #6483 is merged.

@murong00
Copy link
Contributor Author

murong00 commented Mar 8, 2020

@codelipenghui I hava addressed your comments, please help to take a look.

*
* @return a future that can be used to track when the subscription is deleted
*/
CompletableFuture<Void> deleteSubscriptionAsync(String topic, String subName);
CompletableFuture<Void> deleteSubscriptionAsync(String topic, String subName, boolean force);
Copy link
Member

Choose a reason for hiding this comment

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

This is an API breaking change. You can't directly change the method signature. Please add an override method.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added, thanks.

@murong00
Copy link
Contributor Author

@sijie Please help to review this again, thanks.

@sijie sijie merged commit 525f9e9 into apache:master Mar 25, 2020
huangdx0726 pushed a commit to huangdx0726/pulsar that referenced this pull request Aug 24, 2020
### Motivation

Fixes apache#6043

### Modifications

Add method `deleteForcefully` to support force deleting subscription.
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.

How to force delete subscribers
3 participants