private TxnStore getTxnHandler() {
    boolean hackOn = MetastoreConf.getBoolVar(conf, ConfVars.HIVE_IN_TEST) ||
        MetastoreConf.getBoolVar(conf, ConfVars.HIVE_IN_TEZ_TEST);
    String origTxnMgr = null;
    boolean origConcurrency = false;

    // Since TxnUtils.getTxnStore calls TxnHandler.setConf -> checkQFileTestHack -> TxnDbUtil.setConfValues,
    // which may change the values of below two entries, we need to avoid polluting the original values
    if (hackOn) {
      origTxnMgr = MetastoreConf.getVar(conf, ConfVars.HIVE_TXN_MANAGER);
      origConcurrency = MetastoreConf.getBoolVar(conf, ConfVars.HIVE_SUPPORT_CONCURRENCY);
    }

    txnHandler = TxnUtils.getTxnStore(conf);

    // Set them back
    if (hackOn) {
      MetastoreConf.setVar(conf, ConfVars.HIVE_TXN_MANAGER, origTxnMgr);
      MetastoreConf.setBoolVar(conf, ConfVars.HIVE_SUPPORT_CONCURRENCY, origConcurrency);
    }

    return txnHandler;
  }
It handles cleanup of dropped partition/table/database in ACID related metastore tables
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/AcidEventListener.java