diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/job/impl/TaskAttemptImpl.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/job/impl/TaskAttemptImpl.java index 63e7456e863..998eb03a91b 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/job/impl/TaskAttemptImpl.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/job/impl/TaskAttemptImpl.java @@ -382,6 +382,10 @@ public abstract class TaskAttemptImpl implements TaskAttemptStateInternal.SUCCESS_FINISHING_CONTAINER, TaskAttemptEventType.TA_DIAGNOSTICS_UPDATE, DIAGNOSTIC_INFORMATION_UPDATE_TRANSITION) + .addTransition(TaskAttemptStateInternal.SUCCESS_FINISHING_CONTAINER, + TaskAttemptStateInternal.FAILED, + TaskAttemptEventType.TA_TOO_MANY_FETCH_FAILURE, + new TooManyFetchFailureTransition()) // ignore-able events .addTransition(TaskAttemptStateInternal.SUCCESS_FINISHING_CONTAINER, TaskAttemptStateInternal.SUCCESS_FINISHING_CONTAINER, @@ -2148,6 +2152,10 @@ public abstract class TaskAttemptImpl implements @SuppressWarnings("unchecked") @Override public void transition(TaskAttemptImpl taskAttempt, TaskAttemptEvent event) { + if (taskAttempt.getInternalState() == + TaskAttemptStateInternal.SUCCESS_FINISHING_CONTAINER) { + sendContainerCleanup(taskAttempt, event); + } TaskAttemptTooManyFetchFailureEvent fetchFailureEvent = (TaskAttemptTooManyFetchFailureEvent) event; // too many fetch failure can only happen for map tasks diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/job/impl/TestTaskAttempt.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/job/impl/TestTaskAttempt.java index b1b7b8f72df..74120b2eac8 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/job/impl/TestTaskAttempt.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/job/impl/TestTaskAttempt.java @@ -1782,6 +1782,31 @@ public class TestTaskAttempt{ ResourceUtils.resetResourceTypes(conf); } + @Test + public void testTooManyFetchFailureWhileSuccessFinishing() throws Exception { + MockEventHandler eventHandler = new MockEventHandler(); + TaskAttemptImpl taImpl = createTaskAttemptImpl(eventHandler); + TaskId reducetaskId = MRBuilderUtils.newTaskId(taImpl.getID().getTaskId() + .getJobId(), 1, TaskType.REDUCE); + TaskAttemptId reduceTAId = + MRBuilderUtils.newTaskAttemptId(reducetaskId, 0); + + taImpl.handle(new TaskAttemptEvent(taImpl.getID(), + TaskAttemptEventType.TA_DONE)); + + assertEquals("Task attempt's internal state is not " + + "SUCCESS_FINISHING_CONTAINER", + TaskAttemptStateInternal.SUCCESS_FINISHING_CONTAINER, + taImpl.getInternalState()); + + taImpl.handle(new TaskAttemptTooManyFetchFailureEvent(taImpl.getID(), + reduceTAId, "Host")); + assertEquals("Task attempt is not in FAILED state", + TaskAttemptState.FAILED, + taImpl.getState()); + assertFalse("InternalError occurred", eventHandler.internalError); + } + private void setupTaskAttemptFinishingMonitor( EventHandler eventHandler, JobConf jobConf, AppContext appCtx) { TaskAttemptFinishingMonitor taskAttemptFinishingMonitor =