Browse Source

HDFS-6197. Merging change r1585591 from branch-2 to branch-2.4

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2.4@1585592 13f79535-47bb-0310-9956-ffa450edef68
Chris Nauroth 11 years ago
parent
commit
7b517ef338

+ 3 - 0
hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt

@@ -15,6 +15,9 @@ Release 2.4.1 - UNRELEASED
     HDFS-6189. Multiple HDFS tests fail on Windows attempting to use a test
     root path containing a colon.  (cnauroth via szetszwo) 
 
+    HDFS-6197. Rolling upgrade rollback on Windows can fail attempting to rename
+    edit log segment files to a destination that already exists. (cnauroth)
+
 Release 2.4.0 - 2014-04-07 
 
   INCOMPATIBLE CHANGES

+ 6 - 4
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FileJournalManager.java

@@ -512,10 +512,12 @@ public class FileJournalManager implements JournalManager {
     private void renameSelf(String newSuffix) throws IOException {
       File src = file;
       File dst = new File(src.getParent(), src.getName() + newSuffix);
-      boolean success = src.renameTo(dst);
-      if (!success) {
-        throw new IOException(
-          "Couldn't rename log " + src + " to " + dst);
+      // renameTo fails on Windows if the destination file already exists.
+      if (!src.renameTo(dst)) {
+        if (!dst.delete() || !src.renameTo(dst)) {
+          throw new IOException(
+            "Couldn't rename log " + src + " to " + dst);
+        }
       }
       file = dst;
     }

+ 1 - 0
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestRollingUpgrade.java

@@ -195,6 +195,7 @@ public class TestRollingUpgrade {
         Assert.assertEquals(info1, dfs.rollingUpgrade(RollingUpgradeAction.QUERY));
   
         dfs.mkdirs(bar);
+        cluster.shutdown();
       }
 
       // cluster2 takes over QJM