HDFS-10625. VolumeScanner to report why a block is found bad. Contributed by Rushabh S Shah and Yiqun Lin.
(cherry picked from commit 5d1609ddf2
)
This commit is contained in:
parent
250ddf155f
commit
18f7628664
|
@ -157,6 +157,9 @@ class BlockSender implements java.io.Closeable {
|
|||
/** The reference to the volume where the block is located */
|
||||
private FsVolumeReference volumeRef;
|
||||
|
||||
/** The replica of the block that is being read. */
|
||||
private final Replica replica;
|
||||
|
||||
// Cache-management related fields
|
||||
private final long readaheadLength;
|
||||
|
||||
|
@ -239,7 +242,6 @@ class BlockSender implements java.io.Closeable {
|
|||
"If verifying checksum, currently must also send it.");
|
||||
}
|
||||
|
||||
final Replica replica;
|
||||
final long replicaVisibleLength;
|
||||
try(AutoCloseableLock lock = datanode.data.acquireDatasetLock()) {
|
||||
replica = getReplica(block, datanode);
|
||||
|
@ -689,8 +691,12 @@ class BlockSender implements java.io.Closeable {
|
|||
checksum.update(buf, dOff, dLen);
|
||||
if (!checksum.compare(buf, cOff)) {
|
||||
long failedPos = offset + datalen - dLeft;
|
||||
throw new ChecksumException("Checksum failed at " + failedPos,
|
||||
failedPos);
|
||||
StringBuilder replicaInfoString = new StringBuilder();
|
||||
if (replica != null) {
|
||||
replicaInfoString.append(" for replica: " + replica.toString());
|
||||
}
|
||||
throw new ChecksumException("Checksum failed at " + failedPos
|
||||
+ replicaInfoString, failedPos);
|
||||
}
|
||||
dLeft -= dLen;
|
||||
dOff += dLen;
|
||||
|
|
|
@ -281,12 +281,13 @@ public class VolumeScanner extends Thread {
|
|||
volume.getBasePath(), block);
|
||||
return;
|
||||
}
|
||||
LOG.warn("Reporting bad {} on {}", block, volume.getBasePath());
|
||||
LOG.warn("Reporting bad " + block + " with volume "
|
||||
+ volume.getBasePath(), e);
|
||||
try {
|
||||
scanner.datanode.reportBadBlocks(block, volume);
|
||||
} catch (IOException ie) {
|
||||
// This is bad, but not bad enough to shut down the scanner.
|
||||
LOG.warn("Cannot report bad " + block.getBlockId(), e);
|
||||
LOG.warn("Cannot report bad block " + block, ie);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue