Skip to content

Commit 5d1609d

Browse files
author
Yongjun Zhang
committed
HDFS-10625. VolumeScanner to report why a block is found bad. Contributed by Rushabh S Shah and Yiqun Lin.
1 parent 6fcb04c commit 5d1609d

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockSender.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@ class BlockSender implements java.io.Closeable {
156156
/** The reference to the volume where the block is located */
157157
private FsVolumeReference volumeRef;
158158

159+
/** The replica of the block that is being read. */
160+
private final Replica replica;
161+
159162
// Cache-management related fields
160163
private final long readaheadLength;
161164

@@ -238,7 +241,6 @@ class BlockSender implements java.io.Closeable {
238241
"If verifying checksum, currently must also send it.");
239242
}
240243

241-
final Replica replica;
242244
final long replicaVisibleLength;
243245
try(AutoCloseableLock lock = datanode.data.acquireDatasetLock()) {
244246
replica = getReplica(block, datanode);
@@ -688,8 +690,12 @@ public void verifyChecksum(final byte[] buf, final int dataOffset,
688690
checksum.update(buf, dOff, dLen);
689691
if (!checksum.compare(buf, cOff)) {
690692
long failedPos = offset + datalen - dLeft;
691-
throw new ChecksumException("Checksum failed at " + failedPos,
692-
failedPos);
693+
StringBuilder replicaInfoString = new StringBuilder();
694+
if (replica != null) {
695+
replicaInfoString.append(" for replica: " + replica.toString());
696+
}
697+
throw new ChecksumException("Checksum failed at " + failedPos
698+
+ replicaInfoString, failedPos);
693699
}
694700
dLeft -= dLen;
695701
dOff += dLen;

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/VolumeScanner.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,12 +281,13 @@ public void handle(ExtendedBlock block, IOException e) {
281281
volume.getBasePath(), block);
282282
return;
283283
}
284-
LOG.warn("Reporting bad {} on {}", block, volume.getBasePath());
284+
LOG.warn("Reporting bad " + block + " with volume "
285+
+ volume.getBasePath(), e);
285286
try {
286287
scanner.datanode.reportBadBlocks(block, volume);
287288
} catch (IOException ie) {
288289
// This is bad, but not bad enough to shut down the scanner.
289-
LOG.warn("Cannot report bad " + block.getBlockId(), e);
290+
LOG.warn("Cannot report bad block " + block, ie);
290291
}
291292
}
292293
}

0 commit comments

Comments
 (0)