Skip to content

Commit

Permalink
HIVE-23894 - SubmitDag should not be retried incase of query cancel (a…
Browse files Browse the repository at this point in the history
  • Loading branch information
nareshpr authored Jul 30, 2020
1 parent ffbbd84 commit ee27dd3
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions ql/src/java/org/apache/hadoop/hive/ql/exec/tez/TezTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,11 @@ DAGClient submit(DAG dag, Ref<TezSessionState> sessionStateRef) throws Exception
dagClient = sessionState.getSession().submitDAG(dag);
}
} catch (Exception e) {
if (this.isShutdown) {
// Incase of taskShutdown, no need to retry
sessionDestroyOrReturnToPool(sessionStateRef, sessionState);
throw e;
}
// In case of any other exception, retry. If this also fails, report original error and exit.
try {
console.printInfo("Dag submit failed due to " + e.getMessage() + " stack trace: "
Expand All @@ -588,12 +593,7 @@ DAGClient submit(DAG dag, Ref<TezSessionState> sessionStateRef) throws Exception
// we failed to submit after retrying.
// If this is a non-pool session, destroy it.
// Otherwise move it to sessionPool, reopen will retry.
sessionStateRef.value = null;
if (sessionState.isDefault() && sessionState instanceof TezSessionPoolSession) {
sessionState.returnToSessionManager();
} else {
sessionState.destroy();
}
sessionDestroyOrReturnToPool(sessionStateRef, sessionState);
throw retryException;
}
}
Expand All @@ -602,6 +602,16 @@ DAGClient submit(DAG dag, Ref<TezSessionState> sessionStateRef) throws Exception
return new SyncDagClient(dagClient);
}

private void sessionDestroyOrReturnToPool(Ref<TezSessionState> sessionStateRef,
TezSessionState sessionState) throws Exception{
sessionStateRef.value = null;
if (sessionState.isDefault() && sessionState instanceof TezSessionPoolSession) {
sessionState.returnToSessionManager();
} else {
sessionState.destroy();
}
}

/*
* close will move the temp files into the right place for the fetch
* task. If the job has failed it will clean up the files.
Expand Down

0 comments on commit ee27dd3

Please sign in to comment.