You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/10/28 10:33:11 UTC

[GitHub] [pulsar] 315157973 commented on a diff in pull request #18235: [fix][broker][branch-2.8] Fix watcher count on ZK increasing indefinitely

315157973 commented on code in PR #18235:
URL: https://github.com/apache/pulsar/pull/18235#discussion_r1007916716


##########
pulsar-zookeeper-utils/src/main/java/org/apache/pulsar/zookeeper/ZooKeeperCache.java:
##########
@@ -248,6 +245,14 @@ public CompletableFuture<Boolean> existsAsync(String path, Watcher watcher) {
                 if (rc == Code.OK.intValue()) {
                     future.complete(true);
                 } else if (rc == Code.NONODE.intValue()) {
+                    // remove watcher if node does not exist
+                    zk.removeAllWatches(path, Watcher.WatcherType.Any, true,
+                            (rc0, path0, ctx0) -> {
+                                Code code0 = Code.get(rc0);
+                                if (code0 != Code.OK && code0 != Code.NOWATCHER) {
+                                    log.warn("Remove watcher failed. rc: {}, path: {}", code0, path);
+                                }
+                            }, null);

Review Comment:
   Can this repetitive code abstract a method?
   



-- 
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-unsubscribe@pulsar.apache.org

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