liangyepianzhou commented on code in PR #21495:
URL: https://github.com/apache/pulsar/pull/21495#discussion_r1381376673


##########
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:
   >If yes, you should stop the timer task startNewSnapshot of 
replicatedSubscriptionsController here
   
   The logic of `ReplicatedSubscriptionsController::close` is as follow:
   ```
       @Override
       public void close() {
           timer.cancel(true);
       }
   ```



-- 
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]

Reply via email to