@Override
  public void lossLeadership(LeaderElection election) throws Exception {
    if (metastoreTaskThreadPool != null) {
      metastoreTaskThreadPool.shutdown();
      metastoreTaskThreadPool = null;
    }

    if (runningTasks != null && !runningTasks.isEmpty()) {
      runningTasks.forEach(task -> {
        HiveMetaStore.LOG.info("Stopped the Housekeeping task: {}", task.getClass().getCanonicalName());
      });
      runningTasks.clear();
    }
  }
invoke setConf(Configuration conf) before running
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/leader/HouseKeepingTasks.java