{"record":{"id":"e873e320bf4a7167","repo":"apache/hadoop","slug":"incorrect-block-size","errorCode":null,"errorMessage":"Incorrect block size","messagePattern":"Incorrect block 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":266,"sourceCode":"        newBlock.setNumBytes(finalizedLength);\n        break;\n      case RBW:\n      case RWR:\n        long minLength = Long.MAX_VALUE;\n        for(BlockRecord r : syncList) {\n          ReplicaState rState = r.rInfo.getOriginalReplicaState();\n          if(rState == bestState) {\n            minLength = Math.min(minLength, r.rInfo.getNumBytes());\n            participatingList.add(r);\n          }\n          LOG.debug(\"syncBlock replicaInfo: block={}, from datanode {}, receivedState={}, \" +\n              \"receivedLength={}, bestState={}\", block, r.id, rState.name(),\n              r.rInfo.getNumBytes(), bestState.name());\n        }\n        // recover() guarantees syncList will have at least one replica with RWR\n        // or better state.\n        if (minLength == Long.MAX_VALUE) {\n          throw new IOException(\"Incorrect block size\");\n        }\n        newBlock.setNumBytes(minLength);\n        break;\n      case RUR:\n      case TEMPORARY:\n        assert false : \"bad replica state: \" + bestState;\n      default:\n        break; // we have 'case' all enum values\n      }\n      if (isTruncateRecovery) {\n        newBlock.setNumBytes(rBlock.getNewBlock().getNumBytes());\n      }\n\n      LOG.info(\"BlockRecoveryWorker: block={} (length={}), bestState={},\"\n              + \" newBlock={} (length={}), participatingList={}\",\n          block, block.getNumBytes(), bestState.name(), newBlock,\n          newBlock.getNumBytes(), participatingList);\n","sourceCodeStart":248,"sourceCodeEnd":284,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockRecoveryWorker.java#L248-L284","documentation":"Error \"Incorrect block size\" thrown in apache/hadoop.","triggerScenarios":"During replica recovery synchronization, the target block size does not match the size agreed in the recovery protocol.","commonSituations":"A replica's on-disk size did not match the expected block size during recovery. Compare against other replicas and disk health before proceeding.","solutions":["Verify the client computed the new block length correctly during recovery/append; retry the operation.","Check for version mismatch between client, NameNode, and DataNode causing disagreement on the block 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"}