Skip to content

Commit 9084c72

Browse files
authored
HDFS-16180.FsVolumeImpl.nextBlock should consider that the block meta file has been deleted. (#3315)
1 parent b6d1971 commit 9084c72

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetUtil.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.io.DataOutputStream;
2222
import java.io.File;
2323
import java.io.FileDescriptor;
24+
import java.io.FileNotFoundException;
2425
import java.io.FilenameFilter;
2526
import java.io.IOException;
2627
import java.io.InputStream;
@@ -98,7 +99,8 @@ public boolean accept(File dir, String name) {
9899
});
99100

100101
if (matches == null || matches.length == 0) {
101-
throw new IOException("Meta file not found, blockFile=" + blockFile);
102+
throw new FileNotFoundException(
103+
"Meta file not found, blockFile=" + blockFile);
102104
}
103105
if (matches.length > 1) {
104106
throw new IOException("Found more than one meta files: "

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsVolumeImpl.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.io.BufferedWriter;
2121
import java.io.File;
2222
import java.io.FileInputStream;
23+
import java.io.FileNotFoundException;
2324
import java.io.FilenameFilter;
2425
import java.io.IOException;
2526
import java.io.OutputStreamWriter;
@@ -865,7 +866,15 @@ public ExtendedBlock nextBlock() throws IOException {
865866
}
866867

867868
File blkFile = getBlockFile(bpid, block);
868-
File metaFile = FsDatasetUtil.findMetaFile(blkFile);
869+
File metaFile ;
870+
try {
871+
metaFile = FsDatasetUtil.findMetaFile(blkFile);
872+
} catch (FileNotFoundException e){
873+
LOG.warn("nextBlock({}, {}): {}", storageID, bpid,
874+
e.getMessage());
875+
continue;
876+
}
877+
869878
block.setGenerationStamp(
870879
Block.getGenerationStamp(metaFile.getName()));
871880
block.setNumBytes(blkFile.length());

0 commit comments

Comments
 (0)