Browse Source

Revert: Fix race between multiple localizers on single node (chris douglas via mahadev)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/MR-279@1136593 13f79535-47bb-0310-9956-ffa450edef68
Mahadev Konar 14 years ago
parent
commit
2cce806fa3

+ 0 - 2
mapreduce/CHANGES.txt

@@ -11,8 +11,6 @@ Trunk (unreleased changes)
 
 
     Hack until MAPREDUCE-2365 is fixed to make PIG work with MRV2. (mahadev)
     Hack until MAPREDUCE-2365 is fixed to make PIG work with MRV2. (mahadev)
 
 
-    Fix race between multiple localizers on single node (chris douglas via mahadev) 
-
     Bug fix to set correct state on containers so as to avoid duplicate
     Bug fix to set correct state on containers so as to avoid duplicate
     containers from RM to AM. (vinodkv)
     containers from RM to AM. (vinodkv)
 
 

+ 16 - 3
mapreduce/yarn/yarn-server/yarn-server-nodemanager/src/main/c/container-executor/impl/container-executor.c

@@ -519,17 +519,30 @@ int create_directory_for_user(const char* path) {
   int ret = 0;
   int ret = 0;
   ret = change_effective_user(tt_uid, tt_gid);
   ret = change_effective_user(tt_uid, tt_gid);
   if (ret == 0) {
   if (ret == 0) {
-    if (0 == mkdir(path, permissions) || EEXIST == errno) {
+    if (mkdir(path, permissions) == 0) {
       // need to reassert the group sticky bit
       // need to reassert the group sticky bit
       if (chmod(path, permissions) != 0) {
       if (chmod(path, permissions) != 0) {
         fprintf(LOGFILE, "Can't chmod %s to add the sticky bit - %s\n",
         fprintf(LOGFILE, "Can't chmod %s to add the sticky bit - %s\n",
                 path, strerror(errno));
                 path, strerror(errno));
         ret = -1;
         ret = -1;
       } else if (change_owner(path, user, tt_gid) != 0) {
       } else if (change_owner(path, user, tt_gid) != 0) {
-        fprintf(LOGFILE, "Failed to chown %s to %d:%d: %s\n", path, user, tt_gid,
-            strerror(errno));
         ret = -1;
         ret = -1;
       }
       }
+    } else if (errno == EEXIST) {
+      struct stat file_stat;
+      if (stat(path, &file_stat) != 0) {
+        fprintf(LOGFILE, "Can't stat directory %s - %s\n", path, 
+                strerror(errno));
+        ret = -1;
+      } else {
+        if (file_stat.st_uid != user ||
+            file_stat.st_gid != tt_gid) {
+          fprintf(LOGFILE, "Directory %s owned by wrong user or group. "
+                  "Expected %d:%d and found %d:%d.\n",
+                  path, user, tt_gid, file_stat.st_uid, file_stat.st_gid);
+          ret = -1;
+        }
+      }
     } else {
     } else {
       fprintf(LOGFILE, "Failed to create directory %s - %s\n", path,
       fprintf(LOGFILE, "Failed to create directory %s - %s\n", path,
               strerror(errno));
               strerror(errno));