Uploaded image for project: 'Hive'
  1. Hive
  2. HIVE-16487

Serious Zookeeper exception is logged when a race condition happens



    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.0.0
    • Fix Version/s: 2.3.2, 2.4.0, 3.0.0
    • Component/s: Locking
    • Labels:


      A customer started to see this in the logs, but happily everything was working as intended:

      2017-03-30 12:01:59,446 ERROR ZooKeeperHiveLockManager: [HiveServer2-Background-Pool: Thread-620]: Serious Zookeeper exception: 
      org.apache.zookeeper.KeeperException$NoNodeException: KeeperErrorCode = NoNode for /hive_zookeeper_namespace/<TABLE_NAME>/LOCK-SHARED-

      This was happening, because a race condition between the lock releasing, and lock acquiring. The thread releasing the lock removes the parent ZK node just after the thread acquiring the lock made sure, that the parent node exists.

      Since this can happen without any real problem, I plan to add NODEEXISTS, and NONODE as a transient ZooKeeper exception, so the users are not confused.

      Also, the original author of ZooKeeperHiveLockManager maybe planned to handle different ZooKeeperExceptions differently, and the code is hard to understand. See the continue and the break. The break only breaks the switch, and not the loop which IMHO is not intuitive:

          do {
            try {
              ret = lockPrimitive(key, mode, keepAlive, parentCreated, 
            } catch (Exception e1) {
              if (e1 instanceof KeeperException) {
                KeeperException e = (KeeperException) e1;
                switch (e.code()) {
                case CONNECTIONLOSS:
                case OPERATIONTIMEOUT:
                  LOG.debug("Possibly transient ZooKeeper exception: ", e);
                  LOG.error("Serious Zookeeper exception: ", e);
          } while (tryNum < numRetriesForLock);

      If we do not want to try again in case of a "Serious Zookeeper exception:", then we should add a label to the do loop, and break it in the switch.

      If we do want to try regardless of the type of the ZK exception, then we should just change the continue; to break; and move the lines part of the code which did not run in case of continue to the default switch, so it is easier to understand the code.

      Any suggestions or ideas [~ctang.ma] or Szehon Ho?


        1. HIVE-16487.02.patch
          4 kB
          Peter Vary
        2. HIVE-16487.patch
          2 kB
          Peter Vary



            • Assignee:
              pvary Peter Vary
              pvary Peter Vary
            • Votes:
              0 Vote for this issue
              3 Start watching this issue


              • Created: