@Override public void abort_txns(AbortTxnsRequest rqst) throws TException { getTxnHandler().abortTxns(rqst); if (listeners != null && !listeners.isEmpty()) { for (Long txnId : rqst.getTxn_ids()) { MetaStoreListenerNotifier.notifyEvent(listeners, EventType.ABORT_TXN, new AbortTxnEvent(txnId, this)); } } }
@Test public void testReplOpenTxn() throws Exception { int numTxn = 50000; String[] output = TxnDbUtil.queryToString(conf, "select ntxn_next from NEXT_TXN_ID").split("\n"); long startTxnId = Long.parseLong(output[1].trim()); List<Long> txnList = replOpenTxnForTest(startTxnId, numTxn, "default.*"); assert(txnList.size() == numTxn); txnHandler.abortTxns(new AbortTxnsRequest(txnList)); }
@Test public void cleanEmptyAbortedTxns() throws Exception { // Test that we are cleaning aborted transactions with no components left in txn_components. // Put one aborted transaction with an entry in txn_components to make sure we don't // accidently clean it too. Table t = newTable("default", "ceat", false); long txnid = openTxn(); LockComponent comp = new LockComponent(LockType.SHARED_WRITE, LockLevel.TABLE, "default"); comp.setTablename("ceat"); comp.setOperationType(DataOperationType.UPDATE); List<LockComponent> components = new ArrayList<LockComponent>(1); components.add(comp); LockRequest req = new LockRequest(components, "me", "localhost"); req.setTxnid(txnid); LockResponse res = txnHandler.lock(req); txnHandler.abortTxn(new AbortTxnRequest(txnid)); conf.setIntVar(HiveConf.ConfVars.HIVE_TXN_MAX_OPEN_BATCH, TxnStore.TIMED_OUT_TXN_ABORT_BATCH_SIZE + 50); OpenTxnsResponse resp = txnHandler.openTxns(new OpenTxnRequest( TxnStore.TIMED_OUT_TXN_ABORT_BATCH_SIZE + 50, "user", "hostname")); txnHandler.abortTxns(new AbortTxnsRequest(resp.getTxn_ids())); GetOpenTxnsResponse openTxns = txnHandler.getOpenTxns(); Assert.assertEquals(TxnStore.TIMED_OUT_TXN_ABORT_BATCH_SIZE + 50 + 1, openTxns.getOpen_txnsSize()); startInitiator(); openTxns = txnHandler.getOpenTxns(); Assert.assertEquals(1, openTxns.getOpen_txnsSize()); }
@Override public void abort_txns(AbortTxnsRequest rqst) throws TException { getTxnHandler().abortTxns(rqst); if (listeners != null && !listeners.isEmpty()) { for (Long txnId : rqst.getTxn_ids()) { MetaStoreListenerNotifier.notifyEvent(listeners, EventType.ABORT_TXN, new AbortTxnEvent(txnId, this)); } } }