Skip to content

Commit 710fdc5

Browse files
author
wangchengwei
committed
HDFS-16985. delete local block file when FileNotFoundException occurred may lead to missing block.
1 parent 6ea10cf commit 710fdc5

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

  • hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockSender.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -351,11 +351,16 @@ class BlockSender implements java.io.Closeable {
351351
} catch (FileNotFoundException e) {
352352
if ((e.getMessage() != null) && !(e.getMessage()
353353
.contains("Too many open files"))) {
354-
// The replica is on its volume map but not on disk
354+
// The replica seems is on its volume map but not on disk.
355+
// We can't confirm here is block file lost or disk failed.
356+
// If block lost:
357+
// deleted local block file is completely unnecessary
358+
// If disk failed:
359+
// deleted local block file here may lead to missing-block
360+
// when it with only 1 replication left now.
361+
// So just notify namenode is ok.
355362
datanode
356363
.notifyNamenodeDeletedBlock(block, replica.getStorageUuid());
357-
datanode.data.invalidate(block.getBlockPoolId(),
358-
new Block[] {block.getLocalBlock()});
359364
}
360365
throw e;
361366
} finally {

0 commit comments

Comments
 (0)