HDFS-16244.Add the necessary write lock in Checkpointer#doCheckpoint(). (#3497)

This commit is contained in:
jianghuazhu 2021-10-13 17:21:03 +08:00 committed by GitHub
parent 8c271caa81
commit ff24fe6197
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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());
}