Pārlūkot izejas kodu

Merge -r 735763:735764 from trunk onto 0.20 branch. Fixes HADOOP-4967.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/branches/branch-0.20@735765 13f79535-47bb-0310-9956-ffa450edef68
Devaraj Das 16 gadi atpakaļ
vecāks
revīzija
777f62e3ad

+ 3 - 0
CHANGES.txt

@@ -609,6 +609,9 @@ Release 0.19.1 - Unreleased
 
     HADOOP-4965. TestFileAppend3 should close FileSystem. (shv)
 
+    HADOOP-4967. Fixes a race condition in the JvmManager to do with killing
+    tasks. (ddas)
+
 Release 0.19.0 - 2008-11-18
 
   INCOMPATIBLE CHANGES

+ 5 - 0
src/mapred/org/apache/hadoop/mapred/JvmManager.java

@@ -195,6 +195,11 @@ class JvmManager {
     }
     private synchronized void reapJvm( 
         TaskRunner t, TaskTracker tracker, JvmEnv env) {
+      if (t.getTaskInProgress().wasKilled()) {
+        //the task was killed in-flight
+        //no need to do the rest of the operations
+        return;
+      }
       boolean spawnNewJvm = false;
       JobID jobId = t.getTask().getJobID();
       //Check whether there is a free slot to start a new JVM.

+ 5 - 1
src/mapred/org/apache/hadoop/mapred/TaskTracker.java

@@ -1779,7 +1779,7 @@ public class TaskTracker
     StringBuffer diagnosticInfo = new StringBuffer();
     private TaskRunner runner;
     volatile boolean done = false;
-    boolean wasKilled = false;
+    volatile boolean wasKilled = false;
     private JobConf defaultJobConf;
     private JobConf localJobConf;
     private boolean keepFailedTaskFiles;
@@ -2026,6 +2026,10 @@ public class TaskTracker
       LOG.info("reported output size for " + task.getTaskID() +  "  was " + taskStatus.getOutputSize());
 
     }
+    
+    public boolean wasKilled() {
+      return wasKilled;
+    }
 
     /**
      * The task has actually finished running.