-
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
[pulsar-admin] Add remove-subscription-types-enabled command for topic #12983
[pulsar-admin] Add remove-subscription-types-enabled command for topic #12983
Conversation
@yuruguo:Thanks for your contribution. For this PR, do we need to update docs? |
@yuruguo:Thanks for providing doc info! |
if (!op.isPresent()) { | ||
return CompletableFuture.completedFuture(null); | ||
} | ||
op.get().setSubscriptionTypesEnabled(Lists.newArrayList()); |
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 should not modify a object that could be the result of a read from a cache
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.
Sorry, I don't fully understand what you mean. I'm still a little confused about it. Can you give me more information?
I understand that this is the process of making TopicPolicies.subscriptionTypesEnabled
as empty list
(default initial value), right?
Maybe according to your meaning, how should I modify it?
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.
you are using the returned object from getTopicPoliciesAsyncWithRetry
using op.get()
if pulsar().getTopicPoliciesService().updateTopicPoliciesAsync
fails then the local copy of the variable in memory is update but the value is not write to persistent metadata storage.
We should copy/clone the object and not mutate it.
It would be better to have "immutable" objects, but that would be another story
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.
Many topic policy set
&remove
operations are implemented in this way, so they all need to be adjusted, as below:
pulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
Lines 3012 to 3020 in aa97d39
protected CompletableFuture<Void> internalSetPersistence(PersistencePolicies persistencePolicies) { | |
validatePersistencePolicies(persistencePolicies); | |
return getTopicPoliciesAsyncWithRetry(topicName) | |
.thenCompose(op -> { | |
TopicPolicies topicPolicies = op.orElseGet(TopicPolicies::new); | |
topicPolicies.setPersistence(persistencePolicies); | |
return pulsar().getTopicPoliciesService().updateTopicPoliciesAsync(topicName, topicPolicies); | |
}); | |
} |
pulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
Lines 3022 to 3031 in aa97d39
protected CompletableFuture<Void> internalRemovePersistence() { | |
return getTopicPoliciesAsyncWithRetry(topicName) | |
.thenCompose(op -> { | |
if (!op.isPresent()) { | |
return CompletableFuture.completedFuture(null); | |
} | |
op.get().setPersistence(null); | |
return pulsar().getTopicPoliciesService().updateTopicPoliciesAsync(topicName, op.get()); | |
}); | |
} |
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.
Thanks for your guidance, I will create an issue to track this problem and try to submit a PR to solve it :) |
Motivation
CLI
bin/pulsar-admin topics
supportsset-subscription-types-enabled
andget-subscription-types-enabled
command, but lacks correspondingremove-subscription-types-enabled
commands, the purpose of this PR is to add this command for topic.Documentation
Automatically generate doc through code
doc