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.protocol.datatransfer.PacketHeader;
|
|||||||
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.ReplicaState;
|
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.ReplicaState;
|
||||||
import org.apache.hadoop.hdfs.server.common.DataNodeLockManager.LockLevel;
|
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.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.LengthInputStream;
|
||||||
import org.apache.hadoop.hdfs.server.datanode.fsdataset.ReplicaInputStreams;
|
import org.apache.hadoop.hdfs.server.datanode.fsdataset.ReplicaInputStreams;
|
||||||
import org.apache.hadoop.hdfs.util.DataTransferThrottler;
|
import org.apache.hadoop.hdfs.util.DataTransferThrottler;
|
||||||
@ -295,7 +296,12 @@ class BlockSender implements java.io.Closeable {
|
|||||||
(!is32Bit || length <= Integer.MAX_VALUE);
|
(!is32Bit || length <= Integer.MAX_VALUE);
|
||||||
|
|
||||||
// Obtain a reference before reading data
|
// 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
|
* (corruptChecksumOK, meta_file_exist): operation
|
||||||
|
@ -4107,8 +4107,12 @@ public class DataNode extends ReconfigurableBase
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!fromScanner && blockScanner.isEnabled()) {
|
if (!fromScanner && blockScanner.isEnabled()) {
|
||||||
blockScanner.markSuspectBlock(data.getVolume(block).getStorageID(),
|
FsVolumeSpi volume = data.getVolume(block);
|
||||||
block);
|
if (volume == null) {
|
||||||
|
LOG.warn("Cannot find FsVolumeSpi to handle bad block: {}", block);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
blockScanner.markSuspectBlock(volume.getStorageID(), block);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
reportBadBlocks(block);
|
reportBadBlocks(block);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user