@Override
  public void rollbackTxn() throws LockException {
    if (!isTxnOpen()) {
      throw new RuntimeException("Attempt to rollback before opening a transaction");
    }
    try {
      clearLocksAndHB();
      LOG.debug("Rolling back " + JavaUtils.txnIdToString(txnId));
      
      if (replPolicy != null) {
        getMS().replRollbackTxn(txnId, replPolicy, TxnType.DEFAULT);
      } else {
        AbortTxnRequest abortTxnRequest = new AbortTxnRequest(txnId);
        abortTxnRequest.setErrorCode(TxnErrorMsg.ABORT_ROLLBACK.getErrorCode());
        getMS().rollbackTxn(abortTxnRequest);
      }
    } catch (NoSuchTxnException e) {
      LOG.error("Metastore could not find " + JavaUtils.txnIdToString(txnId));
      throw new LockException(e, ErrorMsg.TXN_NO_SUCH_TRANSACTION, JavaUtils.txnIdToString(txnId));
    
    } catch(TxnAbortedException e) {
      throw new LockException(e, ErrorMsg.TXN_ABORTED, JavaUtils.txnIdToString(txnId));
    
    } catch (TException e) {
      throw new LockException(ErrorMsg.METASTORE_COMMUNICATION_FAILED.getMsg(), e);
    } finally {
      resetTxnInfo();
    }
  }
@param delay time to delay for first heartbeat
ql/src/java/org/apache/hadoop/hive/ql/lockmgr/DbTxnManager.java