HDFS-16180.FsVolumeImpl.nextBlock should consider that the block meta file has been deleted. (#3315)

This commit is contained in:
Neil 2021-08-24 11:15:47 +08:00 committed by GitHub
parent b6d1971820
commit 9084c728eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View File

@ -21,6 +21,7 @@
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileDescriptor;
import java.io.FileNotFoundException;
import java.io.FilenameFilter;
import java.io.IOException;
import java.io.InputStream;
@ -98,7 +99,8 @@ public boolean accept(File dir, String name) {
});
if (matches == null || matches.length == 0) {
throw new IOException("Meta file not found, blockFile=" + blockFile);
throw new FileNotFoundException(
"Meta file not found, blockFile=" + blockFile);
}
if (matches.length > 1) {
throw new IOException("Found more than one meta files: "

View File

@ -20,6 +20,7 @@
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FilenameFilter;
import java.io.IOException;
import java.io.OutputStreamWriter;
@ -865,7 +866,15 @@ public ExtendedBlock nextBlock() throws IOException {
}
File blkFile = getBlockFile(bpid, block);
File metaFile = FsDatasetUtil.findMetaFile(blkFile);
File metaFile ;
try {
metaFile = FsDatasetUtil.findMetaFile(blkFile);
} catch (FileNotFoundException e){
LOG.warn("nextBlock({}, {}): {}", storageID, bpid,
e.getMessage());
continue;
}
block.setGenerationStamp(
Block.getGenerationStamp(metaFile.getName()));
block.setNumBytes(blkFile.length());