String getValidTxnListForReplDump(Hive hiveDb, long waitUntilTime) throws HiveException {
    // Key design point for REPL DUMP is to not have any txns older than current txn in which
    // dump runs. This is needed to ensure that Repl dump doesn't copy any data files written by
    // any open txns mainly for streaming ingest case where one delta file shall have data from
    // committed/aborted/open txns. It may also have data inconsistency if the on-going txns
    // doesn't have corresponding open/write events captured which means, catch-up incremental
    // phase won't be able to replicate those txns. So, the logic is to wait for the given amount
    // of time to see if all open txns < current txn is getting aborted/committed. If not, then
    // we forcefully abort those txns just like AcidHouseKeeperService.
    //Exclude readonly and repl created transactions
    HiveTxnManager hiveTxnManager = getTxnMgr();
    ValidTxnList validTxnList = hiveTxnManager.getValidTxns(excludedTxns);
    while (System.currentTimeMillis() < waitUntilTime) {
      //check if no open txns at all
      List<Long> openTxnListForAllDbs = getOpenTxns(validTxnList);
      if (openTxnListForAllDbs.isEmpty()) {
        return validTxnList.toString();
      }
      //check if all transactions that are open are inserted into the hive locks table. If not wait and check again.
      //Transactions table don't contain the db information. DB information is present only in the hive locks table.
      //Transactions are inserted into the hive locks table after compilation. We need to make sure all transactions
      //that are open have a entry in hive locks which can give us the db information and then we only wait for open
      //transactions for the db under replication and not for all open transactions.
      if (getTxnsNotPresentInHiveLocksTable(openTxnListForAllDbs).isEmpty()) {
        //If all open txns have been inserted in the hive locks table, we just need to check for the db under replication
        // If there are no txns which are open for the given db under replication, then just return it.
        if (getOpenTxns(hiveTxnManager, validTxnList, work.dbNameOrPattern).isEmpty()) {
          return validTxnList.toString();
        }
      }
      // Wait for 5 minutes and check again.
      try {
        Thread.sleep(getSleepTime());
      } catch (InterruptedException e) {
        LOG.info("REPL DUMP thread sleep interrupted", e);
      }
      validTxnList = hiveTxnManager.getValidTxns(excludedTxns);
    }

    // After the timeout just force abort the open txns
    if (conf.getBoolVar(REPL_BOOTSTRAP_DUMP_ABORT_WRITE_TXN_AFTER_TIMEOUT)) {
      List<Long> openTxns = getOpenTxns(hiveTxnManager, validTxnList, work.dbNameOrPattern);
      if (!openTxns.isEmpty()) {
        //abort only write transactions for the db under replication if abort transactions is enabled.
        hiveDb.abortTransactions(openTxns, TxnErrorMsg.ABORT_WRITE_TXN_AFTER_TIMEOUT.getErrorCode());
        validTxnList = hiveTxnManager.getValidTxns(excludedTxns);
        openTxns = getOpenTxns(hiveTxnManager, validTxnList, work.dbNameOrPattern);
        if (!openTxns.isEmpty()) {
          LOG.warn("REPL DUMP unable to force abort all the open txns: {} after timeout due to unknown reasons. " +
            "However, this is rare case that shouldn't happen.", openTxns);
          throw new IllegalStateException("REPL DUMP triggered abort txns failed for unknown reasons.");
        }
      }
    } else {
      LOG.warn("Force abort all the open txns is disabled after timeout");
      throw new IllegalStateException("REPL DUMP cannot proceed. Force abort all the open txns is disabled. Enable " +
        "hive.repl.bootstrap.dump.abort.write.txn.after.timeout to proceed.");
    }
    return validTxnList.toString();
  }
Get if there is an entry for the txn id in the hive locks table. It can be in waiting state or acquired state.
@param txnId
@return true if the entry for the txn id is present in hive locks.
@throws LockException
ql/src/java/org/apache/hadoop/hive/ql/exec/repl/ReplDumpTask.java