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

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

Reply via email to