private void checkReplTxnForTest(Long startTxnId, Long endTxnId, String replPolicy, List<Long> targetTxnId)
          throws Exception {
    String[] output = TestTxnDbUtil.queryToString(conf, "SELECT \"RTM_TARGET_TXN_ID\" FROM \"REPL_TXN_MAP\" WHERE " +
            " \"RTM_SRC_TXN_ID\" >=  " + startTxnId + "AND \"RTM_SRC_TXN_ID\" <=  " + endTxnId +
            " AND \"RTM_REPL_POLICY\" = \'" + replPolicy + "\'").split("\n");
    assertEquals(output.length - 1, targetTxnId.size());
    for (int idx = 1; idx < output.length; idx++) {
      long txnId = Long.parseLong(output[idx].trim());
      assertEquals(txnId, targetTxnId.get(idx-1).longValue());
    }
  }
counter = 0;
Thread1 counter=1, lock, wait 3s, check counter(should be 2), counter=3, unlock
Thread2 counter=2, lock (and block), inc counter, should be 4
ql/src/test/org/apache/hadoop/hive/metastore/txn/TestTxnHandler.java