This is an automated email from the ASF dual-hosted git repository.
dengzhhu653 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git
The following commit(s) were added to refs/heads/master by this push:
new 64f6a58b9b2 HIVE-30032: Retry the execution upon SessionNotRunning
(#6771)
64f6a58b9b2 is described below
commit 64f6a58b9b2e7a8c3439f407bc03025a42c1643c
Author: dengzh <[email protected]>
AuthorDate: Fri Sep 11 14:11:36 2026 +0800
HIVE-30032: Retry the execution upon SessionNotRunning (#6771)
---
.../hive/ql/reexec/ReExecuteLostAMQueryPlugin.java | 6 ++++++
.../hive/ql/reexec/TestReExecuteLostAMQueryPlugin.java | 18 ++++++++++++++++++
2 files changed, 24 insertions(+)
diff --git
a/ql/src/java/org/apache/hadoop/hive/ql/reexec/ReExecuteLostAMQueryPlugin.java
b/ql/src/java/org/apache/hadoop/hive/ql/reexec/ReExecuteLostAMQueryPlugin.java
index eeb3a5006cc..c724e84b13f 100644
---
a/ql/src/java/org/apache/hadoop/hive/ql/reexec/ReExecuteLostAMQueryPlugin.java
+++
b/ql/src/java/org/apache/hadoop/hive/ql/reexec/ReExecuteLostAMQueryPlugin.java
@@ -24,6 +24,7 @@
import org.apache.hadoop.hive.ql.hooks.ExecuteWithHookContext;
import org.apache.hadoop.hive.ql.hooks.HookContext;
import org.apache.hadoop.hive.ql.plan.mapper.PlanMapper;
+import org.apache.tez.dag.api.SessionNotRunning;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -58,6 +59,11 @@ public void run(HookContext hookContext) throws Exception {
if (hookContext.getHookType() == HookContext.HookType.ON_FAILURE_HOOK) {
Throwable exception = hookContext.getException();
+ if (exception instanceof SessionNotRunning) {
+ retryPossible = true;
+ return;
+ }
+
if (!(exception instanceof TezRuntimeException)) {
LOG.info("Exception is not a TezRuntimeException, no need to check
further with ReExecuteLostAMQueryPlugin");
return;
diff --git
a/ql/src/test/org/apache/hadoop/hive/ql/reexec/TestReExecuteLostAMQueryPlugin.java
b/ql/src/test/org/apache/hadoop/hive/ql/reexec/TestReExecuteLostAMQueryPlugin.java
index 527a5bc1677..31fc7bec441 100644
---
a/ql/src/test/org/apache/hadoop/hive/ql/reexec/TestReExecuteLostAMQueryPlugin.java
+++
b/ql/src/test/org/apache/hadoop/hive/ql/reexec/TestReExecuteLostAMQueryPlugin.java
@@ -22,6 +22,7 @@
import org.apache.hadoop.hive.ql.QueryState;
import org.apache.hadoop.hive.ql.exec.tez.TezRuntimeException;
import org.apache.hadoop.hive.ql.hooks.HookContext;
+import org.apache.tez.dag.api.SessionNotRunning;
import org.junit.Assert;
import org.junit.Test;
@@ -47,6 +48,23 @@ public void testRetryOnNoCurrentDAGException() throws
Exception {
testReExecuteWithExceptionMessage("No running DAG at present");
}
+ @Test
+ public void testRetryOnDefaultSessionNotRunningException() throws Exception {
+ ReExecuteLostAMQueryPlugin plugin = new ReExecuteLostAMQueryPlugin();
+ ReExecuteLostAMQueryPlugin.LocalHook hook = plugin.new LocalHook();
+
+ HiveConf conf = new HiveConf();
+
+ HookContext context = new HookContext(null,
QueryState.getNewQueryState(conf, null), null, null, null,
+ null, null, null, null, false, null, null);
+ context.setHookType(HookContext.HookType.ON_FAILURE_HOOK);
+ context.setException(new SessionNotRunning("Tez session is not running"));
+
+ hook.run(context);
+
+ Assert.assertTrue(plugin.shouldReExecute(1));
+ }
+
private void testReExecuteWithExceptionMessage(String message) throws
Exception {
ReExecuteLostAMQueryPlugin plugin = new ReExecuteLostAMQueryPlugin();
ReExecuteLostAMQueryPlugin.LocalHook hook = plugin.new LocalHook();