private void abortOpenTxnsForDatabase(HiveTxnManager hiveTxnManager, ValidTxnList validTxnList, String dbName,
                                        Hive hiveDb) throws HiveException {
    List<Long> openTxns = ReplUtils.getOpenTxns(hiveTxnManager, validTxnList, dbName);
    if (!openTxns.isEmpty()) {
      LOG.info("Rolling back write txns:" + openTxns.toString() + " for the database: " + dbName);
      //abort only write transactions for the current database if abort transactions is enabled.
      hiveDb.abortTransactions(openTxns, TxnErrorMsg.ABORT_ONGOING_TXN_FOR_TARGET_DB.getErrorCode());
      validTxnList = hiveTxnManager.getValidTxns(excludedTxns);
      openTxns = ReplUtils.getOpenTxns(hiveTxnManager, validTxnList, dbName);
      if (!openTxns.isEmpty()) {
        LOG.warn("Unable to force abort all the open txns: {}.", openTxns);
        throw new IllegalStateException("Failover triggered abort txns request failed for unknown reasons.");
      }
    }
  }
There was a database update done before and we want to make sure we update the last repl
id on this database as we are now going to switch to processing a new database.
This has to be last task in the graph since if there are intermediate tasks and the last.repl.id
is a root level task then in the execution phase the root level tasks will get executed first,
however if any of the child tasks of the bootstrap load failed then even though the bootstrap has failed
the last repl status of the target database will return a valid value, which will not represent
the state of the database.
ql/src/java/org/apache/hadoop/hive/ql/exec/repl/ReplLoadTask.java