diff --git a/ql/src/java/org/apache/hadoop/hive/ql/lockmgr/zookeeper/ZooKeeperHiveLockManager.java b/ql/src/java/org/apache/hadoop/hive/ql/lockmgr/zookeeper/ZooKeeperHiveLockManager.java index 141cbc9dae..0c0eb7b607 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/lockmgr/zookeeper/ZooKeeperHiveLockManager.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/lockmgr/zookeeper/ZooKeeperHiveLockManager.java @@ -62,8 +62,8 @@ private String parent; private long sleepTime; - private int numRetriesForLock; - private int numRetriesForUnLock; + private int numTotalTriesForLock; + private int numTotalTriesForUnLock; private static String clientIp; @@ -90,8 +90,8 @@ public void setContext(HiveLockManagerCtx ctx) throws LockException { sleepTime = conf.getTimeVar( HiveConf.ConfVars.HIVE_LOCK_SLEEP_BETWEEN_RETRIES, TimeUnit.MILLISECONDS); - numRetriesForLock = conf.getIntVar(HiveConf.ConfVars.HIVE_LOCK_NUMRETRIES); - numRetriesForUnLock = conf.getIntVar(HiveConf.ConfVars.HIVE_UNLOCK_NUMRETRIES); + numTotalTriesForLock = conf.getIntVar(HiveConf.ConfVars.HIVE_LOCK_NUMRETRIES); + numTotalTriesForUnLock = conf.getIntVar(HiveConf.ConfVars.HIVE_UNLOCK_NUMRETRIES); try { curatorFramework = CuratorFrameworkSingleton.getInstance(conf); @@ -115,8 +115,8 @@ public void refresh() { HiveConf conf = ctx.getConf(); sleepTime = conf.getTimeVar( HiveConf.ConfVars.HIVE_LOCK_SLEEP_BETWEEN_RETRIES, TimeUnit.MILLISECONDS); - numRetriesForLock = conf.getIntVar(HiveConf.ConfVars.HIVE_LOCK_NUMRETRIES); - numRetriesForUnLock = conf.getIntVar(HiveConf.ConfVars.HIVE_UNLOCK_NUMRETRIES); + numTotalTriesForLock = conf.getIntVar(HiveConf.ConfVars.HIVE_LOCK_NUMRETRIES); + numTotalTriesForUnLock = conf.getIntVar(HiveConf.ConfVars.HIVE_UNLOCK_NUMRETRIES); } /** @@ -326,7 +326,7 @@ private ZooKeeperHiveLock lock (HiveLockObject key, HiveLockMode mode, LOG.error("Other unexpected exception: ", e1); } } - } while (tryNum < numRetriesForLock); + } while (tryNum <= numTotalTriesForLock); if (ret == null) { console.printError("Unable to acquire " + key.getData().getLockMode() @@ -489,13 +489,13 @@ private void unlockWithRetry(HiveLock hiveLock, String parent) throws LockExcept unlockPrimitive(hiveLock, parent, curatorFramework); break; } catch (Exception e) { - if (tryNum >= numRetriesForUnLock) { + if (tryNum >= numTotalTriesForUnLock) { String name = ((ZooKeeperHiveLock)hiveLock).getPath(); - throw new LockException("Node " + name + " can not be deleted after " + numRetriesForUnLock + " attempts.", + throw new LockException("Node " + name + " can not be deleted after " + numTotalTriesForUnLock + " attempts.", e); } } - } while (tryNum < numRetriesForUnLock); + } while (tryNum <= numTotalTriesForUnLock); return; }