HDFS-6197. Rolling upgrade rollback on Windows can fail attempting to rename edit log segment files to a destination that already exists. Contributed by Chris Nauroth.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1585586 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Chris Nauroth 2014-04-07 21:21:46 +00:00
parent a5b37c6ed1
commit 79bd50f91b
3 changed files with 10 additions and 4 deletions

View File

@ -329,6 +329,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

View File

@ -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;
}

View File

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