Pārlūkot izejas kodu

MAPREDUCE-2374. "Text File Busy" errors launching MR tasks. Contributed by Andy Isaacson.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-1@1376639 13f79535-47bb-0310-9956-ffa450edef68
Aaron Myers 13 gadi atpakaļ
vecāks
revīzija
09d44a61fc

+ 3 - 0
CHANGES.txt

@@ -189,6 +189,9 @@ Release 1.2.0 - unreleased
 
     MAPREDUCE-4567. Fix failing TestJobKillAndFail in branch-1. (tomwhite)
 
+    MAPREDUCE-2374. "Text File Busy" errors launching MR tasks. (Andy Isaacson
+    via atm)
+
 Release 1.1.0 - unreleased
 
   INCOMPATIBLE CHANGES

+ 10 - 1
src/mapred/org/apache/hadoop/mapred/DefaultTaskController.java

@@ -125,8 +125,17 @@ public class DefaultTaskController extends TaskController {
 
       String commandFile = writeCommand(cmdLine, rawFs, p);
       rawFs.setPermission(p, TaskController.TASK_LAUNCH_SCRIPT_PERMISSION);
+      /*
+       * MAPREDUCE-2374: if another thread fork(2)ed a child process during the
+       * window when writeCommand (above) had taskjvm.sh open for write, that
+       * child process might still have a writeable fd open to the script.
+       *
+       * If we run the script with "bash -c /path/to/taskjvm.sh", then bash
+       * would try to execve(2) the script and get ETXTBSY.  Instead, just have
+       * bash interpret the script with "bash /path/to/taskjvm.sh".
+       */
       shExec = new ShellCommandExecutor(new String[]{
-          "bash", "-c", commandFile},
+          "bash", commandFile},
           currentWorkDirectory);
       shExec.execute();
     } catch (Exception e) {