mattisonchao commented on code in PR #16622:
URL: https://github.com/apache/pulsar/pull/16622#discussion_r957401488


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java:
##########
@@ -2195,6 +2195,15 @@ public void checkGC() {
             CompletableFuture<Void> replCloseFuture = new 
CompletableFuture<>();
 
             if (TopicName.get(topic).isGlobal()) {
+                // topics with remote (replication) producer should be skipped
+                if (hasRemoteProducers()) {
+                    if (log.isDebugEnabled()) {
+                        log.debug("[{}] Global topic has connected remote 
producers. Not a candidate for GC",
+                                topic);
+                    }
+                    return;
+                }
+
                 // For global namespace, close repl producers first.
                 // Once all repl producers are closed, we can delete the topic,
                 // provided no remote producers connected to the broker.

Review Comment:
   If we have two clusters, cluster A and cluster B. They enable two-way 
replication. So, cluster A has remote producer B, and cluster B has remote 
producer A.
   In the previous logic. when the replicator has no more backlog (Cluster A), 
we will close the replicator of Cluster A. And cluster B will have no remote 
producer A. In the next round of GC check, if cluster B also has no backlog. At 
this point, cluster B's replicator will be close and cluster A will also remove 
cluster B's remote producer. Then in the next new round of GC, we will clean up 
the topics on both clusters.
   But after this PR is modified, if two clusters enable two-way replication, 
they hold each other's remote producers. At this point, the topic will enter a 
kind of circular chain, and the check GC will never delete the topic until a 
replicator is closed.



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