Uploaded image for project: 'ZooKeeper'
  1. ZooKeeper
  2. ZOOKEEPER-3014

watch can be added to non-existed path by exist command

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Not A Problem
    • 3.4.5, 3.4.6
    • 3.4.12
    • server
    • None

    Description

      We have client A which create a znode ,and its path is /zk/lock/100000.  Another client B thread is acquiring for the lock, so it calls the exist command with watch periodically to check if it is available. Then Client A has finished this work, and  delete this znode. Client b still calls exist command with watch. Because the code doesn't check node existence, when the  Watch add operation comes , it will add to non-exist node path.

      This problem may be cause by the follow code. 

      public Stat statNode(String path, Watcher watcher)
      throws KeeperException.NoNodeException {
      Stat stat = new Stat();
      DataNode n = nodes.get(path);
      if (watcher != null) {
      dataWatches.addWatch(path, watcher);
      }
      if (n == null) {
      throw new KeeperException.NoNodeException();
      }
      synchronized (n) {
      n.copyStat(stat);
      return stat;
      }
      }
      

      The zk version we use is 3.4.5. We meet a problem that is the zk client try to reestablish to zk cluster failed after disconnect for some reason.We find it causes by ZOOKEEPER-706. But we try to know why there are so many watches. Then we find this problem.

       

       

       

      Attachments

        1. image-2018-03-28-22-51-33-751.png
          66 kB
          CHQ
        2. TestCurator.java
          2 kB
          Andor Molnar

        Activity

          People

            Unassigned Unassigned
            tassemble CHQ
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: