public void discardSessionOnFailure(WmTezSession session) {
      if (session == null) return;
      session.clearWm();
      session.setQueryId(null);
      // We can just restart the session if we have received one.
      try {
        tezAmPool.replaceSession(session);
      } catch (Exception e) {
        LOG.error("Failed to restart a failed session", e);
      }
    }
The class that serves as a synchronization point, and future callback,
for async session initialization, as well as parallel cancellation.
ql/src/java/org/apache/hadoop/hive/ql/exec/tez/WorkloadManager.java