poorbarcode commented on code in PR #20025:
URL: https://github.com/apache/pulsar/pull/20025#discussion_r1159765202


##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/persistent/PersistentTopicTest.java:
##########
@@ -577,15 +586,21 @@ public void 
testCreateTopicWithZombieReplicatorCursor(boolean topicLevelPolicy)
         assertEquals(getCursors.get(), 
Collections.singleton(conf.getReplicatorPrefix() + "." + remoteCluster));
 
         if (topicLevelPolicy) {
-            admin.topics().setReplicationClusters(topicName, 
Collections.emptyList());
+            admin.topics().setReplicationClusters(topicName, 
Collections.singletonList("test"));
         } else {
-            admin.namespaces().setNamespaceReplicationClustersAsync(namespace, 
Collections.emptySet()).get();
+            admin.namespaces().setNamespaceReplicationClustersAsync(namespace, 
Collections.singleton("test")).get();
         }
         admin.clusters().deleteCluster(remoteCluster);
         // Now the cluster and its related policy has been removed but the 
replicator cursor still exists
 
-        topic.initialize().get(3, TimeUnit.SECONDS);
-        Awaitility.await().atMost(3, TimeUnit.SECONDS)
-                .until(() -> 
!topic.getManagedLedger().getCursors().iterator().hasNext());
+        // Verify:
+        // 1. Topic can load success( use "topic.initialize()" instead of 
"load topic" ).
+        //    If the topic loading by client is failed, it will retry, so we 
can do retry "topic.initialize()".
+        // 2. The repl cursor will be deleted.
+        Awaitility.await().atMost(10, TimeUnit.SECONDS)
+                .until(() -> {
+                    topic.initialize().get(3, TimeUnit.SECONDS);

Review Comment:
   > BTW, the root cause is not here. I added a try-catch block to swallow the 
exception, the test could still fail.
   
   The root cause is like this:
   1. a replication task starting
   2. failed to get cluster meta from ZK
   3. check replication policies
     - Since the policy is updated asynchronously, the cache has not been 
updated.
     - get clusters( responses `[local_cluster, remote_cluster]`)
   4. Since check replication successes, will not delete the cursor. bingo



-- 
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: commits-unsubscr...@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to