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 ta...@apache.org on 2021/03/23 09:47:06 UTC

[hadoop] branch branch-3.1 updated: HDFS-15906. Close FSImage and FSNamesystem after formatting is complete (#2800)

This is an automated email from the ASF dual-hosted git repository.

tasanuma pushed a commit to branch branch-3.1
in repository https://gitbox.apache.org/repos/asf/hadoop.git


The following commit(s) were added to refs/heads/branch-3.1 by this push:
     new 75f2d47  HDFS-15906. Close FSImage and FSNamesystem after formatting is complete (#2800)
75f2d47 is described below

commit 75f2d47ff5736087fa8945f2d70527131bb3d957
Author: litao <to...@gmail.com>
AuthorDate: Tue Mar 23 17:45:24 2021 +0800

    HDFS-15906. Close FSImage and FSNamesystem after formatting is complete (#2800)
    
    (cherry picked from commit d05d15620e320d28bfbeeee2a4f5224e69062528)
---
 .../java/org/apache/hadoop/hdfs/server/namenode/NameNode.java | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java
index c8cd8f7..e09aae6 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java
@@ -1200,8 +1200,9 @@ public class NameNode extends ReconfigurableBase implements
     System.out.println("Formatting using clusterid: " + clusterId);
     
     FSImage fsImage = new FSImage(conf, nameDirsToFormat, editDirsToFormat);
+    FSNamesystem fsn = null;
     try {
-      FSNamesystem fsn = new FSNamesystem(conf, fsImage);
+      fsn = new FSNamesystem(conf, fsImage);
       fsImage.getEditLog().initJournalsForWrite();
 
       // Abort NameNode format if reformat is disabled and if
@@ -1226,8 +1227,14 @@ public class NameNode extends ReconfigurableBase implements
       fsImage.format(fsn, clusterId);
     } catch (IOException ioe) {
       LOG.warn("Encountered exception during format: ", ioe);
-      fsImage.close();
       throw ioe;
+    } finally {
+      if (fsImage != null) {
+        fsImage.close();
+      }
+      if (fsn != null) {
+        fsn.close();
+      }
     }
     return false;
   }

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