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 618a372596..d18d448ab2 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 @@ void doCheckpoint() throws IOException { 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()); }