@Test
  public void testMmTableAbortWithCompactionNoCleanup() throws Exception {
    // 1. Insert some rows into MM table
    runStatementOnDriver("insert into " + Table.MMTBL + "(a,b) values(1,2)");
    runStatementOnDriver("insert into " + Table.MMTBL + "(a,b) values(5,6)");
    // There should be 1 delta directory
    int [][] resultData1 =  new int[][] {{1,2}, {5,6}};
    verifyDeltaDirAndResult(2, Table.MMTBL.toString(), "", resultData1);
    List<String> r1 = runStatementOnDriver("select count(*) from " + Table.MMTBL);
    Assert.assertEquals("2", r1.get(0));

    // 2. Let a transaction be aborted
    hiveConf.setBoolVar(HiveConf.ConfVars.HIVE_TEST_MODE_ROLLBACK_TXN, true);
    runStatementOnDriver("insert into " + Table.MMTBL + " values(3,4)");
    hiveConf.setBoolVar(HiveConf.ConfVars.HIVE_TEST_MODE_ROLLBACK_TXN, false);
    // There should be 1 delta and 1 base directory. The base one is the aborted one.
    verifyDeltaDirAndResult(3, Table.MMTBL.toString(), "", resultData1);
    r1 = runStatementOnDriver("select count(*) from " + Table.MMTBL);
    Assert.assertEquals("2", r1.get(0));

    // 3. Perform a MINOR compaction, expectation is it should remove aborted base dir
    runStatementOnDriver("alter table "+ Table.MMTBL + " compact 'MINOR'");
    // The worker should remove the subdir for aborted transaction
    runWorker(hiveConf);
    verifyDeltaDirAndResult(3, Table.MMTBL.toString(), "", resultData1);
    verifyBaseDir(0, Table.MMTBL.toString(), "");
    // Verify query result
    List<String> rs = runStatementOnDriver("select a,b from " + Table.MMTBL + " order by a");
    Assert.assertEquals(stringifyValues(resultData1), rs);

    int [][] resultData3 = new int[][] {{1,2}, {5,6}, {7,8}};
    // 4. add few more rows
    runStatementOnDriver("insert into " + Table.MMTBL + "(a,b) values(7,8)");
    // 5. add one more aborted delta
    hiveConf.setBoolVar(HiveConf.ConfVars.HIVE_TEST_MODE_ROLLBACK_TXN, true);
    runStatementOnDriver("insert into " + Table.MMTBL + "(a,b) values(9,10)");
    hiveConf.setBoolVar(HiveConf.ConfVars.HIVE_TEST_MODE_ROLLBACK_TXN, false);
    verifyDeltaDirAndResult(5, Table.MMTBL.toString(), "", resultData3);

    // 6. Perform a MAJOR compaction, expectation is it should remove aborted delta dir
    runStatementOnDriver("alter table "+ Table.MMTBL + " compact 'MAJOR'");
    runWorker(hiveConf);
    verifyDeltaDirAndResult(4, Table.MMTBL.toString(), "", resultData3);
    verifyBaseDir(1, Table.MMTBL.toString(), "");

    // 7. Run one more Major compaction this should have been refused because there are no changes in the table
    CompactionResponse resp = txnHandler.compact(new CompactionRequest("default", Table.MMTBL.name.toLowerCase(), CompactionType.MAJOR));
    Assert.assertFalse(resp.isAccepted());
    Assert.assertEquals(TxnStore.REFUSED_RESPONSE, resp.getState());
    Assert.assertEquals("Compaction is already scheduled with state='ready for cleaning' and id=2", resp.getErrormessage());

    runCleaner(hiveConf);

    // Verify query result
    rs = runStatementOnDriver("select a,b from " + Table.MMTBL + " order by a");
    Assert.assertEquals(stringifyValues(resultData3), rs);
  }
Test cleaner for TXN_TO_WRITE_ID table.
@throws Exception
ql/src/test/org/apache/hadoop/hive/ql/TestTxnCommands2.java