apache/hadoop · error · IOException
Recorded block size is {}, but datanode returned {} bytes
Error message
Recorded block size is {}, but datanode returned {} bytes What it means
Error "Recorded block size is {}, but datanode returned {} bytes" thrown in apache/hadoop.
Source
Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NamenodeFsck.java:1149
} catch (IOException ex) {
// Put chosen node into dead list, continue
LOG.info("Failed to connect to " + targetAddr + ":" + ex);
deadNodes.add(chosenNode);
}
}
long bytesRead = 0L;
try {
bytesRead = copyBock(blockReader, fos);
} catch (Exception e) {
throw new Exception("Could not copy block data for " + lblock.getBlock(),
e);
} finally {
blockReader.close();
}
if (bytesRead != block.getNumBytes()) {
throw new IOException("Recorded block size is " + block.getNumBytes()
+ ", but datanode returned " + bytesRead + " bytes");
}
}
private long copyBock(BlockReader blockReader, OutputStream os)
throws IOException {
final byte[] buf = new byte[8192];
int cnt = 0;
long bytesRead = 0L;
while ((cnt = blockReader.read(buf, 0, buf.length)) > 0) {
os.write(buf, 0, cnt);
bytesRead += cnt;
}
return bytesRead;
}
@Override
public DataEncryptionKey newDataEncryptionKey() throws IOException {View on GitHub (pinned to 2add963021)
Solutions
- Investigate the DataNode serving the mismatched size; the block may be corrupt — consider recovering or deleting the file.
When it happens
Trigger: A DataNode returns a byte count different from the block size recorded in the NameNode metadata.
Common situations: Disk corruption, truncated blocks, or mixed-version metadata after an unclean shutdown.
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/b6a4ac84d673e1e5.
Report an issue: GitHub.