{"record":{"id":"035da95ae0185f0c","repo":"apache/hadoop","slug":"block-ids-mismatched-block-i-blocki-expecte","errorCode":null,"errorMessage":"Block IDs mismatched: block${i}=${blocki}, expected block group=${blockGroup}","messagePattern":"Block IDs mismatched: block(.+?)=(.+?), expected block group=(.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/util/StripedBlockUtil.java","lineNumber":1014,"sourceCode":"    @Override\n    public String toString() {\n      return String.format(\"StripeRange(offsetInBlock=%d, length=%d)\",\n          offsetInBlock, length);\n    }\n  }\n\n  /**\n   * Check if the information such as IDs and generation stamps in block-i\n   * match the block group.\n   */\n  public static void checkBlocks(ExtendedBlock blockGroup,\n      int i, ExtendedBlock blocki) throws IOException {\n    if (!blocki.getBlockPoolId().equals(blockGroup.getBlockPoolId())) {\n      throw new IOException(\"Block pool IDs mismatched: block\" + i + \"=\"\n          + blocki + \", expected block group=\" + blockGroup);\n    }\n    if (blocki.getBlockId() - i != blockGroup.getBlockId()) {\n      throw new IOException(\"Block IDs mismatched: block\" + i + \"=\"\n          + blocki + \", expected block group=\" + blockGroup);\n    }\n    if (blocki.getGenerationStamp() != blockGroup.getGenerationStamp()) {\n      throw new IOException(\"Generation stamps mismatched: block\" + i + \"=\"\n          + blocki + \", expected block group=\" + blockGroup);\n    }\n  }\n\n  public static int getBlockIndex(Block reportedBlock) {\n    long BLOCK_GROUP_INDEX_MASK = 15;\n    return (int) (reportedBlock.getBlockId() &\n        BLOCK_GROUP_INDEX_MASK);\n  }\n}\n","sourceCodeStart":996,"sourceCodeEnd":1029,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/util/StripedBlockUtil.java#L996-L1029","documentation":"Second invariant in StripedBlockUtil.checkBlocks(): for internal block i of a striped group, blockId(i) must equal groupBlockId + i — striped internal blocks have consecutive ids with the group id as base (the low 4 bits of a group id are the index mask, see getBlockIndex). If blocki.getBlockId() - i != blockGroup.getBlockId(), IOException is thrown during the striped write (DFSStripedOutputStream.waitEndBlocks).","triggerScenarios":"Writing an EC file when a streamer's allocated block id is not contiguous with the block group id — i.e., the block returned by the DN/NN does not line up with the streamer's index in the group. Internal invariant violation, not a client-configurable condition.","commonSituations":"Version skew between NameNode and DataNodes on striped block id layout, or a regression in striped block allocation; manifests as EC write failures with 'Block IDs mismatched' in the client trace.","solutions":["Retry the write; single occurrences usually indicate a transient allocation race","Confirm uniform Hadoop versions across the cluster (block id layout is version-dependent)","Extract the block ids from the message and inspect them via `hdfs fsck` / block reports to confirm the group-id/index relationship is broken","Persistent recurrence: gather NN/DN logs for the block group id and file a Hadoop JIRA"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  try (FSDataOutputStream out = fs.create(ecPath)) { /* write striped data */ }\n} catch (IOException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"Block IDs mismatched\")) {\n    LOG.warn(\"Striped write failed on block id mismatch; retry job and check cluster versions\", e);\n  } else { throw e; }\n}","preventionTips":["Pin the cluster to one Hadoop version for EC workloads (block id layout is version-dependent)","Run `hdfs fsck` after repeated striped-write failures to rule out metadata damage"],"tags":["hdfs","erasure-coding","striped-blocks","block-id","write-path"],"backgroundTag":"block-metadata-mismatch","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}