rollbackDBConn(dbConn); LOG.info("Failed to update number of open transactions"); checkRetryable(dbConn, e, "countOpenTxns()"); } finally { close(rs, stmt, dbConn);
private enum LockAction {ACQUIRE, WAIT, KEEP_LOOKING}
LOG.debug("Going to rollback"); rollbackDBConn(dbConn); checkRetryable(dbConn, e, "cleanupMaterializationRebuildLocks"); throw new MetaException("Unable to clean rebuild locks due to " + StringUtils.stringifyException(e));
@Override public void run() { try { try { updateTxns(conn1); updateLocks(conn1); Thread.sleep(1000); conn1.commit(); LOG.debug("no exception, no deadlock"); } catch (SQLException e) { try { tHndlr.checkRetryable(conn1, e, "thread t1"); LOG.debug("Got an exception, but not a deadlock, SQLState is " + e.getSQLState() + " class of exception is " + e.getClass().getName() + " msg is <" + e.getMessage() + ">"); } catch (TxnHandler.RetryException de) { LOG.debug("Forced a deadlock, SQLState is " + e.getSQLState() + " class of " + "exception is " + e.getClass().getName() + " msg is <" + e .getMessage() + ">"); sawDeadlock.set(true); } } conn1.rollback(); } catch (Exception e) { throw new RuntimeException(e); } } };
@Override public void run() { try { try { updateLocks(conn2); updateTxns(conn2); Thread.sleep(1000); conn2.commit(); LOG.debug("no exception, no deadlock"); } catch (SQLException e) { try { tHndlr.checkRetryable(conn2, e, "thread t2"); LOG.debug("Got an exception, but not a deadlock, SQLState is " + e.getSQLState() + " class of exception is " + e.getClass().getName() + " msg is <" + e.getMessage() + ">"); } catch (TxnHandler.RetryException de) { LOG.debug("Forced a deadlock, SQLState is " + e.getSQLState() + " class of " + "exception is " + e.getClass().getName() + " msg is <" + e .getMessage() + ">"); sawDeadlock.set(true); } } conn2.rollback(); } catch (Exception e) { throw new RuntimeException(e); } } };
LOG.debug("Going to rollback"); rollbackDBConn(dbConn); checkRetryable(dbConn, e, "getTxnIdForWriteId"); throw new MetaException("Unable to select from transaction database, " + StringUtils.stringifyException(e));
LOG.debug("Going to rollback"); rollbackDBConn(dbConn); checkRetryable(dbConn, e, "heartbeatLockMaterializationRebuild(" + Warehouse.getQualifiedName(dbName, tableName) + ", " + txnId + ")"); throw new MetaException("Unable to heartbeat rebuild lock due to " +
@Override @RetrySemantics.Idempotent public long getTargetTxnId(String replPolicy, long sourceTxnId) throws MetaException { try { Connection dbConn = null; try { lockInternal(); dbConn = getDbConn(Connection.TRANSACTION_READ_COMMITTED); List<Long> targetTxnIds = getTargetTxnIdList(replPolicy, Collections.singletonList(sourceTxnId), dbConn); if (targetTxnIds.isEmpty()) { LOG.info("Txn {} not present for repl policy {}", sourceTxnId, replPolicy); return -1; } assert (targetTxnIds.size() == 1); return targetTxnIds.get(0); } catch (SQLException e) { LOG.debug("Going to rollback"); rollbackDBConn(dbConn); checkRetryable(dbConn, e, "getTargetTxnId(" + replPolicy + sourceTxnId + ")"); throw new MetaException("Unable to get target transaction id " + StringUtils.stringifyException(e)); } finally { closeDbConn(dbConn); unlockInternal(); } } catch (RetryException e) { return getTargetTxnId(replPolicy, sourceTxnId); } }
LOG.debug("Going to rollback"); rollbackDBConn(dbConn); checkRetryable(dbConn, e, "abortTxns(" + rqst + ")"); throw new MetaException("Unable to update transaction database " + StringUtils.stringifyException(e));
LOG.debug("Going to rollback"); rollbackDBConn(dbConn); checkRetryable(dbConn, e, "showCompact(" + rqst + ")"); throw new MetaException("Unable to select from transaction database " + StringUtils.stringifyException(e));
LOG.debug("Going to rollback"); rollbackDBConn(dbConn); checkRetryable(dbConn, e, "heartbeatTxnRange(" + rqst + ")"); throw new MetaException("Unable to select from transaction database " + StringUtils.stringifyException(e));
private LockResponse checkLockWithRetry(Connection dbConn, long extLockId, long txnId) throws NoSuchLockException, NoSuchTxnException, TxnAbortedException, MetaException { try { try { lockInternal(); if(dbConn.isClosed()) { //should only get here if retrying this op dbConn = getDbConn(Connection.TRANSACTION_READ_COMMITTED); } return checkLock(dbConn, extLockId); } catch (SQLException e) { LOG.debug("Going to rollback"); rollbackDBConn(dbConn); checkRetryable(dbConn, e, "checkLockWithRetry(" + extLockId + "," + txnId + ")"); throw new MetaException("Unable to update transaction database " + StringUtils.stringifyException(e)); } finally { unlockInternal(); closeDbConn(dbConn); } } catch(RetryException e) { return checkLockWithRetry(dbConn, extLockId, txnId); } } /**
throw new MetaException(e.getMessage()); checkRetryable(dbConn, e, "addWriteNotificationLog(" + acidWriteEvent + ")"); throw new MetaException("Unable to add write notification event " + StringUtils.stringifyException(e)); } finally{
LOG.debug("Going to rollback"); rollbackDBConn(dbConn); checkRetryable(dbConn, e, "openTxns(" + rqst + ")"); throw new MetaException("Unable to select from transaction database " + StringUtils.stringifyException(e));
LOG.debug("Going to rollback"); rollbackDBConn(dbConn); checkRetryable(dbConn, e, "seedWriteIdOnAcidConversion(" + rqst + ")"); throw new MetaException("Unable to update transaction database " + StringUtils.stringifyException(e));
LOG.debug("Going to rollback"); rollbackDBConn(dbConn); checkRetryable(dbConn, e, "abortTxn(" + rqst + ")"); throw new MetaException("Unable to update transaction database " + StringUtils.stringifyException(e));
LOG.debug("Going to rollback"); rollbackDBConn(dbConn); checkRetryable(dbConn, e, "addDynamicPartitions(" + rqst + ")"); throw new MetaException("Unable to insert into from transaction database " + StringUtils.stringifyException(e));
LOG.debug("Going to rollback"); rollbackDBConn(dbConn); checkRetryable(dbConn, e, "getValidWriteIds"); throw new MetaException("Unable to select from transaction database, " + StringUtils.stringifyException(e));
/** * {@code ids} should only have txnid or lockid but not both, ideally. * Currently DBTxnManager.heartbeat() enforces this. */ @Override @RetrySemantics.SafeToRetry public void heartbeat(HeartbeatRequest ids) throws NoSuchTxnException, NoSuchLockException, TxnAbortedException, MetaException { try { Connection dbConn = null; try { dbConn = getDbConn(Connection.TRANSACTION_READ_COMMITTED); heartbeatLock(dbConn, ids.getLockid()); heartbeatTxn(dbConn, ids.getTxnid()); } catch (SQLException e) { LOG.debug("Going to rollback"); rollbackDBConn(dbConn); checkRetryable(dbConn, e, "heartbeat(" + ids + ")"); throw new MetaException("Unable to select from transaction database " + StringUtils.stringifyException(e)); } finally { closeDbConn(dbConn); } } catch (RetryException e) { heartbeat(ids); } } @Override
LOG.debug("Going to rollback"); rollbackDBConn(dbConn); checkRetryable(dbConn, e, "checkLock(" + rqst + " )"); throw new MetaException("Unable to update transaction database " + JavaUtils.lockIdToString(extLockId) + " " + StringUtils.stringifyException(e));