apache/hadoop · error · IOException

Inconsistent size of finalized replicas. Replica {} expected

Error message

Inconsistent size of finalized replicas. Replica {} expected size: {}

What it means

Error "Inconsistent size of finalized replicas. Replica {} expected size: {}" thrown in apache/hadoop.

Source

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

            "have the block or their replicas have 0 length. The block can " +
            "be deleted.", block);
        nn.commitBlockSynchronization(block, recoveryId, 0,
            true, true, DatanodeID.EMPTY_ARRAY, null);
        return;
      }

      // Calculate the best available replica state.
      ReplicaState bestState = ReplicaState.RWR;
      long finalizedLength = -1;
      for (BlockRecord r : syncList) {
        assert r.rInfo.getNumBytes() > 0 : "zero length replica";
        ReplicaState rState = r.rInfo.getOriginalReplicaState();
        if (rState.getValue() < bestState.getValue()) {
          bestState = rState;
        }
        if(rState == ReplicaState.FINALIZED) {
          if (finalizedLength > 0 && finalizedLength != r.rInfo.getNumBytes()) {
            throw new IOException("Inconsistent size of finalized replicas. " +
                "Replica " + r.rInfo + " expected size: " + finalizedLength);
          }
          finalizedLength = r.rInfo.getNumBytes();
        }
      }

      // Calculate list of nodes that will participate in the recovery
      // and the new block size
      List<BlockRecord> participatingList = new ArrayList<>();
      final ExtendedBlock newBlock = new ExtendedBlock(bpid, blockId,
          -1, recoveryId);
      switch(bestState) {
      case FINALIZED:
        assert finalizedLength > 0 : "finalizedLength is not positive";
        for(BlockRecord r : syncList) {
          ReplicaState rState = r.rInfo.getOriginalReplicaState();
          if (rState == ReplicaState.FINALIZED ||
              rState == ReplicaState.RBW &&

View on GitHub (pinned to 2add963021)

Solutions

  1. Inspect the replicas on the listed DataNodes; inconsistent finalized lengths indicate corruption or a failed earlier write.
  2. Invalidate the incorrectly sized replica so the NameNode re-replicates the block from a replica with the expected size.

When it happens

Trigger: Block recovery finds finalized replicas of the same block whose on-disk lengths differ from the expected size recorded by the NameNode.

Common situations: Finalized replicas of the same block report different lengths, indicating past corruption or a partial write. Inspect replica sizes and let recovery pick the majority length.


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