apache/hadoop · error · IOException

Invalid checksum length: received length is {} but expected

Error message

Invalid checksum length: received length is {} but expected length is {}

What it means

Error "Invalid checksum length: received length is {} but expected length is {}" thrown in apache/hadoop.

Source

Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockReceiver.java:655

    }
    
    ByteBuffer dataBuf = packetReceiver.getDataSlice();
    ByteBuffer checksumBuf = packetReceiver.getChecksumSlice();
    
    if (lastPacketInBlock || len == 0) {
      if(LOG.isDebugEnabled()) {
        LOG.debug("Receiving an empty packet or the end of the block " + block);
      }
      // sync block if requested
      if (syncBlock) {
        flushOrSync(true, seqno);
      }
    } else {
      final int checksumLen = diskChecksum.getChecksumSize(len);
      final int checksumReceivedLen = checksumBuf.capacity();

      if (checksumReceivedLen > 0 && checksumReceivedLen != checksumLen) {
        throw new IOException("Invalid checksum length: received length is "
            + checksumReceivedLen + " but expected length is " + checksumLen);
      }

      if (checksumReceivedLen > 0 && shouldVerifyChecksum()) {
        try {
          verifyChunks(dataBuf, checksumBuf);
        } catch (IOException ioe) {
          // checksum error detected locally. there is no reason to continue.
          if (responder != null) {
            try {
              ((PacketResponder) responder.getRunnable()).enqueue(seqno,
                  lastPacketInBlock, offsetInBlock,
                  Status.ERROR_CHECKSUM);
              // Wait until the responder sends back the response
              // and interrupt this thread.
              Thread.sleep(3000);
            } catch (InterruptedException e) { }
          }

View on GitHub (pinned to 2add963021)

Solutions

  1. Confirm the client uses the same checksum type and bytes-per-checksum as the block/pipeline expects (dfs.checksum.type, dfs.bytes-per-checksum).
  2. Check for version-skew between client and DataNode producing a checksum buffer of unexpected size.

When it happens

Trigger: The checksum byte array received with a packet has a length different from what the DataNode computed for the packet's data chunks.

Common situations: The checksum section of a packet had a length different from the configured checksum size. Confirm matching checksum configuration between client and cluster.


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/7153f6c501732234. Report an issue: GitHub.