From 58d9479140e9d79af52c46b8fa7486bed6a1523b Mon Sep 17 00:00:00 2001 From: Chris Nauroth Date: Mon, 7 Apr 2014 21:26:42 +0000 Subject: [PATCH] HDFS-6197. Merging change r1585586 from trunk to branch-2. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1585591 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../hdfs/server/namenode/FileJournalManager.java | 10 ++++++---- .../org/apache/hadoop/hdfs/TestRollingUpgrade.java | 1 + 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index e64c2293486..a8599bb2cdc 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -81,6 +81,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 diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FileJournalManager.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FileJournalManager.java index 63323ab2a0d..25440374652 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FileJournalManager.java +++ b/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; } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestRollingUpgrade.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestRollingUpgrade.java index aed81793acc..326de7f788e 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestRollingUpgrade.java +++ b/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