Browse Source

HDFS-17275: judge whether the block has been deleted in the block report (#6335). Contributed by lei w.

Reviewed-by: He Xiaoqiao <hexiaoqiao@apache.org>
Signed-off-by: Shuyan Zhang <zhangshuyan@apache.org>
Lei313 1 year ago
parent
commit
773dd7cc85

+ 3 - 3
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java

@@ -3425,7 +3425,7 @@ public class BlockManager implements BlockStatsMXBean {
 
 
     // find block by blockId
     // find block by blockId
     BlockInfo storedBlock = getStoredBlock(block);
     BlockInfo storedBlock = getStoredBlock(block);
-    if(storedBlock == null) {
+    if (storedBlock == null) {
       // If blocksMap does not contain reported block id,
       // If blocksMap does not contain reported block id,
       // The replica should be removed from Datanode, and set NumBytes to BlockCommand.No_ACK to
       // The replica should be removed from Datanode, and set NumBytes to BlockCommand.No_ACK to
       // avoid useless report to NameNode from Datanode when complete to process it.
       // avoid useless report to NameNode from Datanode when complete to process it.
@@ -3439,8 +3439,8 @@ public class BlockManager implements BlockStatsMXBean {
     // Block is on the NN
     // Block is on the NN
     LOG.debug("In memory blockUCState = {}", ucState);
     LOG.debug("In memory blockUCState = {}", ucState);
 
 
-    // Ignore replicas already scheduled to be removed from the DN
-    if(invalidateBlocks.contains(dn, block)) {
+    // Ignore replicas already scheduled to be removed from the DN or had been deleted
+    if (invalidateBlocks.contains(dn, block) || storedBlock.isDeleted()) {
       return storedBlock;
       return storedBlock;
     }
     }