[improve][pip] PIP-398: Subscription replication on the broker, namespace and topic levels#23770
[improve][pip] PIP-398: Subscription replication on the broker, namespace and topic levels#23770nodece wants to merge 7 commits intoapache:masterfrom
Conversation
#23769 aims to overwrite the subscription replication state from the consumer, which is different from this PIP. Actually, I also need an overwrite feature, and then the users use the admin API to manage the subscription replication. The downstream users sometimes enable/disable the subscription replication on the consumer, this lead to the namespace or topic level is ignored. We can also merge #23769 to this PIP. What's your opinion? @lhotari @yyj8 |
@nodece @yyj8 Please work together to combine both cases since they are both valuable and useful. I think it would make |
This is a great idea and suggestion. Can we consider a strategy that divides into three dimensions: cluster dimension, namespace dimension, and topic dimension. |
Once the consumer level is configured, it is the highest priority, the cluster, namespace, and topic levels will be ignored, please see #23769 (comment) for details.
This is feasible. |
The default configuration for the client is My suggestion is to configure the cluster dimension. If |
The latest client defaults to
I understand your idea, this can make all subscriptions replicated when However, this idea conflicts with PIP-398, which assumes that the consumer-level configuration for In our case, I don't want to configure the My ideaTo combine your case and my case, I suggest introducing a broker configuration for overwriting the consume configuration, and assuming the namespace and topic level are set, the final result will be so like this:
We can also introduce |
73a4da4 to
4e7ee76
Compare
@nodece I agree with your suggestion. Then we can make unified code adjustments on your pip, or you can directly merge my code into your code, or after you submit the code, I can synchronize your code and modify the cluster level configuration before submitting. |
@yyj8 Correct. The Breaking Change: For an existing subscription where The new subscription will follow the above priority. /cc @lhotari |
cd4d790 to
c421642
Compare
|
@yyj8 This PIP has been updated, could you have a chance to review this PIP? |
Are you referring to updating the code and modifying the functional design specifications in this pip pip/pip-398.md design documentation? |
Just for this PIP. |
… topic levels Signed-off-by: Zixuan Liu <nodeces@gmail.com>
Signed-off-by: Zixuan Liu <nodeces@gmail.com>
c421642 to
9a493a9
Compare
Signed-off-by: Zixuan Liu <nodeces@gmail.com>
9a493a9 to
b335e5b
Compare
|
The term |
Signed-off-by: Zixuan Liu <nodeces@gmail.com>
"replicating the subscription state" is correct. This term is from the design of existing consumer. |
|
@lhotari Do you have more suggestions? If not, I will send a vote to the mailing list. |
@nodece I think that at the topic and namespace level, it could be better to combine
I don't know if this is accurate, but putting more thought in how to address the topic and namespace level would be useful. I haven't seen the APIs being updated to have this information in the policies. I don't think that introducing a completely separate concept for topic and namespace level makes sense. |
|
This is an important section: https://github.com/apache/pulsar/pull/23770/files#diff-67fc7a48cc071911c2239d1c628335d4147f54345051f36efd2f18dbcc8339c6R110 Since the consumer enables the subscription replication when the Prioritizing Another thing is that we did not persist the case where
The |
@nodece Yes, I understand that. Isn't there a need to override any client application consumer level setting with topic or namespace level policies? What if Pulsar administrator would explicitly want to disallow or force using replicated subscriptions for a particular topic or namespace while geo-replication is enabled? |
When the topic/namespace level is true, the consumer level will be ignored. Usually, we want to enable the subscription replication, not disable.
The administrator is permitted to enable the subscription replication and subsequently disable it. |
Signed-off-by: Zixuan Liu <nodeces@gmail.com>
|
@nodece Do you have plans to take this PIP forward? |
|
@lhotari Vote has been started. |
| 1. Add the field `Boolean replicate_subscriptions_state` to the `org.apache.pulsar.common.policies.data.Policies` class | ||
| to control subscription replication at the namespace level: | ||
| ```java | ||
| public class Policies { | ||
| @SuppressWarnings("checkstyle:MemberName") | ||
| public Boolean replicate_subscription_state; | ||
| } | ||
| ``` | ||
| 2. Add the management methods to the `org.apache.pulsar.client.admin.Namespaces` interface: | ||
| ```java | ||
| public interface Namespaces { | ||
| void setReplicateSubscriptionState(String namespace, Boolean enabled) throws PulsarAdminException; | ||
| CompletableFuture<Void> setReplicateSubscriptionStateAsync(String namespace, Boolean enabled); | ||
| Boolean getReplicateSubscriptionState(String namespace) throws PulsarAdminException; | ||
| CompletableFuture<Boolean> getReplicateSubscriptionStateAsync(String namespace); | ||
| } | ||
| ``` | ||
| 3. Implement the management methods in the `org.apache.pulsar.client.admin.internal.NamespacesImpl` class. | ||
|
|
||
| ### Topic level | ||
|
|
||
| 1. Add the field `Boolean replicateSubscriptionState` to the `org.apache.pulsar.common.policies.data.TopicPolicies` | ||
| class to enable subscription replication at the topic level: | ||
| ```java | ||
| public class TopicPolicies { | ||
| public Boolean replicateSubscriptionState; | ||
| } | ||
| ``` | ||
| 2. Add the management methods to the `org.apache.pulsar.client.admin.TopicPolicies` interface: | ||
| ```java | ||
| public interface TopicPolicies { | ||
| void setReplicateSubscriptionState(String topic, Boolean enabled) throws PulsarAdminException; | ||
| CompletableFuture<Void> setReplicateSubscriptionStateAsync(String topic, Boolean enabled); | ||
| Boolean getReplicateSubscriptionState(String topic, boolean applied) throws PulsarAdminException; | ||
| CompletableFuture<Boolean> getReplicateSubscriptionStateAsync(String topic, boolean applied); | ||
| } |
There was a problem hiding this comment.
I would strongly suggest replacing the Boolean with an enum. Using a boolean value for replicateSubscriptionState is very confusing.
Here's an example what ReplicateSubscriptionStatePolicy enum could be:
OVERRIDE_ENABLE- overrides any value set by the consumer (or lower level policy) and enables subscription replicationOVERRIDE_DISABLE- overrides any value set by the consumer (or lower level policy) and disables subscription replicationENABLE- enables subscription replication if not explicitly disabled by the consumer (or lower level policy)DISABLE- disables subscription replication if not explicitly enabled by the consumer (or lower level policy)
There was a problem hiding this comment.
We have a pulsar-admin topics set-replicated-subscription-status command, the current implementation uses Boolean for similar that, so I followed the same design for consistency and to avoid introducing a new pattern in the CLI/API.
The meaning is:
- null → remove configuration(I can add a remove api instead of this, and then use boolean instead of Boolean in set API)
- true → enable
- false → disable (but true has priority if both are set in the different levels)
Using an enum would make the meaning explicit, but it introduces additional complexity.
There was a problem hiding this comment.
We have a
pulsar-admin topics set-replicated-subscription-statuscommand, the current implementation uses Boolean for similar that, so I followed the same design for consistency and to avoid introducing a new pattern in the CLI/API.
This is a valid argument if we are able to achieve all required use cases with a Boolean.
After thinking about it again, it seems that these choices need to be covered:
- override any setting by the consumer (or lower level policy) and enable subscription replication for all subscriptions
- override any setting by the consumer (or lower level policy) and disable subscription replication for all subscriptions
- enable subscription replication if not explicitly disabled by the consumer (or lower level policy) for all subscriptions
- no setting at all (higher level setting would take priority). If all policies (broker, ns, topic) are "empty", the consumer setting would get used directly.
@nodece With a single Boolean value, how would you distinguish between the 2 different cases (1. and 3. above) where subscription replication is enabled?
(with "lower level policy", it means the hierarchy of broker -> namespace -> topic)
There was a problem hiding this comment.
@nodece With a single
Booleanvalue, how would you distinguish between the 2 different cases (1. and 3. above) where subscription replication is enabled?
override any setting by the consumer (or lower level policy) and enable subscription replication for all subscriptions
Subscription replication is enabled if:
- The consumer sets true
- The first non-null policy found in the following order is true: topic → namespace → broker. Once a policy is found (even if false), lower levels are ignored.
no setting at all (higher level setting would take priority). If all policies (broker, ns, topic) are "empty", the consumer setting would get used directly.
Correct.
I understand the concern about using null for removing the setting. To make the semantics clearer, I'll add an explicit removeReplicateSubscriptionState() API instead of relying on null.
So no need to worry about Boolean vs boolean, the new API will handle the unset case explicitly.
@nodece I added a request for changes for the |
Motivation
Enhance the subscription replication.
Documentation
docdoc-requireddoc-not-neededdoc-complete