apache/hadoop · error · IOException
Got wrong length during writeBlock({}) from {} at offset {}:
Error message
Got wrong length during writeBlock({}) from {} at offset {}: {} What it means
Error "Got wrong length during writeBlock({}) from {} at offset {}: {}" thrown in apache/hadoop.
Source
Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockReceiver.java:568
* returns the number of data bytes that the packet has.
*/
private int receivePacket() throws IOException {
// read the next packet
packetReceiver.receiveNextPacket(in);
PacketHeader header = packetReceiver.getHeader();
long seqno = header.getSeqno();
LOG.debug("Receiving one packet for block {} seqno:{} header:{} ", block,
seqno, header);
// Sanity check the header
if (header.getOffsetInBlock() > replicaInfo.getNumBytes()) {
throw new IOException("Received an out-of-sequence packet for " + block +
"from " + inAddr + " at offset " + header.getOffsetInBlock() +
". Expecting packet starting at " + replicaInfo.getNumBytes());
}
if (header.getDataLen() < 0) {
throw new IOException("Got wrong length during writeBlock(" + block +
") from " + inAddr + " at offset " +
header.getOffsetInBlock() + ": " +
header.getDataLen());
}
long offsetInBlock = header.getOffsetInBlock();
boolean lastPacketInBlock = header.isLastPacketInBlock();
final int len = header.getDataLen();
boolean syncBlock = header.getSyncBlock();
// avoid double sync'ing on close
if (syncBlock && lastPacketInBlock) {
this.syncOnClose = false;
// sync directory for finalize irrespective of syncOnClose config since
// sync is requested.
this.dirSyncOnFinalize = true;
}
View on GitHub (pinned to 2add963021)
Solutions
- Verify client and DataNode versions are compatible; a malformed packet header length field usually indicates protocol mismatch or stream corruption.
- Inspect the network path for truncation/corruption and check the client logs for earlier errors in the same block write.
When it happens
Trigger: The data length read from the stream during receiveBlock does not match the length advertised in the packet header at the current offset.
Common situations: The packet length field did not match the data actually received, typically from stream corruption or a truncated connection. Check network stability between client and DataNode.
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/299c35c7942a22d8.
Report an issue: GitHub.