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) {