@Test
  public void testMsckRepair() throws Exception {
    dropTable(new String[] { "tab_acid", "tab_acid_msck"});

    driver.run("create table tab_acid (a int, b int) partitioned by (p string) " +
      "stored as orc TBLPROPERTIES ('transactional'='true')");
    driver.run("insert into tab_acid partition(p) values (1,1,'p1'),(2,2,'p1'),(3,3,'p1')");
    driver.run("insert into tab_acid partition(p) values (1,2,'p1'),(2,3,'p1'),(3,4,'p1')");

    // Create target table
    driver.run("create table tab_acid_msck (a int, b int) partitioned by (p string) " +
      " stored as orc TBLPROPERTIES ('transactional'='true')");

    // copy files on fs
    FileSystem fs = FileSystem.get(conf);
    FileUtil.copy(fs, new Path(getWarehouseDir() + "/tab_acid/p=p1"), fs,
      new Path(getWarehouseDir(), "tab_acid_msck"), false, conf);

    FileStatus[] fileStatuses = fs.listStatus(new Path(getWarehouseDir(), "tab_acid_msck/p=p1"));
    Assert.assertEquals(2, fileStatuses.length);

    HiveConf.setBoolVar(conf, HiveConf.ConfVars.HIVE_ACID_LOCKLESS_READS_ENABLED, true);
    // call msck repair
    driver.compileAndRespond("msck repair table tab_acid_msck");
    txnMgr.acquireLocks(driver.getPlan(), ctx, "Fiddler");
    List<ShowLocksResponseElement> locks = getLocks();
    Assert.assertEquals("Unexpected lock count", 1, locks.size());
    TestTxnDbUtil.checkLock(LockType.EXCL_WRITE, LockState.ACQUIRED, "default", "tab_acid_msck", null, locks);

    //simulate concurrent session
    DbTxnManager txnMgr2 = (DbTxnManager) TxnManagerFactory.getTxnManagerFactory().getTxnManager(conf);
    swapTxnManager(txnMgr2);
    driver.compileAndRespond("insert into tab_acid_msck partition(p) values (1,3,'p1'),(2,4,'p1'),(3,5,'p1')", true);
    txnMgr2.acquireLocks(driver.getPlan(), ctx, "Fiddler", false);
    locks = getLocks();
    Assert.assertEquals("Unexpected lock count", 2, locks.size());
    TestTxnDbUtil.checkLock(LockType.EXCL_WRITE, LockState.ACQUIRED, "default", "tab_acid_msck", null, locks);
    TestTxnDbUtil.checkLock(LockType.SHARED_WRITE, LockState.WAITING, "default", "tab_acid_msck", null, locks);

    txnMgr2.rollbackTxn();
    txnMgr.commitTxn();
  }
T7 is a table with 2 partitions
1. run select from T7
2. run drop partition from T7
concurrently with 1 starting first so that 2 blocks
3. start another concurrent select on T7 - it should block behind waiting X (from drop) - LM should be fair
4. finish #1 so that drop unblocks
5. rollback the drop to release its X lock
6. # should unblock
ql/src/test/org/apache/hadoop/hive/ql/lockmgr/TestDbTxnManager2.java