@Override public void acquireLocks(QueryPlan plan, Context ctx, String username) throws LockException { try { acquireLocksWithHeartbeatDelay(plan, ctx, username, 0); } catch(LockException e) { if(e.getCause() instanceof TxnAbortedException) { txnId = 0; stmtId = -1; tableWriteIds.clear(); } throw e; } }
@Override public void acquireLocks(QueryPlan plan, Context ctx, String username) throws LockException { try { acquireLocksWithHeartbeatDelay(plan, ctx, username, 0); } catch(LockException e) { if(e.getCause() instanceof TxnAbortedException) { txnId = 0; statementId = -1; } throw e; } }
@Ignore("This seems useless now that we have a txn for everything") @Test public void testLockTimeout() throws Exception { addPartitionInput(newTable(true)); QueryPlan qp = new MockQueryPlan(this, HiveOperation.QUERY); //make sure it works with nothing to expire testLockExpiration(txnMgr, 0, true); //create a few read locks, all on the same resource for(int i = 0; i < 5; i++) { ((DbTxnManager)txnMgr).acquireLocks(qp, ctx, "PeterI" + i, true); // No heartbeat } testLockExpiration(txnMgr, 5, true); //create a lot of locks for(int i = 0; i < TEST_TIMED_OUT_TXN_ABORT_BATCH_SIZE + 17; i++) { ((DbTxnManager)txnMgr).acquireLocks(qp, ctx, "PeterI" + i, true); // No heartbeat } testLockExpiration(txnMgr, TEST_TIMED_OUT_TXN_ABORT_BATCH_SIZE + 17, true); // Create a lock, but send the heartbeat with a long delay. The lock will get expired. ((DbTxnManager)txnMgr).acquireLocksWithHeartbeatDelay(qp, ctx, "bob", HiveConf.getTimeVar(conf, HiveConf.ConfVars.HIVE_TXN_TIMEOUT, TimeUnit.MILLISECONDS) * 10); testLockExpiration(txnMgr, 1, true); // Create a lock and trigger a heartbeat. With heartbeat, the lock won't expire. txnMgr.acquireLocks(qp, ctx, "peter"); testLockExpiration(txnMgr, 1, false); }