diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/InvalidateBlocks.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/InvalidateBlocks.java index 75561caabac..ff68c020f31 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/InvalidateBlocks.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/InvalidateBlocks.java @@ -293,10 +293,12 @@ class InvalidateBlocks { getBlocksToInvalidateByLimit(nodeToECBlocks.get(dn), toInvalidate, numECBlocks, remainingLimit); } - if (toInvalidate.size() > 0 && getBlockSetsSize(dn) == 0) { - remove(dn); + if (toInvalidate.size() > 0) { + if (getBlockSetsSize(dn) == 0) { + remove(dn); + } + dn.addBlocksToBeInvalidated(toInvalidate); } - dn.addBlocksToBeInvalidated(toInvalidate); return toInvalidate; }