From ced740e5808b8ba924592d72cd6d832db5c6f62e Mon Sep 17 00:00:00 2001 From: Jing Zhao Date: Wed, 13 Nov 2013 19:59:55 +0000 Subject: [PATCH] HDFS-5474. Deletesnapshot can make Namenode in safemode on NN restarts. Contributed by Sathish. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1541685 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../apache/hadoop/hdfs/server/namenode/FSNamesystem.java | 9 +++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 5589f10d21..6ef8fd2211 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -541,6 +541,9 @@ Release 2.3.0 - UNRELEASED HDFS-5425. Renaming underconstruction file with snapshots can make NN failure on restart. (jing9 and Vinay) + HDFS-5474. Deletesnapshot can make Namenode in safemode on NN restarts. + (Sathish via jing9) + Release 2.2.1 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java index fcc66c63d6..da5654bc67 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java @@ -6961,6 +6961,7 @@ void deleteSnapshot(String snapshotRoot, String snapshotName) return; // Return previous response } boolean success = false; + BlocksMapUpdateInfo collectedBlocks = new BlocksMapUpdateInfo(); writeLock(); try { checkOperation(OperationCategory.WRITE); @@ -6969,7 +6970,6 @@ void deleteSnapshot(String snapshotRoot, String snapshotName) checkOwner(pc, snapshotRoot); } - BlocksMapUpdateInfo collectedBlocks = new BlocksMapUpdateInfo(); List removedINodes = new ChunkedArrayList(); dir.writeLock(); try { @@ -6980,8 +6980,6 @@ void deleteSnapshot(String snapshotRoot, String snapshotName) dir.writeUnlock(); } removedINodes.clear(); - this.removeBlocks(collectedBlocks); - collectedBlocks.clear(); getEditLog().logDeleteSnapshot(snapshotRoot, snapshotName, cacheEntry != null); success = true; @@ -6990,7 +6988,10 @@ void deleteSnapshot(String snapshotRoot, String snapshotName) RetryCache.setState(cacheEntry, success); } getEditLog().logSync(); - + + removeBlocks(collectedBlocks); + collectedBlocks.clear(); + if (auditLog.isInfoEnabled() && isExternalInvocation()) { String rootPath = Snapshot.getSnapshotPath(snapshotRoot, snapshotName); logAuditEvent(true, "deleteSnapshot", rootPath, null, null);