{"record":{"id":"cbffa9f0a43574e2","repo":"apache/hadoop","slug":"createdlistsize-was-but-there-were-creat","errorCode":null,"errorMessage":"<createdListSize> was {}, but there were {} <created> entries.","messagePattern":"<createdListSize> was (.+?), but there were (.+?) <created> entries\\.","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":1522,"sourceCode":"        while (true) {\n          Node created = dirDiff.removeChild(\n              SNAPSHOT_DIFF_SECTION_CREATED);\n          if (created == null){\n            break;\n          }\n          String cleName = created.removeChildStr(SECTION_NAME);\n          if (cleName == null) {\n            throw new IOException(\"Expected <created> entry to have \" +\n                \"a <name> field\");\n          }\n          created.verifyNoRemainingKeys(\"created\");\n          FsImageProto.SnapshotDiffSection.CreatedListEntry.newBuilder().\n              setName(ByteString.copyFrom(cleName, StandardCharsets.UTF_8)).\n              build().writeDelimitedTo(out);\n          actualCreatedListSize++;\n        }\n        if (actualCreatedListSize != expectedCreatedListSize) {\n          throw new IOException(\"<createdListSize> was \" +\n              expectedCreatedListSize +\", but there were \" +\n              actualCreatedListSize + \" <created> entries.\");\n        }\n        dirDiff.verifyNoRemainingKeys(\"dirDiff\");\n      }\n      expectTagEnd(SNAPSHOT_DIFF_SECTION_DIR_DIFF_ENTRY);\n    }\n\n    private void processFileDiffEntry() throws IOException {\n      LOG.debug(\"Processing fileDiffEntry\");\n      DiffEntry.Builder headerBld = DiffEntry.newBuilder();\n      headerBld.setType(DiffEntry.Type.FILEDIFF);\n      Node fileDiffHeader = new Node();\n      loadNodeChildren(fileDiffHeader, \"fileDiffEntry fields\", \"fileDiff\");\n      Long inodeId = fileDiffHeader.removeChildLong(\n          SNAPSHOT_DIFF_SECTION_INODE_ID);\n      if (inodeId == null) {\n        throw new IOException(\"<fileDiffEntry> contained no <inodeid> entry.\");","sourceCodeStart":1504,"sourceCodeEnd":1540,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/OfflineImageReconstructor.java#L1504-L1540","documentation":"After consuming all <created> entries of a <dirDiff>, the reconstructor compared the running count against the declared <createdListSize> and they differ. The protobuf createdListSize must equal the number of CreatedListEntry records actually serialized, so the mismatch is fatal even though the XML is well-formed.","triggerScenarios":"<created> entries added or deleted without updating <createdListSize>, or vice versa; the declared size edited while the entry list stayed unchanged.","commonSituations":"Hand-edits that fix disaster-recovery images by dropping created files; scripts appending entries but never recounting; partial copy-paste of created lists between diffs.","solutions":["Count the <created> children of the affected <dirDiff> and set <createdListSize> to exactly that number","Alternatively add/remove <created> entries until the list matches the declared size - both sides must agree","Re-run a streaming pre-check that validates size vs entry count for every <dirDiff>","Regenerate the XML from the original fsimage with a same-version oiv"],"exampleFix":"<!-- before: size says 2, only 1 entry -->\n<dirDiff>...<createdListSize>2</createdListSize>\n  <created><name>part-00000</name></created>\n</dirDiff>\n<!-- after -->\n<dirDiff>...<createdListSize>1</createdListSize>\n  <created><name>part-00000</name></created>\n</dirDiff>","handlingStrategy":"validation","validationCode":"# python: createdListSize must equal the number of <created> children\nimport xml.etree.ElementTree as ET\n\ndef created_lists_consistent(path):\n    for ev, el in ET.iterparse(path, events=('end',)):\n        if el.tag == 'dirDiff':\n            s = el.find('createdListSize')\n            if s is not None and int(s.text) != len(el.findall('created')):\n                return False\n    return True","typeGuard":null,"tryCatchPattern":"// catch the oiv count-mismatch message; it prints both numbers -\n// reconcile them, delete partial output, re-run","preventionTips":["Treat createdListSize as derived: recount after every list edit","Change entries and size in the same edit","Stream-validate consistency before ReverseXML","Regenerate the dump when reconciliation is ambiguous"],"tags":["hdfs","oiv","fsimage","reversexml","snapshot-diff","count-mismatch"],"backgroundTag":"xml-entry-count-mismatch","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}