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 fe...@apache.org on 2021/10/13 09:21:26 UTC

[hadoop] branch trunk updated: HDFS-16244.Add the necessary write lock in Checkpointer#doCheckpoint(). (#3497)

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

ferhui pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git


The following commit(s) were added to refs/heads/trunk by this push:
     new ff24fe6  HDFS-16244.Add the necessary write lock in Checkpointer#doCheckpoint(). (#3497)
ff24fe6 is described below

commit ff24fe61972ff99486fae1822fe1a12ef3c7c846
Author: jianghuazhu <74...@qq.com>
AuthorDate: Wed Oct 13 17:21:03 2021 +0800

    HDFS-16244.Add the necessary write lock in Checkpointer#doCheckpoint(). (#3497)
---
 .../org/apache/hadoop/hdfs/server/namenode/Checkpointer.java  | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/Checkpointer.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/Checkpointer.java
index 618a372..d18d448 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/Checkpointer.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/Checkpointer.java
@@ -244,9 +244,14 @@ class Checkpointer extends Daemon {
 
       if(needReloadImage) {
         LOG.info("Loading image with txid " + sig.mostRecentCheckpointTxId);
-        File file = bnStorage.findImageFile(NameNodeFile.IMAGE,
-            sig.mostRecentCheckpointTxId);
-        bnImage.reloadFromImageFile(file, backupNode.getNamesystem());
+        backupNode.namesystem.writeLock();
+        try {
+          File file = bnStorage.findImageFile(NameNodeFile.IMAGE,
+              sig.mostRecentCheckpointTxId);
+          bnImage.reloadFromImageFile(file, backupNode.getNamesystem());
+        } finally {
+          backupNode.namesystem.writeUnlock();
+        }
       }
       rollForwardByApplyingLogs(manifest, bnImage, backupNode.getNamesystem());
     }

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