Browse Source

HADOOP-3995. In case of quota failure on HDFS, rename does not restore
source filename. (rangadi)



git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/trunk@689327 13f79535-47bb-0310-9956-ffa450edef68

Raghu Angadi 16 years ago
parent
commit
344a6cb598

+ 3 - 0
CHANGES.txt

@@ -386,6 +386,9 @@ Release 0.18.1 - Unreleased
 
   BUG FIXES
 
+    HADOOP-3995. In case of quota failure on HDFS, rename does not restore
+    source filename. (rangadi)
+
     HADOOP-3821. Prevent SequenceFile and IFile from duplicating codecs in
     CodecPool when closed more than once. (Arun Murthy via cdouglas)
 

+ 3 - 0
src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java

@@ -375,6 +375,8 @@ class FSDirectory implements FSConstants, Closeable {
         return false;
       }
 
+      String srcChildName = srcChild.getLocalName();
+      
       // check the validity of the destination
       INode dstChild = null;
       QuotaExceededException failureByQuota = null;
@@ -416,6 +418,7 @@ class FSDirectory implements FSConstants, Closeable {
             +"failed to rename "+src+" to "+dst);
         try {
           // put it back
+          srcChild.setLocalName(srcChildName);
           addChild(srcInodes, srcInodes.length-1, srcChild, false);
         } catch (IOException ignored) {}
         if (failureByQuota != null) {

+ 14 - 1
src/test/org/apache/hadoop/hdfs/TestQuota.java

@@ -268,7 +268,7 @@ public class TestQuota extends TestCase {
       assertEquals(c.getDirectoryCount(), 6);
       assertEquals(c.getQuota(), 6);
 
-      // 10: Move /nqdir0/qdir1/qdir21/nqdir30 to /nqdir0/qdir1/qdir21
+      // 10: Move /nqdir0/qdir1/qdir20/nqdir30 to /nqdir0/qdir1/qdir21
       hasException = false;
       try {
         assertFalse(dfs.rename(tempPath, quotaDir3));
@@ -276,6 +276,19 @@ public class TestQuota extends TestCase {
         hasException = true;
       }
       assertTrue(hasException);
+      assertTrue(dfs.exists(tempPath));
+      assertFalse(dfs.exists(new Path(quotaDir3, "nqdir30")));
+      
+      // 10.a: Rename /nqdir0/qdir1/qdir20/nqdir30 to /nqdir0/qdir1/qdir21/nqdir32
+      hasException = false;
+      try {
+        assertFalse(dfs.rename(tempPath, new Path(quotaDir3, "nqdir32")));
+      } catch (QuotaExceededException e) {
+        hasException = true;
+      }
+      assertTrue(hasException);
+      assertTrue(dfs.exists(tempPath));
+      assertFalse(dfs.exists(new Path(quotaDir3, "nqdir32")));
 
       // 11: Move /nqdir0/qdir1/qdir20/nqdir30 to /nqdir0
       assertTrue(dfs.rename(tempPath, new Path("/nqdir0")));