You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by sj...@apache.org on 2016/09/14 04:52:04 UTC

hadoop git commit: HDFS-9696. Garbage snapshot records linger forever. Contributed by Kihwal Lee

Repository: hadoop
Updated Branches:
  refs/heads/branch-2.6 d75c8e75f -> 8ebf8965d


HDFS-9696. Garbage snapshot records linger forever. Contributed by Kihwal Lee

(cherry picked from commit 83e57e083f2cf6c0de8a46966c5492faeabd8f2a)

Conflicts:
	hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestSaveNamespace.java

(cherry picked from commit 4766a3153dd517ac832d4761c884ed88a83a6c09)
(cherry picked from commit e3b809a284ba689034d9aa82ecd51e79f810911f)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/8ebf8965
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/8ebf8965
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/8ebf8965

Branch: refs/heads/branch-2.6
Commit: 8ebf8965d8cfe94f5004e484aaa0a5ffadeffbed
Parents: d75c8e7
Author: Kihwal Lee <ki...@apache.org>
Authored: Mon Aug 15 13:17:02 2016 -0500
Committer: Sangjin Lee <sj...@apache.org>
Committed: Tue Sep 13 21:51:34 2016 -0700

----------------------------------------------------------------------
 hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt     |  2 +
 .../server/namenode/FSImageFormatProtobuf.java  |  6 ++-
 .../hdfs/server/namenode/TestSaveNamespace.java | 41 ++++++++++++++++++++
 3 files changed, 48 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/8ebf8965/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
index 8795ad0..f508e84 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
+++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
@@ -45,6 +45,8 @@ Release 2.6.5 - UNRELEASED
     HDFS-9365. Balancer does not work with the HDFS-6376 HA setup. (Tsz Wo
     Nicholas Sze)
 
+    HDFS-9696. Garbage snapshot records linger forever. (kihwal)
+
 Release 2.6.4 - 2016-02-11
 
   INCOMPATIBLE CHANGES

http://git-wip-us.apache.org/repos/asf/hadoop/blob/8ebf8965/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormatProtobuf.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormatProtobuf.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormatProtobuf.java
index 2527089..0f25378 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormatProtobuf.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormatProtobuf.java
@@ -443,7 +443,11 @@ public final class FSImageFormatProtobuf {
           this, summary, context, context.getSourceNamesystem());
 
       snapshotSaver.serializeSnapshotSection(sectionOutputStream);
-      snapshotSaver.serializeSnapshotDiffSection(sectionOutputStream);
+      // Skip snapshot-related sections when there is no snapshot.
+      if (context.getSourceNamesystem().getSnapshotManager()
+          .getNumSnapshots() > 0) {
+        snapshotSaver.serializeSnapshotDiffSection(sectionOutputStream);
+      }
       snapshotSaver.serializeINodeReferenceSection(sectionOutputStream);
     }
 

http://git-wip-us.apache.org/repos/asf/hadoop/blob/8ebf8965/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestSaveNamespace.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestSaveNamespace.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestSaveNamespace.java
index 26bddc3..9762e8d 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestSaveNamespace.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestSaveNamespace.java
@@ -624,6 +624,47 @@ public class TestSaveNamespace {
     }
   }
 
+  @Test
+  public void testSkipSnapshotSection() throws Exception {
+    MiniDFSCluster cluster = new MiniDFSCluster.Builder(new Configuration())
+        .numDataNodes(1).build();
+    cluster.waitActive();
+    DistributedFileSystem fs = cluster.getFileSystem();
+    OutputStream out = null;
+    try {
+      String path = "/skipSnapshot";
+      out = fs.create(new Path(path));
+      out.close();
+
+      // add a bogus filediff
+      FSDirectory dir = cluster.getNamesystem().getFSDirectory();
+      INodeFile file = dir.getINode(path).asFile();
+      file.addSnapshotFeature(null).getDiffs()
+          .saveSelf2Snapshot(-1, file, null);
+
+      // make sure it has a diff
+      assertTrue("Snapshot fileDiff is missing.",
+          file.getFileWithSnapshotFeature().getDiffs() != null);
+
+      // saveNamespace
+      fs.setSafeMode(SafeModeAction.SAFEMODE_ENTER);
+      cluster.getNameNodeRpc().saveNamespace();
+      fs.setSafeMode(SafeModeAction.SAFEMODE_LEAVE);
+
+      // restart namenode
+      cluster.restartNameNode(true);
+      dir = cluster.getNamesystem().getFSDirectory();
+      file = dir.getINode(path).asFile();
+
+      // there should be no snapshot feature for the inode, when there is
+      // no snapshot.
+      assertTrue("There should be no snapshot feature for this INode.",
+          file.getFileWithSnapshotFeature() == null);
+    } finally {
+      cluster.shutdown();
+    }
+  }
+
   private void doAnEdit(FSNamesystem fsn, int id) throws IOException {
     // Make an edit
     fsn.mkdirs(


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org