@Override public void run() { try { releaseLocksAndCommitOrRollback(false, txnManager); } catch (LockException e) { LOG.warn("Exception when releasing locks in ShutdownHook for Driver: " + e.getMessage()); } } };
@Override protected void destruct() { if (lockMgr != null) { try { lockMgr.close(); } catch (LockException e) { // Not much I can do about it. LOG.warn("Got exception when closing lock manager " + e.getMessage()); } } }
@Override public void run() { try { releaseLocksAndCommitOrRollback(false, txnMgr); } catch (LockException e) { LOG.warn("Exception when releasing locks in ShutdownHook for Driver: " + e.getMessage()); } } };
protected void destruct() { if (lockMgr != null) { try { lockMgr.close(); } catch (LockException e) { // Not much I can do about it. LOG.warn("Got exception when closing lock manager " + e.getMessage()); } } }
@Override public void destroy() { lDrvState.stateLock.lock(); try { // in the cancel case where the driver state is INTERRUPTED, destroy will be deferred to // the query process if (lDrvState.driverState == DriverState.DESTROYED) { return; } else { lDrvState.driverState = DriverState.DESTROYED; } } finally { lDrvState.stateLock.unlock(); } if (!hiveLocks.isEmpty()) { try { releaseLocksAndCommitOrRollback(false); } catch (LockException e) { LOG.warn("Exception when releasing locking in destroy: " + e.getMessage()); } } ShutdownHookManager.removeShutdownHook(shutdownRunner); }
public void destroy() { lDrvState.stateLock.lock(); try { // in the cancel case where the driver state is INTERRUPTED, destroy will be deferred to // the query process if (lDrvState.driverState == DriverState.DESTROYED || lDrvState.driverState == DriverState.INTERRUPT) { return; } else { lDrvState.driverState = DriverState.DESTROYED; } } finally { lDrvState.stateLock.unlock(); } if (!hiveLocks.isEmpty()) { try { releaseLocksAndCommitOrRollback(false, null); } catch (LockException e) { LOG.warn("Exception when releasing locking in destroy: " + e.getMessage()); } } ShutdownHookManager.removeShutdownHook(shutdownRunner); }
/** * Send a heartbeat to the metastore for locks and transactions. */ @Override public void run() { try { // For negative testing purpose.. if(conf.getBoolVar(HiveConf.ConfVars.HIVE_IN_TEST) && conf.getBoolVar(HiveConf.ConfVars.HIVETESTMODEFAILHEARTBEATER)) { throw new LockException(HiveConf.ConfVars.HIVETESTMODEFAILHEARTBEATER.name() + "=true"); } LOG.debug("Heartbeating...for currentUser: " + currentUser); currentUser.doAs((PrivilegedExceptionAction<Object>) () -> { txnMgr.heartbeat(); return null; }); } catch (LockException e) { LOG.error("Failed trying to heartbeat queryId=" + queryId + ", currentUser: " + currentUser + ": " + e.getMessage()); lockException = e; } catch (Throwable t) { String errorMsg = "Failed trying to heartbeat queryId=" + queryId + ", currentUser: " + currentUser + ": " + t.getMessage(); LOG.error(errorMsg, t); lockException = new LockException(errorMsg, t); } } }
/** * Send a heartbeat to the metastore for locks and transactions. */ @Override public void run() { try { // For negative testing purpose.. if(conf.getBoolVar(HiveConf.ConfVars.HIVE_IN_TEST) && conf.getBoolVar(HiveConf.ConfVars.HIVETESTMODEFAILHEARTBEATER)) { throw new LockException(HiveConf.ConfVars.HIVETESTMODEFAILHEARTBEATER.name() + "=true"); } LOG.debug("Heartbeating..."); txnMgr.heartbeat(); } catch (LockException e) { LOG.error("Failed trying to heartbeat queryId=" + queryId + ": " + e.getMessage()); lockException = e; } catch (Throwable t) { LOG.error("Failed trying to heartbeat queryId=" + queryId + ": " + t.getMessage(), t); lockException = new LockException("Failed trying to heartbeat queryId=" + queryId + ": " + t.getMessage(), t); } } }
} catch (TxnAbortedException e) { LockException le = new LockException(e, ErrorMsg.TXN_ABORTED, JavaUtils.txnIdToString(txnId), e.getMessage()); LOG.error(le.getMessage()); throw le; } catch (TException e) {
private int closeInProcess(boolean destroyed) { releaseDriverContext(); releasePlan(); releaseCachedResult(); releaseFetchTask(); releaseResStream(); releaseContext(); if(destroyed) { if (!hiveLocks.isEmpty()) { try { releaseLocksAndCommitOrRollback(false); } catch (LockException e) { LOG.warn("Exception when releasing locking in destroy: " + e.getMessage()); } } ShutdownHookManager.removeShutdownHook(shutdownRunner); } return 0; }
@Override public void replRollbackTxn(String replPolicy, long srcTxnId) throws LockException { try { getMS().replRollbackTxn(srcTxnId, replPolicy); } catch (NoSuchTxnException e) { LOG.error("Metastore could not find " + JavaUtils.txnIdToString(srcTxnId)); throw new LockException(e, ErrorMsg.TXN_NO_SUCH_TRANSACTION, JavaUtils.txnIdToString(srcTxnId)); } catch (TxnAbortedException e) { LockException le = new LockException(e, ErrorMsg.TXN_ABORTED, JavaUtils.txnIdToString(srcTxnId), e.getMessage()); LOG.error(le.getMessage()); throw le; } catch (TException e) { throw new LockException(ErrorMsg.METASTORE_COMMUNICATION_FAILED.getMsg(), e); } }
@Override public void commitTxn() throws LockException { if (!isTxnOpen()) { throw new RuntimeException("Attempt to commit before opening a transaction"); } try { // do all new clear in clearLocksAndHB method to make sure that same code is there for replCommitTxn flow. clearLocksAndHB(); LOG.debug("Committing txn " + JavaUtils.txnIdToString(txnId)); getMS().commitTxn(txnId); } 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) { LockException le = new LockException(e, ErrorMsg.TXN_ABORTED, JavaUtils.txnIdToString(txnId), e.getMessage()); LOG.error(le.getMessage()); throw le; } catch (TException e) { throw new LockException(ErrorMsg.METASTORE_COMMUNICATION_FAILED.getMsg(), e); } finally { // do all new reset in resetTxnInfo method to make sure that same code is there for replCommitTxn flow. resetTxnInfo(); } } @Override
@Override public void commitTxn() throws LockException { if (!isTxnOpen()) { throw new RuntimeException("Attempt to commit before opening a transaction"); } try { lockMgr.clearLocalLockRecords(); stopHeartbeat(); LOG.debug("Committing txn " + JavaUtils.txnIdToString(txnId)); getMS().commitTxn(txnId); } 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) { LockException le = new LockException(e, ErrorMsg.TXN_ABORTED, JavaUtils.txnIdToString(txnId), e.getMessage()); LOG.error(le.getMessage()); throw le; } catch (TException e) { throw new LockException(ErrorMsg.METASTORE_COMMUNICATION_FAILED.getMsg(), e); } finally { txnId = 0; statementId = -1; } }
private int closeInProcess(boolean destroyed) { releaseDriverContext(); releasePlan(); releaseFetchTask(); releaseResStream(); releaseContext(); if (SessionState.get() != null) { SessionState.get().getLineageState().clear(); } if(destroyed) { if (!hiveLocks.isEmpty()) { try { releaseLocksAndCommitOrRollback(false, null); } catch (LockException e) { LOG.warn("Exception when releasing locking in destroy: " + e.getMessage()); } } ShutdownHookManager.removeShutdownHook(shutdownRunner); } return 0; }
@Override public void replCommitTxn(CommitTxnRequest rqst) throws LockException { try { if (rqst.isSetReplLastIdInfo()) { if (!isTxnOpen()) { throw new RuntimeException("Attempt to commit before opening a transaction"); } // For transaction started internally by repl load command, heartbeat needs to be stopped. clearLocksAndHB(); } getMS().replCommitTxn(rqst); } catch (NoSuchTxnException e) { LOG.error("Metastore could not find " + JavaUtils.txnIdToString(rqst.getTxnid())); throw new LockException(e, ErrorMsg.TXN_NO_SUCH_TRANSACTION, JavaUtils.txnIdToString(rqst.getTxnid())); } catch (TxnAbortedException e) { LockException le = new LockException(e, ErrorMsg.TXN_ABORTED, JavaUtils.txnIdToString(rqst.getTxnid()), e.getMessage()); LOG.error(le.getMessage()); throw le; } catch (TException e) { throw new LockException(ErrorMsg.METASTORE_COMMUNICATION_FAILED.getMsg(), e); } finally { if (rqst.isSetReplLastIdInfo()) { // For transaction started internally by repl load command, needs to clear the txn info. resetTxnInfo(); } } }
Assert.fail(); } catch(LockException le) { Assert.assertEquals(le.getMessage(), ErrorMsg.LOCK_ACQUIRE_CANCELLED.getMsg());
/** * Add the task according to the parsed command tree. This is used for the CLI * command "SHOW LOCKS DATABASE database [extended];". * * @param ast * The parsed command tree. * @throws SemanticException * Parsing failed */ private void analyzeShowDbLocks(ASTNode ast) throws SemanticException { boolean isExtended = (ast.getChildCount() > 1); String dbName = stripQuotes(ast.getChild(0).getText()); HiveTxnManager txnManager = null; try { txnManager = TxnManagerFactory.getTxnManagerFactory().getTxnManager(conf); } catch (LockException e) { throw new SemanticException(e.getMessage()); } ShowLocksDesc showLocksDesc = new ShowLocksDesc(ctx.getResFile(), dbName, isExtended, txnManager.useNewShowLocksFormat()); rootTasks.add(TaskFactory.get(new DDLWork(getInputs(), getOutputs(), showLocksDesc))); setFetchTask(createFetchTask(showLocksDesc.getSchema())); // Need to initialize the lock manager ctx.setNeedLockMgr(true); }
/** * Add the task according to the parsed command tree. This is used for the CLI * command "SHOW LOCKS DATABASE database [extended];". * * @param ast * The parsed command tree. * @throws SemanticException * Parsing failed */ private void analyzeShowDbLocks(ASTNode ast) throws SemanticException { boolean isExtended = (ast.getChildCount() > 1); String dbName = stripQuotes(ast.getChild(0).getText()); HiveTxnManager txnManager = null; try { txnManager = TxnManagerFactory.getTxnManagerFactory().getTxnManager(conf); } catch (LockException e) { throw new SemanticException(e.getMessage()); } ShowLocksDesc showLocksDesc = new ShowLocksDesc(ctx.getResFile(), dbName, isExtended, txnManager.useNewShowLocksFormat()); rootTasks.add(TaskFactory.get(new DDLWork(getInputs(), getOutputs(), showLocksDesc), conf)); setFetchTask(createFetchTask(showLocksDesc.getSchema())); // Need to initialize the lock manager ctx.setNeedLockMgr(true); }
txnManager = TxnManagerFactory.getTxnManagerFactory().getTxnManager(conf); } catch (LockException e) { throw new SemanticException(e.getMessage());
txnManager = TxnManagerFactory.getTxnManagerFactory().getTxnManager(conf); } catch (LockException e) { throw new SemanticException(e.getMessage());