Ver código fonte

Merge -r 759931:759932 from trunk onto 0.20 branch. Fixes HADOOP-5473.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/branches/branch-0.20@759935 13f79535-47bb-0310-9956-ffa450edef68
Devaraj Das 16 anos atrás
pai
commit
911a79739e

+ 4 - 0
CHANGES.txt

@@ -817,6 +817,10 @@ Release 0.20.0 - Unreleased
     HADOOP-5588. Remove an unnecessary call to listStatus(..) in
     FileSystem.globStatusInternal(..).  (Hairong Kuang via szetszwo)
 
+    HADOOP-5473. Solves a race condition in killing a task - the state is KILLED
+    if there is a user request pending to kill the task and the TT reported
+    the state as SUCCESS. (Amareshwari Sriramadasu via ddas)
+
 Release 0.19.2 - Unreleased
 
   BUG FIXES

+ 4 - 1
src/mapred/org/apache/hadoop/mapred/JobInProgress.java

@@ -748,7 +748,10 @@ class JobInProgress {
     // mark the task as KILLED.
     // In case of task with no promotion the task tracker will mark the task 
     // as SUCCEEDED.
-    if (wasComplete && (status.getRunState() == TaskStatus.State.SUCCEEDED)) {
+    // User has requested to kill the task, but TT reported SUCCEEDED, 
+    // mark the task KILLED.
+    if ((wasComplete || tip.wasKilled(taskid)) && 
+        (status.getRunState() == TaskStatus.State.SUCCEEDED)) {
       status.setRunState(TaskStatus.State.KILLED);
     }
     

+ 6 - 1
src/mapred/org/apache/hadoop/mapred/TaskInProgress.java

@@ -590,7 +590,8 @@ class TaskInProgress {
       // Check if the user manually KILLED/FAILED this task-attempt...
       Boolean shouldFail = tasksToKill.remove(taskid);
       if (shouldFail != null) {
-        if (isCleanupAttempt(taskid) || jobSetup || jobCleanup) {
+        if (status.getRunState() == TaskStatus.State.FAILED ||
+            status.getRunState() == TaskStatus.State.KILLED) {
           taskState = (shouldFail) ? TaskStatus.State.FAILED :
                                      TaskStatus.State.KILLED;
         } else {
@@ -969,6 +970,10 @@ class TaskInProgress {
     return taskStatuses.get(taskid).getTaskTracker();
   }
     
+  boolean wasKilled(TaskAttemptID taskid) {
+    return tasksToKill.containsKey(taskid);
+  }
+  
   /**
    * Has this task already failed on this machine?
    * @param trackerHost The task tracker hostname