use of org.apache.hadoop.hive.ql.processors.CommandProcessorResponse in project hive by apache.
the class TestDbTxnManager2 method testCompletedTxnComponents.
@Test
public void testCompletedTxnComponents() throws Exception {
dropTable(new String[] { "TAB1", "tab_not_acid2" });
CommandProcessorResponse cpr = driver.run("create table if not exists tab1 (a int, b int) partitioned by (p string) " + "clustered by (a) into 2 buckets stored as orc TBLPROPERTIES ('transactional'='true')");
checkCmdOnDriver(cpr);
cpr = driver.run("create table if not exists tab_not_acid2 (a int, b int)");
checkCmdOnDriver(cpr);
checkCmdOnDriver(driver.run("insert into tab_not_acid2 values(1,1),(2,2)"));
//writing both acid and non-acid resources in the same txn
//txnid:1
checkCmdOnDriver(driver.run("from tab_not_acid2 insert into tab1 partition(p='two')(a,b) select a,b insert into tab_not_acid2(a,b) select a,b "));
Assert.assertEquals(TxnDbUtil.queryToString("select * from COMPLETED_TXN_COMPONENTS"), 1, TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_TXN_COMPONENTS"));
//only expect transactional components to be in COMPLETED_TXN_COMPONENTS
Assert.assertEquals(TxnDbUtil.queryToString("select * from COMPLETED_TXN_COMPONENTS"), 1, TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_TXN_COMPONENTS where ctc_txnid=1 and ctc_table='tab1'"));
}
use of org.apache.hadoop.hive.ql.processors.CommandProcessorResponse in project hive by apache.
the class TestDbTxnManager2 method testWriteSetTracking9.
/**
* Concurrent update/delete of different partitions - should pass
*/
@Test
public void testWriteSetTracking9() throws Exception {
dropTable(new String[] { "TAB1" });
CommandProcessorResponse cpr = driver.run("create table if not exists tab1 (a int, b int) partitioned by (p string) " + "clustered by (a) into 2 buckets stored as orc TBLPROPERTIES ('transactional'='true')");
checkCmdOnDriver(cpr);
//txnid:1
checkCmdOnDriver(driver.run("insert into tab1 partition(p)(a,b,p) values(1,1,'one'),(2,2,'two')"));
HiveTxnManager txnMgr2 = TxnManagerFactory.getTxnManagerFactory().getTxnManager(conf);
txnMgr2.openTxn(ctx, "T2");
checkCmdOnDriver(driver.compileAndRespond("update tab1 set b = 7 where b=1"));
txnMgr2.acquireLocks(driver.getPlan(), ctx, "T2");
List<ShowLocksResponseElement> locks = getLocks(txnMgr2);
Assert.assertEquals("Unexpected lock count", 2, locks.size());
checkLock(LockType.SHARED_WRITE, LockState.ACQUIRED, "default", "TAB1", "p=two", locks);
checkLock(LockType.SHARED_WRITE, LockState.ACQUIRED, "default", "TAB1", "p=one", locks);
//now start concurrent txn
txnMgr.openTxn(ctx, "T3");
checkCmdOnDriver(driver.compileAndRespond("delete from tab1 where p='two' and b=2"));
((DbTxnManager) txnMgr).acquireLocks(driver.getPlan(), ctx, "T3", false);
locks = getLocks(txnMgr);
Assert.assertEquals("Unexpected lock count", 3, locks.size());
checkLock(LockType.SHARED_WRITE, LockState.ACQUIRED, "default", "TAB1", "p=two", locks);
checkLock(LockType.SHARED_WRITE, LockState.ACQUIRED, "default", "TAB1", "p=one", locks);
checkLock(LockType.SHARED_WRITE, LockState.WAITING, "default", "TAB1", "p=two", locks);
//this simulates the completion of txnid:2
AddDynamicPartitions adp = new AddDynamicPartitions(txnMgr2.getCurrentTxnId(), "default", "tab1", Collections.singletonList("p=one"));
adp.setOperationType(DataOperationType.UPDATE);
txnHandler.addDynamicPartitions(adp);
//txnid:2
txnMgr2.commitTxn();
//retest WAITING locks (both have same ext id)
((DbLockManager) txnMgr.getLockManager()).checkLock(locks.get(2).getLockid());
locks = getLocks(txnMgr);
Assert.assertEquals("Unexpected lock count", 1, locks.size());
checkLock(LockType.SHARED_WRITE, LockState.ACQUIRED, "default", "TAB1", "p=two", locks);
//completion of txnid:3
adp = new AddDynamicPartitions(txnMgr.getCurrentTxnId(), "default", "tab1", Collections.singletonList("p=two"));
adp.setOperationType(DataOperationType.DELETE);
txnHandler.addDynamicPartitions(adp);
//txnid:3
txnMgr.commitTxn();
Assert.assertEquals("WRITE_SET mismatch: " + TxnDbUtil.queryToString("select * from COMPLETED_TXN_COMPONENTS"), 2, TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_TXN_COMPONENTS where ctc_txnid=1 and ctc_table='tab1'"));
Assert.assertEquals("WRITE_SET mismatch: " + TxnDbUtil.queryToString("select * from COMPLETED_TXN_COMPONENTS"), 1, TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_TXN_COMPONENTS where ctc_txnid=2 and ctc_table='tab1' and ctc_partition='p=one'"));
Assert.assertEquals("WRITE_SET mismatch: " + TxnDbUtil.queryToString("select * from COMPLETED_TXN_COMPONENTS"), 1, TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_TXN_COMPONENTS where ctc_txnid=3 and ctc_table='tab1' and ctc_partition='p=two'"));
Assert.assertEquals("WRITE_SET mismatch: " + TxnDbUtil.queryToString("select * from WRITE_SET"), 1, TxnDbUtil.countQueryAgent("select count(*) from WRITE_SET where ws_partition='p=one' and ws_operation_type='u' and ws_table='tab1'"));
Assert.assertEquals("WRITE_SET mismatch: " + TxnDbUtil.queryToString("select * from WRITE_SET"), 1, TxnDbUtil.countQueryAgent("select count(*) from WRITE_SET where ws_partition='p=two' and ws_operation_type='d' and ws_table='tab1'"));
Assert.assertEquals("COMPLETED_TXN_COMPONENTS mismatch: " + TxnDbUtil.queryToString("select * from COMPLETED_TXN_COMPONENTS"), 4, TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_TXN_COMPONENTS where ctc_table='tab1' and ctc_partition is not null"));
}
use of org.apache.hadoop.hive.ql.processors.CommandProcessorResponse in project hive by apache.
the class TestDbTxnManager2 method testWriteSetTracking3.
/**
* txns overlap and update the same resource - can't commit 2nd txn
*/
@Test
public void testWriteSetTracking3() throws Exception {
dropTable(new String[] { "TAB_PART" });
CommandProcessorResponse cpr = driver.run("create table if not exists TAB_PART (a int, b int) " + "partitioned by (p string) clustered by (a) into 2 buckets stored as orc TBLPROPERTIES ('transactional'='true')");
checkCmdOnDriver(cpr);
checkCmdOnDriver(driver.run("insert into TAB_PART partition(p='blah') values(1,2)"));
HiveTxnManager txnMgr2 = TxnManagerFactory.getTxnManagerFactory().getTxnManager(conf);
long txnId = txnMgr.openTxn(ctx, "Known");
long txnId2 = txnMgr2.openTxn(ctx, "Unknown");
checkCmdOnDriver(driver.compileAndRespond("update TAB_PART set b = 7 where p = 'blah'"));
txnMgr.acquireLocks(driver.getPlan(), ctx, "Known");
List<ShowLocksResponseElement> locks = getLocks(txnMgr);
Assert.assertEquals("Unexpected lock count", 1, locks.size());
checkLock(LockType.SHARED_WRITE, LockState.ACQUIRED, "default", "TAB_PART", "p=blah", locks);
checkCmdOnDriver(driver.compileAndRespond("update TAB_PART set b = 7 where p = 'blah'"));
((DbTxnManager) txnMgr2).acquireLocks(driver.getPlan(), ctx, "Unknown", false);
//should not matter which txnMgr is used here
locks = getLocks(txnMgr2);
Assert.assertEquals("Unexpected lock count", 2, locks.size());
checkLock(LockType.SHARED_WRITE, LockState.ACQUIRED, "default", "TAB_PART", "p=blah", locks);
checkLock(LockType.SHARED_WRITE, LockState.WAITING, "default", "TAB_PART", "p=blah", locks);
AddDynamicPartitions adp = new AddDynamicPartitions(txnId, "default", "TAB_PART", Collections.singletonList("p=blah"));
adp.setOperationType(DataOperationType.UPDATE);
txnHandler.addDynamicPartitions(adp);
txnMgr.commitTxn();
adp.setTxnid(txnId2);
txnHandler.addDynamicPartitions(adp);
LockException expectedException = null;
try {
//with HIVE-15032 this should use static parts and thus not need addDynamicPartitions
txnMgr2.commitTxn();
} catch (LockException e) {
expectedException = e;
}
Assert.assertTrue("Didn't get exception", expectedException != null);
Assert.assertEquals("Got wrong message code", ErrorMsg.TXN_ABORTED, expectedException.getCanonicalErrorMsg());
Assert.assertEquals("Exception msg didn't match", "Aborting [txnid:3,3] due to a write conflict on default/TAB_PART/p=blah committed by [txnid:2,3] u/u", expectedException.getCause().getMessage());
}
use of org.apache.hadoop.hive.ql.processors.CommandProcessorResponse in project hive by apache.
the class TestDbTxnManager2 method testWriteSetTracking6.
/**
* check that read query concurrent with txn works ok
*/
@Test
public void testWriteSetTracking6() throws Exception {
dropTable(new String[] { "TAB2" });
Assert.assertEquals(0, TxnDbUtil.countQueryAgent("select count(*) from WRITE_SET"));
CommandProcessorResponse cpr = driver.run("create table if not exists TAB2(a int, b int) clustered " + "by (a) into 2 buckets stored as orc TBLPROPERTIES ('transactional'='true')");
checkCmdOnDriver(cpr);
checkCmdOnDriver(driver.compileAndRespond("select * from TAB2 where a = 113"));
txnMgr.acquireLocks(driver.getPlan(), ctx, "Works");
List<ShowLocksResponseElement> locks = getLocks(txnMgr);
Assert.assertEquals("Unexpected lock count", 1, locks.size());
checkLock(LockType.SHARED_READ, LockState.ACQUIRED, "default", "TAB2", null, locks);
HiveTxnManager txnMgr2 = TxnManagerFactory.getTxnManagerFactory().getTxnManager(conf);
txnMgr2.openTxn(ctx, "Horton");
checkCmdOnDriver(driver.compileAndRespond("update TAB2 set b = 17 where a = 101"));
txnMgr2.acquireLocks(driver.getPlan(), ctx, "Horton");
Assert.assertEquals(0, TxnDbUtil.countQueryAgent("select count(*) from WRITE_SET"));
locks = getLocks(txnMgr);
Assert.assertEquals("Unexpected lock count", 2, locks.size());
checkLock(LockType.SHARED_READ, LockState.ACQUIRED, "default", "TAB2", null, locks);
checkLock(LockType.SHARED_WRITE, LockState.ACQUIRED, "default", "TAB2", null, locks);
//no conflict
txnMgr2.commitTxn();
Assert.assertEquals(1, TxnDbUtil.countQueryAgent("select count(*) from WRITE_SET"));
locks = getLocks(txnMgr);
Assert.assertEquals("Unexpected lock count", 1, locks.size());
checkLock(LockType.SHARED_READ, LockState.ACQUIRED, "default", "TAB2", null, locks);
TestTxnCommands2.runHouseKeeperService(new AcidWriteSetService(), conf);
Assert.assertEquals(0, TxnDbUtil.countQueryAgent("select count(*) from WRITE_SET"));
}
use of org.apache.hadoop.hive.ql.processors.CommandProcessorResponse in project hive by apache.
the class TestDbTxnManager2 method testMetastoreTablesCleanup.
/**
* Normally the compaction process will clean up records in TXN_COMPONENTS, COMPLETED_TXN_COMPONENTS,
* COMPACTION_QUEUE and COMPLETED_COMPACTIONS. But if a table/partition has been dropped before
* compaction and there are still relevant records in those metastore tables, the Initiator will
* complain about not being able to find the table/partition. This method is to test and make sure
* we clean up relevant records as soon as a table/partition is dropped.
*
* Note, here we don't need to worry about cleaning up TXNS table, since it's handled separately.
* @throws Exception
*/
@Test
public void testMetastoreTablesCleanup() throws Exception {
dropTable(new String[] { "temp.T10", "temp.T11", "temp.T12p", "temp.T13p" });
CommandProcessorResponse cpr = driver.run("create database if not exists temp");
checkCmdOnDriver(cpr);
// Create some ACID tables: T10, T11 - unpartitioned table, T12p, T13p - partitioned table
cpr = driver.run("create table temp.T10 (a int, b int) clustered by(b) into 2 buckets stored as orc TBLPROPERTIES ('transactional'='true')");
checkCmdOnDriver(cpr);
cpr = driver.run("create table temp.T11 (a int, b int) clustered by(b) into 2 buckets stored as orc TBLPROPERTIES ('transactional'='true')");
checkCmdOnDriver(cpr);
cpr = driver.run("create table temp.T12p (a int, b int) partitioned by (ds string, hour string) clustered by(b) into 2 buckets stored as orc TBLPROPERTIES ('transactional'='true')");
checkCmdOnDriver(cpr);
cpr = driver.run("create table temp.T13p (a int, b int) partitioned by (ds string, hour string) clustered by(b) into 2 buckets stored as orc TBLPROPERTIES ('transactional'='true')");
checkCmdOnDriver(cpr);
// Successfully insert some data into ACID tables, so that we have records in COMPLETED_TXN_COMPONENTS
cpr = driver.run("insert into temp.T10 values (1, 1)");
checkCmdOnDriver(cpr);
cpr = driver.run("insert into temp.T10 values (2, 2)");
checkCmdOnDriver(cpr);
cpr = driver.run("insert into temp.T11 values (3, 3)");
checkCmdOnDriver(cpr);
cpr = driver.run("insert into temp.T11 values (4, 4)");
checkCmdOnDriver(cpr);
cpr = driver.run("insert into temp.T12p partition (ds='today', hour='1') values (5, 5)");
checkCmdOnDriver(cpr);
cpr = driver.run("insert into temp.T12p partition (ds='tomorrow', hour='2') values (6, 6)");
checkCmdOnDriver(cpr);
cpr = driver.run("insert into temp.T13p partition (ds='today', hour='1') values (7, 7)");
checkCmdOnDriver(cpr);
cpr = driver.run("insert into temp.T13p partition (ds='tomorrow', hour='2') values (8, 8)");
checkCmdOnDriver(cpr);
int count = TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_TXN_COMPONENTS where CTC_DATABASE='temp' and CTC_TABLE in ('t10', 't11')");
Assert.assertEquals(4, count);
count = TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_TXN_COMPONENTS where CTC_DATABASE='temp' and CTC_TABLE in ('t12p', 't13p')");
Assert.assertEquals(4, count);
// Fail some inserts, so that we have records in TXN_COMPONENTS
conf.setBoolVar(HiveConf.ConfVars.HIVETESTMODEROLLBACKTXN, true);
cpr = driver.run("insert into temp.T10 values (9, 9)");
checkCmdOnDriver(cpr);
cpr = driver.run("insert into temp.T11 values (10, 10)");
checkCmdOnDriver(cpr);
cpr = driver.run("insert into temp.T12p partition (ds='today', hour='1') values (11, 11)");
checkCmdOnDriver(cpr);
cpr = driver.run("insert into temp.T13p partition (ds='today', hour='1') values (12, 12)");
checkCmdOnDriver(cpr);
count = TxnDbUtil.countQueryAgent("select count(*) from TXN_COMPONENTS where TC_DATABASE='temp' and TC_TABLE in ('t10', 't11', 't12p', 't13p')");
Assert.assertEquals(4, count);
conf.setBoolVar(HiveConf.ConfVars.HIVETESTMODEROLLBACKTXN, false);
// Drop a table/partition; corresponding records in TXN_COMPONENTS and COMPLETED_TXN_COMPONENTS should disappear
count = TxnDbUtil.countQueryAgent("select count(*) from TXN_COMPONENTS where TC_DATABASE='temp' and TC_TABLE='t10'");
Assert.assertEquals(1, count);
count = TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_TXN_COMPONENTS where CTC_DATABASE='temp' and CTC_TABLE='t10'");
Assert.assertEquals(2, count);
cpr = driver.run("drop table temp.T10");
checkCmdOnDriver(cpr);
count = TxnDbUtil.countQueryAgent("select count(*) from TXN_COMPONENTS where TC_DATABASE='temp' and TC_TABLE='t10'");
Assert.assertEquals(0, count);
count = TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_TXN_COMPONENTS where CTC_DATABASE='temp' and CTC_TABLE='t10'");
Assert.assertEquals(0, count);
count = TxnDbUtil.countQueryAgent("select count(*) from TXN_COMPONENTS where TC_DATABASE='temp' and TC_TABLE='t12p' and TC_PARTITION='ds=today/hour=1'");
Assert.assertEquals(1, count);
count = TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_TXN_COMPONENTS where CTC_DATABASE='temp' and CTC_TABLE='t12p' and CTC_PARTITION='ds=today/hour=1'");
Assert.assertEquals(1, count);
cpr = driver.run("alter table temp.T12p drop partition (ds='today', hour='1')");
checkCmdOnDriver(cpr);
count = TxnDbUtil.countQueryAgent("select count(*) from TXN_COMPONENTS where TC_DATABASE='temp' and TC_TABLE='t12p' and TC_PARTITION='ds=today/hour=1'");
Assert.assertEquals(0, count);
count = TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_TXN_COMPONENTS where CTC_DATABASE='temp' and CTC_TABLE='t12p' and CTC_PARTITION='ds=today/hour=1'");
Assert.assertEquals(0, count);
// Successfully perform compaction on a table/partition, so that we have successful records in COMPLETED_COMPACTIONS
cpr = driver.run("alter table temp.T11 compact 'minor'");
checkCmdOnDriver(cpr);
count = TxnDbUtil.countQueryAgent("select count(*) from COMPACTION_QUEUE where CQ_DATABASE='temp' and CQ_TABLE='t11' and CQ_STATE='i' and CQ_TYPE='i'");
Assert.assertEquals(1, count);
org.apache.hadoop.hive.ql.TestTxnCommands2.runWorker(conf);
count = TxnDbUtil.countQueryAgent("select count(*) from COMPACTION_QUEUE where CQ_DATABASE='temp' and CQ_TABLE='t11' and CQ_STATE='r' and CQ_TYPE='i'");
Assert.assertEquals(1, count);
org.apache.hadoop.hive.ql.TestTxnCommands2.runCleaner(conf);
count = TxnDbUtil.countQueryAgent("select count(*) from COMPACTION_QUEUE where CQ_DATABASE='temp' and CQ_TABLE='t11'");
Assert.assertEquals(0, count);
count = TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_COMPACTIONS where CC_DATABASE='temp' and CC_TABLE='t11' and CC_STATE='s' and CC_TYPE='i'");
Assert.assertEquals(1, count);
cpr = driver.run("alter table temp.T12p partition (ds='tomorrow', hour='2') compact 'minor'");
checkCmdOnDriver(cpr);
count = TxnDbUtil.countQueryAgent("select count(*) from COMPACTION_QUEUE where CQ_DATABASE='temp' and CQ_TABLE='t12p' and CQ_PARTITION='ds=tomorrow/hour=2' and CQ_STATE='i' and CQ_TYPE='i'");
Assert.assertEquals(1, count);
org.apache.hadoop.hive.ql.TestTxnCommands2.runWorker(conf);
count = TxnDbUtil.countQueryAgent("select count(*) from COMPACTION_QUEUE where CQ_DATABASE='temp' and CQ_TABLE='t12p' and CQ_PARTITION='ds=tomorrow/hour=2' and CQ_STATE='r' and CQ_TYPE='i'");
Assert.assertEquals(1, count);
org.apache.hadoop.hive.ql.TestTxnCommands2.runCleaner(conf);
count = TxnDbUtil.countQueryAgent("select count(*) from COMPACTION_QUEUE where CQ_DATABASE='temp' and CQ_TABLE='t12p'");
Assert.assertEquals(0, count);
count = TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_COMPACTIONS where CC_DATABASE='temp' and CC_TABLE='t12p' and CC_STATE='s' and CC_TYPE='i'");
Assert.assertEquals(1, count);
// Fail compaction, so that we have failed records in COMPLETED_COMPACTIONS
conf.setBoolVar(HiveConf.ConfVars.HIVETESTMODEFAILCOMPACTION, true);
cpr = driver.run("alter table temp.T11 compact 'major'");
checkCmdOnDriver(cpr);
count = TxnDbUtil.countQueryAgent("select count(*) from COMPACTION_QUEUE where CQ_DATABASE='temp' and CQ_TABLE='t11' and CQ_STATE='i' and CQ_TYPE='a'");
Assert.assertEquals(1, count);
// will fail
org.apache.hadoop.hive.ql.TestTxnCommands2.runWorker(conf);
count = TxnDbUtil.countQueryAgent("select count(*) from COMPACTION_QUEUE where CQ_DATABASE='temp' and CQ_TABLE='t11' and CQ_STATE='i' and CQ_TYPE='a'");
Assert.assertEquals(0, count);
count = TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_COMPACTIONS where CC_DATABASE='temp' and CC_TABLE='t11' and CC_STATE='f' and CC_TYPE='a'");
Assert.assertEquals(1, count);
cpr = driver.run("alter table temp.T12p partition (ds='tomorrow', hour='2') compact 'major'");
checkCmdOnDriver(cpr);
count = TxnDbUtil.countQueryAgent("select count(*) from COMPACTION_QUEUE where CQ_DATABASE='temp' and CQ_TABLE='t12p' and CQ_PARTITION='ds=tomorrow/hour=2' and CQ_STATE='i' and CQ_TYPE='a'");
Assert.assertEquals(1, count);
// will fail
org.apache.hadoop.hive.ql.TestTxnCommands2.runWorker(conf);
count = TxnDbUtil.countQueryAgent("select count(*) from COMPACTION_QUEUE where CQ_DATABASE='temp' and CQ_TABLE='t12p' and CQ_PARTITION='ds=tomorrow/hour=2' and CQ_STATE='i' and CQ_TYPE='a'");
Assert.assertEquals(0, count);
count = TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_COMPACTIONS where CC_DATABASE='temp' and CC_TABLE='t12p' and CC_STATE='f' and CC_TYPE='a'");
Assert.assertEquals(1, count);
conf.setBoolVar(HiveConf.ConfVars.HIVETESTMODEFAILCOMPACTION, false);
// Put 2 records into COMPACTION_QUEUE and do nothing
cpr = driver.run("alter table temp.T11 compact 'major'");
checkCmdOnDriver(cpr);
count = TxnDbUtil.countQueryAgent("select count(*) from COMPACTION_QUEUE where CQ_DATABASE='temp' and CQ_TABLE='t11' and CQ_STATE='i' and CQ_TYPE='a'");
Assert.assertEquals(1, count);
cpr = driver.run("alter table temp.T12p partition (ds='tomorrow', hour='2') compact 'major'");
checkCmdOnDriver(cpr);
count = TxnDbUtil.countQueryAgent("select count(*) from COMPACTION_QUEUE where CQ_DATABASE='temp' and CQ_TABLE='t12p' and CQ_PARTITION='ds=tomorrow/hour=2' and CQ_STATE='i' and CQ_TYPE='a'");
Assert.assertEquals(1, count);
// Drop a table/partition, corresponding records in COMPACTION_QUEUE and COMPLETED_COMPACTIONS should disappear
cpr = driver.run("drop table temp.T11");
checkCmdOnDriver(cpr);
count = TxnDbUtil.countQueryAgent("select count(*) from COMPACTION_QUEUE where CQ_DATABASE='temp' and CQ_TABLE='t11'");
Assert.assertEquals(0, count);
count = TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_COMPACTIONS where CC_DATABASE='temp' and CC_TABLE='t11'");
Assert.assertEquals(0, count);
cpr = driver.run("alter table temp.T12p drop partition (ds='tomorrow', hour='2')");
checkCmdOnDriver(cpr);
count = TxnDbUtil.countQueryAgent("select count(*) from COMPACTION_QUEUE where CQ_DATABASE='temp' and CQ_TABLE='t12p'");
Assert.assertEquals(0, count);
count = TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_COMPACTIONS where CC_DATABASE='temp' and CC_TABLE='t12p'");
Assert.assertEquals(0, count);
// Put 1 record into COMPACTION_QUEUE and do nothing
cpr = driver.run("alter table temp.T13p partition (ds='today', hour='1') compact 'major'");
checkCmdOnDriver(cpr);
count = TxnDbUtil.countQueryAgent("select count(*) from COMPACTION_QUEUE where CQ_DATABASE='temp' and CQ_TABLE='t13p' and CQ_STATE='i' and CQ_TYPE='a'");
Assert.assertEquals(1, count);
// Drop database, everything in all 4 meta tables should disappear
count = TxnDbUtil.countQueryAgent("select count(*) from TXN_COMPONENTS where TC_DATABASE='temp' and TC_TABLE in ('t10', 't11', 't12p', 't13p')");
Assert.assertEquals(1, count);
count = TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_TXN_COMPONENTS where CTC_DATABASE='temp' and CTC_TABLE in ('t10', 't11', 't12p', 't13p')");
Assert.assertEquals(2, count);
count = TxnDbUtil.countQueryAgent("select count(*) from COMPACTION_QUEUE where CQ_DATABASE='temp' and CQ_TABLE in ('t10', 't11', 't12p', 't13p')");
Assert.assertEquals(1, count);
count = TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_COMPACTIONS where CC_DATABASE='temp' and CC_TABLE in ('t10', 't11', 't12p', 't13p')");
Assert.assertEquals(0, count);
cpr = driver.run("drop database if exists temp cascade");
checkCmdOnDriver(cpr);
count = TxnDbUtil.countQueryAgent("select count(*) from TXN_COMPONENTS where TC_DATABASE='temp' and TC_TABLE in ('t10', 't11', 't12p', 't13p')");
Assert.assertEquals(0, count);
count = TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_TXN_COMPONENTS where CTC_DATABASE='temp' and CTC_TABLE in ('t10', 't11', 't12p', 't13p')");
Assert.assertEquals(0, count);
count = TxnDbUtil.countQueryAgent("select count(*) from COMPACTION_QUEUE where CQ_DATABASE='temp' and CQ_TABLE in ('t10', 't11', 't12p', 't13p')");
Assert.assertEquals(0, count);
count = TxnDbUtil.countQueryAgent("select count(*) from COMPLETED_COMPACTIONS where CC_DATABASE='temp' and CC_TABLE in ('t10', 't11', 't12p', 't13p')");
Assert.assertEquals(0, count);
}
Aggregations