From 3aceec711b291eaaa371f7fda9b00da2c737b860 Mon Sep 17 00:00:00 2001 From: huhaiyang Date: Thu, 28 Dec 2023 21:13:16 +0800 Subject: [PATCH] HDFS-17297. The NameNode should remove block from the BlocksMap if the block is marked as deleted (#6369) Reviewed-by: ZanderXu Signed-off-by: Takanobu Asanuma --- .../org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 c14526b6a1..277cc42222 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 @@ -3815,7 +3815,10 @@ boolean internalReleaseLease(Lease lease, String src, INodesInPath iip, // may be client have crashed before writing data to pipeline. // This blocks doesn't need any recovery. // We can remove this block and close the file. - pendingFile.removeLastBlock(lastBlock); + BlockInfo lastBlockInfo = pendingFile.removeLastBlock(lastBlock); + if (lastBlockInfo != null) { + blockManager.removeBlock(lastBlockInfo); + } finalizeINodeFileUnderConstruction(src, pendingFile, iip.getLatestSnapshotId(), false); if (uc.getNumExpectedLocations() == 0) {