ayushtkn commented on code in PR #5103:
URL: https://github.com/apache/hive/pull/5103#discussion_r1504705734
##########
ql/src/java/org/apache/hadoop/hive/ql/reexec/ReExecuteLostAMQueryPlugin.java:
##########
@@ -44,15 +50,28 @@ public void run(HookContext hookContext) throws Exception {
if (hookContext.getHookType() == HookContext.HookType.ON_FAILURE_HOOK) {
Throwable exception = hookContext.getException();
- if (exception != null && exception.getMessage() != null) {
+ if (!(exception instanceof TezRuntimeException)) {
+ LOG.info("Exception is not a TezRuntimeException, no need to check
further with ReExecuteLostAMQueryPlugin");
+ return;
+ }
+
+ TezRuntimeException tre = (TezRuntimeException)exception;
+
+ if (tre != null && tre.getMessage() != null) {
+ dagIds.add(tre.getDagId());
// When HS2 does not manage the AMs, tez AMs are registered with
zookeeper and HS2 discovers it,
// failure of unmanaged AMs will throw AM record not being found in
zookeeper.
String unmanagedAMFailure = "AM record not found (likely died)";
- if
(lostAMContainerErrorPattern.matcher(exception.getMessage()).matches()
- || exception.getMessage().contains(unmanagedAMFailure)) {
+ // DAG lost in the scenario described at TEZ-4543
+ String dagLostFailure = "No running DAG at present";
Review Comment:
Shouldn't ``dagLostFailure`` & ``unmanagedAMFailure`` defined as constants
in the class?
##########
ql/src/java/org/apache/hadoop/hive/ql/reexec/ReExecuteLostAMQueryPlugin.java:
##########
@@ -44,15 +50,28 @@ public void run(HookContext hookContext) throws Exception {
if (hookContext.getHookType() == HookContext.HookType.ON_FAILURE_HOOK) {
Throwable exception = hookContext.getException();
- if (exception != null && exception.getMessage() != null) {
+ if (!(exception instanceof TezRuntimeException)) {
+ LOG.info("Exception is not a TezRuntimeException, no need to check
further with ReExecuteLostAMQueryPlugin");
+ return;
+ }
+
+ TezRuntimeException tre = (TezRuntimeException)exception;
+
+ if (tre != null && tre.getMessage() != null) {
Review Comment:
I think this ``null`` check isn't required, if it is ``null``, the instance
of would bait you out before you reach here
##########
ql/src/java/org/apache/hadoop/hive/ql/reexec/ReExecuteLostAMQueryPlugin.java:
##########
@@ -44,15 +50,28 @@ public void run(HookContext hookContext) throws Exception {
if (hookContext.getHookType() == HookContext.HookType.ON_FAILURE_HOOK) {
Throwable exception = hookContext.getException();
- if (exception != null && exception.getMessage() != null) {
+ if (!(exception instanceof TezRuntimeException)) {
+ LOG.info("Exception is not a TezRuntimeException, no need to check
further with ReExecuteLostAMQueryPlugin");
+ return;
+ }
+
+ TezRuntimeException tre = (TezRuntimeException)exception;
+
+ if (tre != null && tre.getMessage() != null) {
+ dagIds.add(tre.getDagId());
// When HS2 does not manage the AMs, tez AMs are registered with
zookeeper and HS2 discovers it,
// failure of unmanaged AMs will throw AM record not being found in
zookeeper.
String unmanagedAMFailure = "AM record not found (likely died)";
- if
(lostAMContainerErrorPattern.matcher(exception.getMessage()).matches()
- || exception.getMessage().contains(unmanagedAMFailure)) {
+ // DAG lost in the scenario described at TEZ-4543
+ String dagLostFailure = "No running DAG at present";
+
+ if (lostAMContainerErrorPattern.matcher(tre.getMessage()).matches()
+ || tre.getMessage().contains(unmanagedAMFailure)
+ || tre.getMessage().contains(dagLostFailure)) {
retryPossible = true;
}
- LOG.info("Got exception message: {} retryPossible: {}",
exception.getMessage(), retryPossible);
+ LOG.info("Got exception message: {} retryPossible: {}, dags seen so
far: {}", tre.getMessage(), retryPossible,
Review Comment:
nit
``tre.getMessage()`` is being call multiple times, can we refactor that into
a variable & use it everywhere
##########
ql/src/test/org/apache/hadoop/hive/ql/reexec/TestReExecuteLostAMQueryPlugin.java:
##########
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hive.ql.reexec;
+
+import org.apache.hadoop.hive.conf.HiveConf;
+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.junit.Assert;
+import org.junit.Test;
+
+public class TestReExecuteLostAMQueryPlugin {
+
+ @Test
+ public void testRetryOnUnmanagedAmFailure() throws Exception {
+ ReExecuteLostAMQueryPlugin plugin = new ReExecuteLostAMQueryPlugin();
+ ReExecuteLostAMQueryPlugin.LocalHook hook = plugin.new LocalHook();
+
+ HookContext context = new HookContext(null,
QueryState.getNewQueryState(new HiveConf(), null), null, null, null,
+ null, null, null, null, false, null, null);
+ context.setHookType(HookContext.HookType.ON_FAILURE_HOOK);
+ context.setException(new TezRuntimeException("dag_0_0", "AM record not
found (likely died)"));
+
+ hook.run(context);
+
+ Assert.assertEquals(true, plugin.shouldReExecute(1));
Review Comment:
Can we use ``assertTrue`` instead
##########
ql/src/java/org/apache/hadoop/hive/ql/reexec/ReExecuteLostAMQueryPlugin.java:
##########
@@ -33,6 +36,9 @@
public class ReExecuteLostAMQueryPlugin implements IReExecutionPlugin {
private static final Logger LOG =
LoggerFactory.getLogger(ReExecuteLostAMQueryPlugin.class);
private boolean retryPossible;
+ // a list to track DAG ids seen by this re-execution plugin during the same
query
+ // it can help a lot with identifying the previous DAGs in case of retries
+ private List<String> dagIds = new ArrayList<>();
Review Comment:
Can this be a set?
##########
ql/src/test/org/apache/hadoop/hive/ql/reexec/TestReExecuteLostAMQueryPlugin.java:
##########
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hive.ql.reexec;
+
+import org.apache.hadoop.hive.conf.HiveConf;
+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.junit.Assert;
+import org.junit.Test;
+
+public class TestReExecuteLostAMQueryPlugin {
+
+ @Test
+ public void testRetryOnUnmanagedAmFailure() throws Exception {
+ ReExecuteLostAMQueryPlugin plugin = new ReExecuteLostAMQueryPlugin();
+ ReExecuteLostAMQueryPlugin.LocalHook hook = plugin.new LocalHook();
+
+ HookContext context = new HookContext(null,
QueryState.getNewQueryState(new HiveConf(), null), null, null, null,
+ null, null, null, null, false, null, null);
+ context.setHookType(HookContext.HookType.ON_FAILURE_HOOK);
+ context.setException(new TezRuntimeException("dag_0_0", "AM record not
found (likely died)"));
+
+ hook.run(context);
+
+ Assert.assertEquals(true, plugin.shouldReExecute(1));
+ }
+
+ @Test
+ public void testRetryOnNoCurrentDAGException() throws Exception {
+ ReExecuteLostAMQueryPlugin plugin = new ReExecuteLostAMQueryPlugin();
+ ReExecuteLostAMQueryPlugin.LocalHook hook = plugin.new LocalHook();
+
+ HookContext context = new HookContext(null,
QueryState.getNewQueryState(new HiveConf(), null), null, null, null,
+ null, null, null, null, false, null, null);
+ context.setHookType(HookContext.HookType.ON_FAILURE_HOOK);
+ context.setException(new TezRuntimeException("dag_0_0", "No running DAG at
present"));
+
+ hook.run(context);
+
+ Assert.assertEquals(true, plugin.shouldReExecute(1));
Review Comment:
Can we use ``assertTrue`` instead
##########
ql/src/test/org/apache/hadoop/hive/ql/reexec/TestReExecuteLostAMQueryPlugin.java:
##########
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hive.ql.reexec;
+
+import org.apache.hadoop.hive.conf.HiveConf;
+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.junit.Assert;
+import org.junit.Test;
+
+public class TestReExecuteLostAMQueryPlugin {
+
+ @Test
+ public void testRetryOnUnmanagedAmFailure() throws Exception {
+ ReExecuteLostAMQueryPlugin plugin = new ReExecuteLostAMQueryPlugin();
+ ReExecuteLostAMQueryPlugin.LocalHook hook = plugin.new LocalHook();
+
+ HookContext context = new HookContext(null,
QueryState.getNewQueryState(new HiveConf(), null), null, null, null,
+ null, null, null, null, false, null, null);
+ context.setHookType(HookContext.HookType.ON_FAILURE_HOOK);
+ context.setException(new TezRuntimeException("dag_0_0", "AM record not
found (likely died)"));
+
+ hook.run(context);
+
+ Assert.assertEquals(true, plugin.shouldReExecute(1));
+ }
+
+ @Test
+ public void testRetryOnNoCurrentDAGException() throws Exception {
Review Comment:
This test & the test above looks exactly same apart from the exception
message, can we refactor the test body into a method & call that method with
the test message as argument?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]