From d69df0b5961299fa6be7b15068c44404ff0490a7 Mon Sep 17 00:00:00 2001 From: Jason Lowe Date: Fri, 26 Jan 2018 15:46:01 -0600 Subject: [PATCH] MAPREDUCE-7020. Task timeout in uber mode can crash AM. Contributed by Peter Bacsko (cherry picked from commit e3a16474773248b116dad77c513e5e90a8235212) --- .../hadoop/mapred/TaskAttemptListenerImpl.java | 5 +++-- .../hadoop/mapred/TestTaskAttemptListenerImpl.java | 6 ++++-- .../main/java/org/apache/hadoop/mapred/Task.java | 14 +++++++++++--- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapred/TaskAttemptListenerImpl.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapred/TaskAttemptListenerImpl.java index c54e11c638f..a9fcbe2fc3b 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapred/TaskAttemptListenerImpl.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapred/TaskAttemptListenerImpl.java @@ -342,8 +342,9 @@ public class TaskAttemptListenerImpl extends CompositeService AtomicReference lastStatusRef = attemptIdToStatus.get(yarnAttemptID); if (lastStatusRef == null) { - throw new IllegalStateException("Status update was called" - + " with illegal TaskAttemptId: " + yarnAttemptID); + LOG.error("Status update was called with illegal TaskAttemptId: " + + yarnAttemptID); + return false; } taskHeartbeatHandler.progressing(yarnAttemptID); diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapred/TestTaskAttemptListenerImpl.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapred/TestTaskAttemptListenerImpl.java index 5c0d7453085..38cba8a9529 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapred/TestTaskAttemptListenerImpl.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapred/TestTaskAttemptListenerImpl.java @@ -397,13 +397,15 @@ public class TestTaskAttemptListenerImpl { assertEquals(Phase.REDUCE, status.phase); } - @Test(expected = IllegalStateException.class) + @Test public void testStatusUpdateFromUnregisteredTask() throws IOException, InterruptedException{ configureMocks(); startListener(false); - listener.statusUpdate(attemptID, firstReduceStatus); + boolean taskFound = listener.statusUpdate(attemptID, firstReduceStatus); + + assertFalse(taskFound); } private void configureMocks() { diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/Task.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/Task.java index d6ce7a37761..169164f8a13 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/Task.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/Task.java @@ -785,6 +785,9 @@ abstract public class Task implements Writable, Configurable { long taskProgressInterval = MRJobConfUtil. getTaskProgressReportInterval(conf); + boolean uberized = conf.getBoolean("mapreduce.task.uberized", + false); + while (!taskDone.get()) { synchronized (lock) { done = false; @@ -820,9 +823,14 @@ abstract public class Task implements Writable, Configurable { // if Task Tracker is not aware of our task ID (probably because it died and // came back up), kill ourselves if (!taskFound) { - LOG.warn("Parent died. Exiting "+taskId); - resetDoneFlag(); - System.exit(66); + if (uberized) { + taskDone.set(true); + break; + } else { + LOG.warn("Parent died. Exiting "+taskId); + resetDoneFlag(); + System.exit(66); + } } sendProgress = resetProgressFlag();