@Override
  public void unlock(HiveLock hiveLock) throws LockException {
    long lockId = ((DbHiveLock)hiveLock).lockId;
    boolean removed = false;
    try {
      LOG.debug("Unlocking " + hiveLock);
      txnManager.getMS().unlock(lockId);
      //important to remove after unlock() in case it fails
      removed = locks.remove(hiveLock);
      Metrics metrics = MetricsFactory.getInstance();
      if (metrics != null) {
        try {
          metrics.decrementCounter(MetricsConstant.METASTORE_HIVE_LOCKS);
        } catch (Exception e) {
          LOG.warn("Error Reporting hive client metastore unlock operation to Metrics system", e);
        }
      }
      LOG.debug("Removed a lock " + removed);
    } catch (NoSuchLockException e) {
      //if metastore has no record of this lock, it most likely timed out; either way
      //there is no point tracking it here any longer
      removed = locks.remove(hiveLock);
      LOG.error("Metastore could find no record of lock " + JavaUtils.lockIdToString(lockId));
      throw new LockException(e, ErrorMsg.LOCK_NO_SUCH_LOCK, JavaUtils.lockIdToString(lockId));
    } catch (TxnOpenException e) {
      throw new RuntimeException("Attempt to unlock lock " + JavaUtils.lockIdToString(lockId) +
          "associated with an open transaction, " + e.getMessage(), e);
    } catch (TException e) {
      throw new LockException(ErrorMsg.METASTORE_COMMUNICATION_FAILED.getMsg(),
          e);
    }
    finally {
      if(removed) {
        LOG.debug("Removed a lock " + hiveLock);
      }
    }
  }
Used to make another attempt to acquire a lock (in Waiting state)
@param extLockId
@return result of the attempt
@throws LockException
ql/src/java/org/apache/hadoop/hive/ql/lockmgr/DbLockManager.java