Browse Source

HADOOP-6017. Lease Manager in NameNode does not handle certain characters
in filenames. This results in fatal errors in Secondary NameNode and while
restrating NameNode. (Tsz Wo (Nicholas), SZE via rangadi)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/branches/branch-0.19@785054 13f79535-47bb-0310-9956-ffa450edef68

Raghu Angadi 16 years ago
parent
commit
b1b3e2ac77

+ 4 - 0
CHANGES.txt

@@ -1230,6 +1230,10 @@ Release 0.18.4 - Unreleased
 
     HADOOP-5644. Namnode is stuck in safe mode. (Suresh Srinivas via hairong)
 
+    HADOOP-6017. Lease Manager in NameNode does not handle certain characters
+    in filenames. This results in fatal errors in Secondary NameNode and while
+    restrating NameNode. (Tsz Wo (Nicholas), SZE via rangadi)
+
 Release 0.18.3 - 2009-01-27
 
   IMPROVEMENTS

+ 3 - 2
src/hdfs/org/apache/hadoop/hdfs/server/namenode/LeaseManager.java

@@ -285,11 +285,12 @@ public class LeaseManager {
                ", replaceBy=" + replaceBy);
     }
 
+    final int len = overwrite.length();
     for(Map.Entry<String, Lease> entry : findLeaseWithPrefixPath(src, sortedLeasesByPath)) {
       final String oldpath = entry.getKey();
       final Lease lease = entry.getValue();
-      final String newpath = oldpath.replaceFirst(
-          java.util.regex.Pattern.quote(overwrite), replaceBy);
+      //overwrite must be a prefix of oldpath
+      final String newpath = replaceBy + oldpath.substring(len);
       if (LOG.isDebugEnabled()) {
         LOG.debug("changeLease: replacing " + oldpath + " with " + newpath);
       }

+ 11 - 0
src/test/org/apache/hadoop/hdfs/TestRenameWhileOpen.java

@@ -82,6 +82,17 @@ public class TestRenameWhileOpen extends junit.framework.TestCase {
       fs.mkdirs(dir3);
       fs.rename(dir1, dir3);
 
+      // create file3
+      Path file3 = new Path(dir3, "file3");
+      FSDataOutputStream stm3 = TestFileCreation.createFile(fs, file3, 1);
+      TestFileCreation.writeFile(stm3);
+      // rename file3 to some bad name
+      try {
+        fs.rename(file3, new Path(dir3, "$ "));
+      } catch(Exception e) {
+        e.printStackTrace();
+      }
+      
       // restart cluster with the same namenode port as before.
       // This ensures that leases are persisted in fsimage.
       cluster.shutdown();