HDFS-17298. Fix NPE in DataNode.handleBadBlock and BlockSender (#6374)
This commit is contained in:
parent
e07e445326
commit
7e2ebfc17e
@ -41,6 +41,7 @@
|
||||
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.ReplicaState;
|
||||
import org.apache.hadoop.hdfs.server.common.DataNodeLockManager.LockLevel;
|
||||
import org.apache.hadoop.hdfs.server.datanode.fsdataset.FsVolumeReference;
|
||||
import org.apache.hadoop.hdfs.server.datanode.fsdataset.FsVolumeSpi;
|
||||
import org.apache.hadoop.hdfs.server.datanode.fsdataset.LengthInputStream;
|
||||
import org.apache.hadoop.hdfs.server.datanode.fsdataset.ReplicaInputStreams;
|
||||
import org.apache.hadoop.hdfs.util.DataTransferThrottler;
|
||||
@ -295,7 +296,12 @@ class BlockSender implements java.io.Closeable {
|
||||
(!is32Bit || length <= Integer.MAX_VALUE);
|
||||
|
||||
// Obtain a reference before reading data
|
||||
volumeRef = datanode.data.getVolume(block).obtainReference();
|
||||
FsVolumeSpi volume = datanode.data.getVolume(block);
|
||||
if (volume == null) {
|
||||
LOG.warn("Cannot find FsVolumeSpi to obtain a reference for block: {}", block);
|
||||
throw new ReplicaNotFoundException(block);
|
||||
}
|
||||
volumeRef = volume.obtainReference();
|
||||
|
||||
/*
|
||||
* (corruptChecksumOK, meta_file_exist): operation
|
||||
|
@ -4107,8 +4107,12 @@ void handleBadBlock(ExtendedBlock block, IOException e, boolean fromScanner) {
|
||||
return;
|
||||
}
|
||||
if (!fromScanner && blockScanner.isEnabled()) {
|
||||
blockScanner.markSuspectBlock(data.getVolume(block).getStorageID(),
|
||||
block);
|
||||
FsVolumeSpi volume = data.getVolume(block);
|
||||
if (volume == null) {
|
||||
LOG.warn("Cannot find FsVolumeSpi to handle bad block: {}", block);
|
||||
return;
|
||||
}
|
||||
blockScanner.markSuspectBlock(volume.getStorageID(), block);
|
||||
} else {
|
||||
try {
|
||||
reportBadBlocks(block);
|
||||
|
Loading…
Reference in New Issue
Block a user