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
a852800d2f
commit
4fd2adbc5f
|
@ -147,6 +147,9 @@ class BlockSender implements java.io.Closeable {
|
||||||
/** The reference to the volume where the block is located */
|
/** The reference to the volume where the block is located */
|
||||||
private FsVolumeReference volumeRef;
|
private FsVolumeReference volumeRef;
|
||||||
|
|
||||||
|
/** The replica of the block that is being read. */
|
||||||
|
private final Replica replica;
|
||||||
|
|
||||||
// Cache-management related fields
|
// Cache-management related fields
|
||||||
private final long readaheadLength;
|
private final long readaheadLength;
|
||||||
|
|
||||||
|
@ -229,7 +232,6 @@ class BlockSender implements java.io.Closeable {
|
||||||
"If verifying checksum, currently must also send it.");
|
"If verifying checksum, currently must also send it.");
|
||||||
}
|
}
|
||||||
|
|
||||||
final Replica replica;
|
|
||||||
final long replicaVisibleLength;
|
final long replicaVisibleLength;
|
||||||
synchronized(datanode.data) {
|
synchronized(datanode.data) {
|
||||||
replica = getReplica(block, datanode);
|
replica = getReplica(block, datanode);
|
||||||
|
@ -680,8 +682,12 @@ class BlockSender implements java.io.Closeable {
|
||||||
checksum.update(buf, dOff, dLen);
|
checksum.update(buf, dOff, dLen);
|
||||||
if (!checksum.compare(buf, cOff)) {
|
if (!checksum.compare(buf, cOff)) {
|
||||||
long failedPos = offset + datalen - dLeft;
|
long failedPos = offset + datalen - dLeft;
|
||||||
throw new ChecksumException("Checksum failed at " + failedPos,
|
StringBuilder replicaInfoString = new StringBuilder();
|
||||||
failedPos);
|
if (replica != null) {
|
||||||
|
replicaInfoString.append(" for replica: " + replica.toString());
|
||||||
|
}
|
||||||
|
throw new ChecksumException("Checksum failed at " + failedPos
|
||||||
|
+ replicaInfoString, failedPos);
|
||||||
}
|
}
|
||||||
dLeft -= dLen;
|
dLeft -= dLen;
|
||||||
dOff += dLen;
|
dOff += dLen;
|
||||||
|
|
|
@ -282,12 +282,13 @@ public class VolumeScanner extends Thread {
|
||||||
volume.getBasePath(), block);
|
volume.getBasePath(), block);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LOG.warn("Reporting bad {} on {}", block, volume.getBasePath());
|
LOG.warn("Reporting bad " + block + " with volume "
|
||||||
|
+ volume.getBasePath(), e);
|
||||||
try {
|
try {
|
||||||
scanner.datanode.reportBadBlocks(block);
|
scanner.datanode.reportBadBlocks(block);
|
||||||
} catch (IOException ie) {
|
} catch (IOException ie) {
|
||||||
// This is bad, but not bad enough to shut down the scanner.
|
// 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