private static void shouldNeverHappen(long txnid) { throw new RuntimeException("This should never happen: " + JavaUtils.txnIdToString(txnid)); } private static void shouldNeverHappen(long txnid, long extLockId, long intLockId) {
private static void shouldNeverHappen(long txnid, long extLockId, long intLockId) { throw new RuntimeException("This should never happen: " + JavaUtils.txnIdToString(txnid) + " " + JavaUtils.lockIdToString(extLockId) + " " + intLockId); }
/** * Used to raise an informative error when the caller expected a txn in a particular TxnStatus * but found it in some other status */ private static void raiseTxnUnexpectedState(TxnStatus actualStatus, long txnid) throws NoSuchTxnException, TxnAbortedException { switch (actualStatus) { case ABORTED: throw new TxnAbortedException("Transaction " + JavaUtils.txnIdToString(txnid) + " already aborted"); case COMMITTED: throw new NoSuchTxnException("Transaction " + JavaUtils.txnIdToString(txnid) + " is already committed."); case UNKNOWN: throw new NoSuchTxnException("No such transaction " + JavaUtils.txnIdToString(txnid)); case OPEN: throw new NoSuchTxnException(JavaUtils.txnIdToString(txnid) + " is " + TxnStatus.OPEN); default: throw new IllegalArgumentException("Unknown TxnStatus " + actualStatus); } } /**
private LockInfo getTxnIdFromLockId(Connection dbConn, long extLockId) throws NoSuchLockException, MetaException, SQLException { Statement stmt = null; ResultSet rs = null; try { stmt = dbConn.createStatement(); String s = "select hl_lock_ext_id, hl_lock_int_id, hl_db, hl_table, " + "hl_partition, hl_lock_state, hl_lock_type, hl_txnid from HIVE_LOCKS where " + "hl_lock_ext_id = " + extLockId; LOG.debug("Going to execute query <" + s + ">"); rs = stmt.executeQuery(s); if (!rs.next()) { return null; } LockInfo info = new LockInfo(rs); LOG.debug("getTxnIdFromLockId(" + extLockId + ") Return " + JavaUtils.txnIdToString(info.txnId)); return info; } finally { close(rs); closeStmt(stmt); } }
if (alreadyCommitted) { throw new NoSuchTxnException("Transaction " + JavaUtils.txnIdToString(txnid) + " is already committed."); throw new NoSuchTxnException("No such transaction " + JavaUtils.txnIdToString(txnid)); LOG.debug("Going to rollback"); rollbackDBConn(dbConn); throw new TxnAbortedException("Transaction " + JavaUtils.txnIdToString(txnid) + " already aborted");// todo: add time of abort, which is not currently tracked.
sb.append(") ").append(JavaUtils.txnIdToString(txnId)); close(rs); throw new NoSuchLockException(sb.toString());
@Override public String toString() { return JavaUtils.lockIdToString(extLockId) + " intLockId:" + intLockId + " " + JavaUtils.txnIdToString(txnId) + " db:" + db + " table:" + table + " partition:" + partition + " state:" + (state == null ? "null" : state.toString()) + " type:" + (type == null ? "null" : type.toString()); } private boolean isDbLock() {
public static ValidTxnList createValidTxnListForCleaner(GetOpenTxnsResponse txns, long minOpenTxnGLB) { long highWaterMark = minOpenTxnGLB - 1; long[] abortedTxns = new long[txns.getOpen_txnsSize()]; BitSet abortedBits = BitSet.valueOf(txns.getAbortedBits()); int i = 0; for(long txnId : txns.getOpen_txns()) { if(txnId > highWaterMark) { break; } if(abortedBits.get(i)) { abortedTxns[i] = txnId; } else { assert false : JavaUtils.txnIdToString(txnId) + " is open and <= hwm:" + highWaterMark; } ++i; } abortedTxns = Arrays.copyOf(abortedTxns, i); BitSet bitSet = new BitSet(abortedTxns.length); bitSet.set(0, abortedTxns.length); //add ValidCleanerTxnList? - could be problematic for all the places that read it from // string as they'd have to know which object to instantiate return new ValidReadTxnList(abortedTxns, bitSet, highWaterMark, Long.MAX_VALUE); } /**
String msg = "Aborting " + JavaUtils.txnIdToString(writeSet.get(0).txnId) + " since a concurrent committed transaction [" + JavaUtils.txnIdToString(rs.getLong(4)) + "," + rs.getLong(5) + "] has already updated resource '" + resourceName + "'"; LOG.info(msg);
LOG.info("Nth commitTxn(" + JavaUtils.txnIdToString(txnid) + ") msg"); return; if (rs.next()) { String committedTxn = "[" + JavaUtils.txnIdToString(rs.getLong(1)) + "," + rs.getLong(2) + "]"; StringBuilder resource = new StringBuilder(rs.getString(3)).append("/").append(rs.getString(4)); String partitionName = rs.getString(5); resource.append('/').append(partitionName); String msg = "Aborting [" + JavaUtils.txnIdToString(txnid) + "," + rs.getLong(6) + "]" + " due to a write conflict on " + resource + " committed by " + committedTxn + " " + rs.getString(7) + "/" + rs.getString(8); close(rs); "completed_txn_components when committing txn! " + JavaUtils.txnIdToString(txnid));
deleteReplTxnMapEntry(dbConn, sourceTxnId, rqst.getReplPolicy()); LOG.info("abortTxn(" + JavaUtils.txnIdToString(txnid) + ") requested by it is already " + TxnStatus.ABORTED); return;
+ " agentInfo=" + rqst.getAgentInfo() + " " + JavaUtils.txnIdToString(txnid));