HBase
  1. HBase
  2. HBASE-10448

ZKUtil create and watch methods don't set watch in some cases

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 0.96.0, 0.96.1.1
    • Fix Version/s: 0.98.0, 0.96.2, 0.99.0, 0.94.17
    • Component/s: Zookeeper
    • Labels:
      None
    • Hadoop Flags:
      Reviewed

      Description

      While using the ZKUtil methods during testing, I found that watch was not set when it should be set based on the methods and method comments:
      createNodeIfNotExistsAndWatch
      createEphemeralNodeAndWatch

      For example, in createNodeIfNotExistsAndWatch():

       public static boolean createNodeIfNotExistsAndWatch(
            ZooKeeperWatcher zkw, String znode, byte [] data)
        throws KeeperException {
          try {
            zkw.getRecoverableZooKeeper().create(znode, data, createACL(zkw, znode),
                CreateMode.PERSISTENT);
          } catch (KeeperException.NodeExistsException nee) {
            try {
              zkw.getRecoverableZooKeeper().exists(znode, zkw);
            } catch (InterruptedException e) {
              zkw.interruptedException(e);
              return false;
            }
            return false;
          } catch (InterruptedException e) {
            zkw.interruptedException(e);
            return false;
          }
          return true;
        }
      

      The watch is only set via exists() call when the node already exists.
      Similarly in createEphemeralNodeAndWatch():

        public static boolean createEphemeralNodeAndWatch(ZooKeeperWatcher zkw,
            String znode, byte [] data)
        throws KeeperException {
          try {
            zkw.getRecoverableZooKeeper().create(znode, data, createACL(zkw, znode),
                CreateMode.EPHEMERAL);
          } catch (KeeperException.NodeExistsException nee) {
            if(!watchAndCheckExists(zkw, znode)) {
              // It did exist but now it doesn't, try again
              return createEphemeralNodeAndWatch(zkw, znode, data);
            }
            return false;
          } catch (InterruptedException e) {
            LOG.info("Interrupted", e);
            Thread.currentThread().interrupt();
          }
          return true;
        }
      

        Issue Links

          Activity

            People

            • Assignee:
              Jerry He
              Reporter:
              Jerry He
            • Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development