oneby-wang commented on code in PR #25910:
URL: https://github.com/apache/pulsar/pull/25910#discussion_r3332944291


##########
pulsar-metadata/src/main/java/org/apache/pulsar/metadata/impl/PulsarZooKeeperClient.java:
##########
@@ -122,9 +123,35 @@ public ZooKeeper call() throws KeeperException, 
InterruptedException {
                         log.info().attr("connectString", 
connectString).log("Reconnecting zookeeper");
                         // close the previous one
                         closeZkHandle();
+
+                        // ZooKeeper can deliver SyncConnected after 
createZooKeeper() returns but before zk.set(newZk)
+                        // publishes the new instance. Hold these events until 
the new instance is published, so child
+                        // watchers never observe a new-session event while 
PulsarZooKeeperClient still points at the
+                        // old handle.
+                        CountDownLatch newZkSetLatch = new CountDownLatch(1);
+                        Watcher forwardEventsWatcher = event -> {
+                            try {
+                                boolean awaited = 
newZkSetLatch.await(sessionTimeoutMs, TimeUnit.MILLISECONDS);
+                                if (!awaited) {
+                                    log.warn().attr("event", event)
+                                            .log("Timed out waiting for 
ZooKeeper instance to be published before "
+                                                    + "forwarding event");
+                                    return;

Review Comment:
   Addressed



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