diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index e2fd5908ccb..c7a8f2e8405 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -265,6 +265,9 @@ Trunk (Unreleased) HDFS-4757. Update FSDirectory#inodeMap when replacing an INodeDirectory while setting quota. (Jing Zhao via szetszwo) + HDFS-4761. When resetting FSDirectory, the inodeMap should also be reset. + (Jing Zhao via szetszwo) + BREAKDOWN OF HADOOP-8562 SUBTASKS AND RELATED JIRAS HDFS-4145. Merge hdfs cmd line scripts from branch-1-win. (David Lao, diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java index 1f1daf935e3..8e3a74bb0d8 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java @@ -2022,6 +2022,8 @@ public class FSDirectory implements Closeable { try { setReady(false); rootDir = createRoot(getFSNamesystem()); + inodeMap.clear(); + addToInodeMapUnprotected(rootDir); nameCache.reset(); } finally { writeUnlock(); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestCheckpoint.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestCheckpoint.java index 3ed98556a5e..d84283fa7d3 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestCheckpoint.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestCheckpoint.java @@ -77,6 +77,7 @@ import org.apache.hadoop.util.ExitUtil.ExitException; import org.apache.hadoop.util.StringUtils; import org.apache.log4j.Level; import org.junit.After; +import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.mockito.ArgumentMatcher; @@ -1061,6 +1062,10 @@ public class TestCheckpoint { secondary = startSecondaryNameNode(conf); secondary.doCheckpoint(); + FSDirectory secondaryFsDir = secondary.getFSNamesystem().dir; + INode rootInMap = secondaryFsDir.getInode(secondaryFsDir.rootDir.getId()); + Assert.assertSame(rootInMap, secondaryFsDir.rootDir); + fileSys.delete(tmpDir, true); fileSys.mkdirs(tmpDir); secondary.doCheckpoint();