From dfe70f6a03294ee1b42e0c72b732826e533de912 Mon Sep 17 00:00:00 2001 From: Vinod Kumar Vavilapalli Date: Wed, 10 Jul 2013 17:08:43 +0000 Subject: [PATCH] YARN-295. Fixed a race condition in ResourceManager RMAppAttempt state machine. Contributed by Mayank Bansal. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1501856 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-yarn-project/CHANGES.txt | 3 +++ .../rmapp/attempt/RMAppAttemptImpl.java | 4 ++++ .../rmapp/attempt/TestRMAppAttemptTransitions.java | 14 ++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index b0ff0aed3f..c059e2bf80 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -63,6 +63,9 @@ Release 2.1.1-beta - UNRELEASED YARN-368. Fixed a typo in error message in Auxiliary services. (Albert Chu via vinodkv) + YARN-295. Fixed a race condition in ResourceManager RMAppAttempt state + machine. (Mayank Bansal via vinodkv) + Release 2.1.0-beta - 2013-07-02 INCOMPATIBLE CHANGES diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/RMAppAttemptImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/RMAppAttemptImpl.java index dd9c42260a..11fdd9442f 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/RMAppAttemptImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/RMAppAttemptImpl.java @@ -245,6 +245,10 @@ RMAppAttemptEventType.LAUNCH_FAILED, new LaunchFailedTransition()) .addTransition(RMAppAttemptState.ALLOCATED, RMAppAttemptState.KILLED, RMAppAttemptEventType.KILL, new KillAllocatedAMTransition()) + .addTransition(RMAppAttemptState.ALLOCATED, RMAppAttemptState.FAILED, + RMAppAttemptEventType.CONTAINER_FINISHED, + new AMContainerCrashedTransition()) + // Transitions from LAUNCHED State .addTransition(RMAppAttemptState.LAUNCHED, RMAppAttemptState.RUNNING, RMAppAttemptEventType.REGISTERED, new AMRegisteredTransition()) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/TestRMAppAttemptTransitions.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/TestRMAppAttemptTransitions.java index a394110b46..cafe4f9a70 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/TestRMAppAttemptTransitions.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/TestRMAppAttemptTransitions.java @@ -654,6 +654,20 @@ public void testAllocatedToFailed() { testAppAttemptFailedState(amContainer, diagnostics); } + @Test + public void testAMCrashAtAllocated() { + Container amContainer = allocateApplicationAttempt(); + String containerDiagMsg = "some error"; + int exitCode = 123; + ContainerStatus cs = + BuilderUtils.newContainerStatus(amContainer.getId(), + ContainerState.COMPLETE, containerDiagMsg, exitCode); + applicationAttempt.handle(new RMAppAttemptContainerFinishedEvent( + applicationAttempt.getAppAttemptId(), cs)); + assertEquals(RMAppAttemptState.FAILED, + applicationAttempt.getAppAttemptState()); + } + @Test public void testRunningToFailed() { Container amContainer = allocateApplicationAttempt();