Browse Source

HDFS-3652. FSEditLog failure removes the wrong edit stream when storage dirs have same name. Contributed by Todd Lipcon.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-1.0@1361048 13f79535-47bb-0310-9956-ffa450edef68
Todd Lipcon 12 years ago
parent
commit
9ddaf9db5c

+ 3 - 0
CHANGES.txt

@@ -8,6 +8,9 @@ Release 1.0.4 - Unreleased
 
   BUG FIXES
 
+    HDFS-3652. FSEditLog failure removes the wrong edit stream when storage
+    dirs have same name. (todd)
+
 Release 1.0.3 - 2012.05.07
 
   NEW FEATURES

+ 3 - 1
src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSEditLog.java

@@ -444,8 +444,10 @@ public class FSEditLog {
     }
     for (int idx = 0; idx < editStreams.size(); idx++) {
       File parentDir = getStorageDirForStream(idx);
-      if (parentDir.getName().equals(sd.getRoot().getName())) {
+      if (parentDir.getAbsolutePath().equals(
+            sd.getRoot().getAbsolutePath())) {
         editStreams.remove(idx);
+        idx--;
       }
     }
     exitIfNoStreams();

+ 5 - 3
src/test/org/apache/hadoop/hdfs/server/namenode/TestStorageDirectoryFailure.java

@@ -63,9 +63,11 @@ public class TestStorageDirectoryFailure {
     String baseDir = System.getProperty("test.build.data", "/tmp");
     File dfsDir = new File(baseDir, "dfs");
     nameDirs = new ArrayList<String>();
-    nameDirs.add(new File(dfsDir, "name1").getPath());
-    nameDirs.add(new File(dfsDir, "name2").getPath());
-    nameDirs.add(new File(dfsDir, "name3").getPath());
+    // Have all the name dirs with the same filename: important for regression
+    // testing HDFS-3652.
+    nameDirs.add(new File(new File(dfsDir, "name1"), "nn").getPath());
+    nameDirs.add(new File(new File(dfsDir, "name2"), "nn").getPath());
+    nameDirs.add(new File(new File(dfsDir, "name3"), "nn").getPath());
 
     conf.set("dfs.name.dir", StringUtils.join(nameDirs, ","));
     conf.set("dfs.data.dir", new File(dfsDir, "data").getPath());