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 04:38:20 UTC

[GitHub] [pulsar] coderzc opened a new pull request, #18235: [fix][broker][branch-2.8] Fix watcher count on ZK increasing indefinitely

coderzc opened a new pull request, #18235:
URL: https://github.com/apache/pulsar/pull/18235

   ### Motivation
   
   I find some z-node only call `exist` and add watcher, but `ExistsWatchRegistration` still will be registered even though the z-node may never be created. this will lead to the watcher count on ZK increasing indefinitely.
   
   ```java
       /** Handle the special case of exists watches - they add a watcher
        * even in the case where NONODE result code is returned.
        */
       class ExistsWatchRegistration extends WatchRegistration {
   
           public ExistsWatchRegistration(Watcher watcher, String clientPath) {
               super(watcher, clientPath);
           }
   
           @Override
           protected Map<String, Set<Watcher>> getWatches(int rc) {
               return rc == 0 ? watchManager.dataWatches : watchManager.existWatches;
           }
   
           @Override
           protected boolean shouldAddWatch(int rc) {
               return rc == 0 || rc == KeeperException.Code.NONODE.intValue();
           }
   
       }
   ```
   
   ### Modifications
   
   Remove watcher if `exist` return `NONODE`.
   Remove unused method in ZkUtils.
   
   ### Documentation
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   - [ ] `doc` <!-- Your PR contains doc changes. Please attach the local preview screenshots (run `sh start.sh` at `pulsar/site2/website`) to your PR description, or else your PR might not get merged. -->
   - [ ] `doc-required` <!-- Your PR changes impact docs and you will update later -->
   - [x] `doc-not-needed` <!-- Your PR changes do not impact docs -->
   - [ ] `doc-complete` <!-- Docs have been already added -->
   
   ### Matching PR in forked repository
   
   PR in forked repository: 
   


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


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

Posted by "tisonkun (via GitHub)" <gi...@apache.org>.
tisonkun commented on PR #18235:
URL: https://github.com/apache/pulsar/pull/18235#issuecomment-1459181990

   Closing...
   
   IIRC 2.8 is end of life. Also, this is not a cherry-pick patch. If it's still relevant for the master branch, you can open a new pull request.


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


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

Posted by GitBox <gi...@apache.org>.
coderzc commented on PR #18235:
URL: https://github.com/apache/pulsar/pull/18235#issuecomment-1294445937

   @codelipenghui PTAL.


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


[GitHub] [pulsar] tisonkun closed pull request #18235: [fix][broker][branch-2.8] Fix watcher count on ZK increasing indefinitely

Posted by "tisonkun (via GitHub)" <gi...@apache.org>.
tisonkun closed pull request #18235: [fix][broker][branch-2.8] Fix watcher count on ZK increasing indefinitely 
URL: https://github.com/apache/pulsar/pull/18235


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


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

Posted by GitBox <gi...@apache.org>.
coderzc commented on PR #18235:
URL: https://github.com/apache/pulsar/pull/18235#issuecomment-1296969677

   > If you want to add a watch if only the node exists, you can use `getData` instead.
   
   It seems that this will add a lot of useless data transfer.


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


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

Posted by GitBox <gi...@apache.org>.
coderzc commented on PR #18235:
URL: https://github.com/apache/pulsar/pull/18235#issuecomment-1295762896

   /pulsarbot rerun-failure-checks


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


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

Posted by GitBox <gi...@apache.org>.
codelipenghui commented on code in PR #18235:
URL: https://github.com/apache/pulsar/pull/18235#discussion_r1007782116


##########
pulsar-metadata/src/main/java/org/apache/pulsar/metadata/impl/ZKMetadataStore.java:
##########
@@ -206,6 +203,14 @@ private void existsFromStoreInternal(String path, CompletableFuture<Boolean> fut
                     if (code == Code.OK) {
                         future.complete(true);
                     } else if (code == Code.NONODE) {
+                        // remove watcher if node does not exist
+                        zkc.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);

Review Comment:
   Please check all.



##########
pulsar-metadata/src/main/java/org/apache/pulsar/metadata/impl/ZKMetadataStore.java:
##########
@@ -206,6 +203,14 @@ private void existsFromStoreInternal(String path, CompletableFuture<Boolean> fut
                     if (code == Code.OK) {
                         future.complete(true);
                     } else if (code == Code.NONODE) {
+                        // remove watcher if node does not exist
+                        zkc.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);

Review Comment:
   ```suggestion
                                           log.warn("Remove watcher for non-existing znode failed. rc: {}, path: {}", code0, path);
   ```



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


[GitHub] [pulsar] github-actions[bot] commented on pull request #18235: [fix][broker][branch-2.8] Fix watcher count on ZK increasing indefinitely

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #18235:
URL: https://github.com/apache/pulsar/pull/18235#issuecomment-1336009436

   The pr had no activity for 30 days, mark with Stale label.


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


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

Posted by GitBox <gi...@apache.org>.
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


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

Posted by GitBox <gi...@apache.org>.
coderzc commented on PR #18235:
URL: https://github.com/apache/pulsar/pull/18235#issuecomment-1297080528

   /pulsarbot rerun-failure-checks


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


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

Posted by GitBox <gi...@apache.org>.
tisonkun commented on PR #18235:
URL: https://github.com/apache/pulsar/pull/18235#issuecomment-1295770328

   If you want to add a watch if only the node exists, you can use `getData` instead.


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