poorbarcode commented on code in PR #21495:
URL: https://github.com/apache/pulsar/pull/21495#discussion_r1381313726
##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/ReplicatorSubscriptionTest.java:
##########
@@ -704,6 +705,53 @@ public void
testReplicatedSubscriptionWhenReplicatorProducerIsClosed() throws Ex
Awaitility.await().untilAsserted(() ->
assertNotNull(topic2.getSubscription(subscriptionName)));
}
+ @Test
+ public void testReplicateSubBackLog() throws Exception {
Review Comment:
Please add another test:
- Enable replication
- Pub&Sub messages
- Disabled replication
- Ensure the Replicated Subscription Controller has been closed
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java:
##########
@@ -3476,12 +3476,14 @@ private synchronized void
checkReplicatedSubscriptionControllerState(boolean sho
boolean isCurrentlyEnabled =
replicatedSubscriptionsController.isPresent();
boolean isEnableReplicatedSubscriptions =
brokerService.pulsar().getConfiguration().isEnableReplicatedSubscriptions();
+ boolean isReplicationDisEnable =
this.topicPolicies.getReplicationClusters().get().size() == 1;
Review Comment:
```suggestion
boolean replicationEnabled =
this.topicPolicies.getReplicationClusters().get().size() > 1;
```
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java:
##########
@@ -3476,12 +3476,14 @@ private synchronized void
checkReplicatedSubscriptionControllerState(boolean sho
boolean isCurrentlyEnabled =
replicatedSubscriptionsController.isPresent();
boolean isEnableReplicatedSubscriptions =
brokerService.pulsar().getConfiguration().isEnableReplicatedSubscriptions();
+ boolean isReplicationDisEnable =
this.topicPolicies.getReplicationClusters().get().size() == 1;
- if (shouldBeEnabled && !isCurrentlyEnabled &&
isEnableReplicatedSubscriptions) {
+ if (shouldBeEnabled && !isCurrentlyEnabled &&
isEnableReplicatedSubscriptions && !isReplicationDisEnable) {
log.info("[{}] Enabling replicated subscriptions controller",
topic);
replicatedSubscriptionsController = Optional.of(new
ReplicatedSubscriptionsController(this,
brokerService.pulsar().getConfiguration().getClusterName()));
- } else if (isCurrentlyEnabled && !shouldBeEnabled ||
!isEnableReplicatedSubscriptions) {
+ } else if (isCurrentlyEnabled && !shouldBeEnabled ||
!isEnableReplicatedSubscriptions
+ || isReplicationDisEnable) {
log.info("[{}] Disabled replicated subscriptions controller",
topic);
replicatedSubscriptionsController.ifPresent(ReplicatedSubscriptionsController::close);
Review Comment:
At this line, you removed an exist `replicatedSubscriptionsController`
instance, right?
If yes, you should stop the timer task `startNewSnapshot` of
`replicatedSubscriptionsController` here
And please add a test for this case.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]