Skip to content

Commit b335e5b

Browse files
committed
Compatible with existing designs as much as possible
Signed-off-by: Zixuan Liu <[email protected]>
1 parent 5935c9b commit b335e5b

File tree

1 file changed

+12
-49
lines changed

1 file changed

+12
-49
lines changed

Diff for: pip/pip-398.md

+12-49
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,11 @@ to the broker, namespace and topic levels, the system reduces the need for expli
2727
The PIP aims to provide management of subscription replication at the broker, namespace and topic levels using the
2828
Pulsar Admin CLI and API.
2929

30-
# Out scope
31-
32-
This feature depends on https://github.com/apache/pulsar/pull/23757, which makes the subscription replication nullable
33-
on the consumer level. Otherwise, the broker, namespace and topic levels will be ignored.
34-
3530
# High Level Design
3631

3732
Introduces a configuration used for enabling subscription replication on the broker, namespace and topic levels, when
38-
enabled, all consumers under the topic will automatically replicate their subscription states to remote clusters.
33+
enabled, all consumers under the broker/namespace/topic will automatically replicate their subscription states to remote
34+
clusters.
3935

4036
The priority for the subscription replication configuration is as follows:
4137

@@ -108,39 +104,25 @@ public class ServiceConfiguration implements PulsarConfiguration {
108104

109105
### Consumer level
110106

111-
We currently support the `replicateSubscriptionState` flag for new subscription at the consumer level, which can be set
112-
to `true` or `false`. If `true`, we persist `pulsar.replicated.subscription=1L` to the cursor properties, and if
113-
`false`, we remove that.
114-
115-
To keep the consumer-level configuration, we need to consider the `false` case, so propose using
116-
`pulsar.replicated.subscription=0L` instead of removing the property.
117-
118-
The consumer-level configuration takes precedence over both the topic, broker and namespace levels, ensuring that
119-
consumer-specific configurations can still override the more general settings.
107+
No changes. When the consumer with `replicateSubscriptionState=true`, the old/new subscription will be snapshot. If `false`, no operation will
108+
be performed.
120109

121110
### Subscription replication applied
122111

123112
When the subscription replication is changed on the broker, namespace or topic level, the subscription replication will
124-
be applied to all consumers under the topic.
113+
be applied to all consumers under the broker/namespace/topic.
125114

126-
Please notice that the `org.apache.pulsar.client.admin.Topics.setReplicatedSubscriptionStatus()` can override the
127-
subscription replication configuration for the special subscription, and equals the consumer level.
115+
We exclusively consider the `true` case for replication. If the consumer level is set to `false`, the
116+
replication configuration defined at the topic, namespace, or broker level will be applied to the subscription.
117+
118+
There is a special case here, if the user intentionally sets `false` at the consumer level, and then set `true` at the
119+
topic/ns/broker level, this may disrupt the user's behavior. This way, we can minimize changes to the Pulsar public API
120+
as much as possible.
128121

129122
## Public-facing Changes
130123

131124
### Public API
132125

133-
### Client API
134-
135-
Change the set replicated subscription status method in the `org.apache.pulsar.client.admin.Topics` interface to accept the `Boolean` type:
136-
137-
```java
138-
void setReplicatedSubscriptionStatus(String topic, String subName, Boolean enabled) throws PulsarAdminException;
139-
CompletableFuture<Void> setReplicatedSubscriptionStatusAsync(String topic, String subName, Boolean enabled);
140-
```
141-
142-
#### REST API
143-
144126
##### Namespace level
145127

146128
- `/{tenant}/{namespace}/replicateSubscriptionState`: enable/disable/remove the subscription replication on the
@@ -181,8 +163,6 @@ CompletableFuture<Void> setReplicatedSubscriptionStatusAsync(String topic, Strin
181163
- true
182164
- false
183165
- null
184-
- `/{tenant}/{namespace}/{topic}/subscription/{subName}/replicatedSubscriptionStatus`: Change the body type from boolean
185-
to Boolean.
186166

187167
### CLI
188168

@@ -203,10 +183,6 @@ CompletableFuture<Void> setReplicatedSubscriptionStatusAsync(String topic, Strin
203183
subscription replication configuration on the topic level.
204184
- `pulsar-admin topicPolicies remove-replicate-subscription-state <tenant>/<namespace>/<topic>` to remove the
205185
subscription replication configuration on the topic level.
206-
- `pulsar-admin topicPolicies remove-replicate-subscription-state <tenant>/<namespace>/<topic>` to remove the
207-
subscription replication configuration on the topic level.
208-
- `pulsar-admin topics remove-replicated-subscription-status <tenant>/<namespace>/<topic>` to remove the
209-
subscription replication configuration on the consumer(subscription) level.
210186

211187
# Security Considerations
212188

@@ -230,20 +206,7 @@ Both write and read operations require the necessary permissions, which already
230206

231207
## Upgrade
232208

233-
Because the consumer's `replicateSubscriptionSate=false` does not persist to the cursor properties, it leads to
234-
compatibility issues:
235-
236-
- When the existing subscription with `replicateSubscriptionSate=false` on the consumer level, which uses the policy
237-
from the topic, namespace, or broker level. If you want to use the initial configuration, please use the pulsar-admin
238-
API orCLI:
239-
- CLI
240-
```shell
241-
bin/pulsar-admin topics set-replicated-subscription-status <tenant>/<namespace>/<topic> -s <subName> --disable
242-
```
243-
- API
244-
```java
245-
admin.topics().setReplicatedSubscriptionStatus(topic, subName, false);
246-
```
209+
None.
247210

248211
## Downgrade / Rollback
249212

0 commit comments

Comments
 (0)