{"record":{"id":"269a28a9b794074e","repo":"apache/hadoop","slug":"inconsistent-size-of-finalized-replicas-replica","errorCode":null,"errorMessage":"Inconsistent size of finalized replicas. Replica {} expected size: {}","messagePattern":"Inconsistent size of finalized replicas\\. Replica (.+?) expected size: (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockRecoveryWorker.java","lineNumber":222,"sourceCode":"            \"have the block or their replicas have 0 length. The block can \" +\n            \"be deleted.\", block);\n        nn.commitBlockSynchronization(block, recoveryId, 0,\n            true, true, DatanodeID.EMPTY_ARRAY, null);\n        return;\n      }\n\n      // Calculate the best available replica state.\n      ReplicaState bestState = ReplicaState.RWR;\n      long finalizedLength = -1;\n      for (BlockRecord r : syncList) {\n        assert r.rInfo.getNumBytes() > 0 : \"zero length replica\";\n        ReplicaState rState = r.rInfo.getOriginalReplicaState();\n        if (rState.getValue() < bestState.getValue()) {\n          bestState = rState;\n        }\n        if(rState == ReplicaState.FINALIZED) {\n          if (finalizedLength > 0 && finalizedLength != r.rInfo.getNumBytes()) {\n            throw new IOException(\"Inconsistent size of finalized replicas. \" +\n                \"Replica \" + r.rInfo + \" expected size: \" + finalizedLength);\n          }\n          finalizedLength = r.rInfo.getNumBytes();\n        }\n      }\n\n      // Calculate list of nodes that will participate in the recovery\n      // and the new block size\n      List<BlockRecord> participatingList = new ArrayList<>();\n      final ExtendedBlock newBlock = new ExtendedBlock(bpid, blockId,\n          -1, recoveryId);\n      switch(bestState) {\n      case FINALIZED:\n        assert finalizedLength > 0 : \"finalizedLength is not positive\";\n        for(BlockRecord r : syncList) {\n          ReplicaState rState = r.rInfo.getOriginalReplicaState();\n          if (rState == ReplicaState.FINALIZED ||\n              rState == ReplicaState.RBW &&","sourceCodeStart":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockRecoveryWorker.java#L204-L240","documentation":"Error \"Inconsistent size of finalized replicas. Replica {} expected size: {}\" thrown in apache/hadoop.","triggerScenarios":"Block recovery finds finalized replicas of the same block whose on-disk lengths differ from the expected size recorded by the NameNode.","commonSituations":"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.","solutions":["Inspect the replicas on the listed DataNodes; inconsistent finalized lengths indicate corruption or a failed earlier write.","Invalidate the incorrectly sized replica so the NameNode re-replicates the block from a replica with the expected size."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}