{"record":{"id":"fc9bb91c2154bdb3","repo":"apache/hadoop","slug":"only-found-actualnuminodes-inode-entries-out-o","errorCode":null,"errorMessage":"Only found {actualNumINodes} <inode> entries out of {expectedNumInodes}","messagePattern":"Only found (.+?) <inode> entries out of (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/OfflineImageReconstructor.java","lineNumber":597,"sourceCode":"      Long lval = headerNode.removeChildLong(INODE_SECTION_LAST_INODE_ID);\n      if (lval != null)  {\n        b.setLastInodeId(lval);\n      }\n      Integer expectedNumINodes =\n          headerNode.removeChildInt(INODE_SECTION_NUM_INODES);\n      if (expectedNumINodes == null) {\n        throw new IOException(\"Failed to find <numInodes> in INodeSection.\");\n      }\n      b.setNumInodes(expectedNumINodes);\n      INodeSection s = b.build();\n      s.writeDelimitedTo(out);\n      headerNode.verifyNoRemainingKeys(\"INodeSection\");\n      int actualNumINodes = 0;\n      while (actualNumINodes < expectedNumINodes) {\n        try {\n          expectTag(INODE_SECTION_INODE, false);\n        } catch (IOException e) {\n          throw new IOException(\"Only found \" + actualNumINodes +\n              \" <inode> entries out of \" + expectedNumINodes, e);\n        }\n        actualNumINodes++;\n        Node inode = new Node();\n        loadNodeChildren(inode, \"INode fields\");\n        INodeSection.INode.Builder inodeBld = processINodeXml(inode);\n        inodeBld.build().writeDelimitedTo(out);\n      }\n      expectTagEnd(INODE_SECTION_NAME);\n      recordSectionLength(SectionName.INODE.name());\n    }\n  }\n\n  private INodeSection.INode.Builder processINodeXml(Node node)\n      throws IOException {\n    String type = node.removeChildStr(INODE_SECTION_TYPE);\n    if (type == null) {\n      throw new IOException(\"INode XML found with no <type> tag.\");","sourceCodeStart":579,"sourceCodeEnd":615,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/OfflineImageReconstructor.java#L579-L615","documentation":"After the header promises expectedNumINodes, the processor calls expectTag(<inode>) exactly that many times; any IOException from expectTag (typically the unexpected end of the section) is re-thrown with this progress message. It means the XML physically contains fewer <inode> elements than <numInodes> declares - a count/content mismatch, not a parse error.","triggerScenarios":"ReverseXML after inode entries were deleted without decrementing <numInodes>; XML truncated mid-section; entries renamed so expectTag(<inode>) no longer matches them (the original exception is chained as the cause).","commonSituations":"Hand-pruning namespace dumps to remove files; scripted filters that drop entries but not header counts; interrupted copies of the XML.","solutions":["Make counts agree: set <numInodes> to the actual number of <inode> elements (or restore the missing entries)","Regenerate the dump and prune with a DOM tool that updates counts automatically","Rule out truncation: xmllint --noout plus a look at the tail of the file"],"exampleFix":"<!-- before: 5 inodes remain but header still says 8 -->\n<INodeSection><numInodes>8</numInodes>...(5 <inode> elements)...</INodeSection>\n\n<!-- after -->\n<INodeSection><numInodes>5</numInodes>...(5 <inode> elements)...</INodeSection>","handlingStrategy":"validation","validationCode":"declared=$(xmllint --xpath 'string(//INodeSection/numInodes)' fsimage.xml)\nactual=$(xmllint --xpath 'count(//inode)' fsimage.xml)\n[ \"$declared\" = \"$actual\" ] || { echo \"expected $declared inodes, found $actual - fix count or entries\"; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Update counts in the same commit as entry deletions","After filtering entries programmatically, recompute all section counts","Prefer regenerating from fsimage over subtractive XML edits"],"tags":["hdfs","reversexml","fsimage","count-mismatch","inodesection"],"backgroundTag":"element-count-mismatch","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}