{"record":{"id":"d52a096e1bedcc20","repo":"apache/druid","slug":"expected-version-9-got-d","errorCode":null,"errorMessage":"Expected version[9], got[%d]","messagePattern":"Expected version\\[9\\], got\\[(.+?)\\]","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/segment/IndexIO.java","lineNumber":574,"sourceCode":"  static class V9IndexLoader implements IndexLoader\n  {\n    private final ColumnConfig columnConfig;\n\n    V9IndexLoader(ColumnConfig columnConfig)\n    {\n      this.columnConfig = columnConfig;\n    }\n\n    @Override\n    public QueryableIndex load(File inDir, ObjectMapper mapper, boolean lazy, SegmentLazyLoadFailCallback loadFailed)\n        throws IOException\n    {\n      log.debug(\"Mapping v9 index[%s]\", inDir);\n      long startTime = System.currentTimeMillis();\n\n      final int theVersion = Ints.fromByteArray(Files.toByteArray(new File(inDir, \"version.bin\")));\n      if (theVersion != V9_VERSION) {\n        throw new IAE(\"Expected version[9], got[%d]\", theVersion);\n      }\n\n      SmooshedFileMapper smooshedFiles = Smoosh.map(inDir);\n\n      ByteBuffer indexBuffer = smooshedFiles.mapFile(\"index.drd\");\n      /**\n       * Index.drd should consist of the segment version, the columns and dimensions of the segment as generic\n       * indexes, the interval start and end millis as longs (in 16 bytes), and a bitmap index type.\n       */\n      final GenericIndexed<String> nonNullCols = GenericIndexed.read(\n          indexBuffer,\n          GenericIndexed.STRING_STRATEGY,\n          smooshedFiles\n      );\n      final GenericIndexed<String> nonNullDims = GenericIndexed.read(\n          indexBuffer,\n          GenericIndexed.STRING_STRATEGY,\n          smooshedFiles","sourceCodeStart":556,"sourceCodeEnd":592,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/segment/IndexIO.java#L556-L592","documentation":"The v9 segment mapper (DefaultMapper) reads version.bin and requires exactly V9_VERSION (9). Any other integer means the directory is not a v9 segment — usually a v8 segment or corrupt version file — so loading is rejected with IAE.","triggerScenarios":"IndexIO.mapDir (v9 path) invoked on a directory whose version.bin contains 8 (legacy), another future version, or garbage from a truncated write.","commonSituations":"Pointing a modern loader at legacy v8 segments without running the v8->v9 conversion; interrupted segment writes leaving an empty/partial version.bin; restoring segments from incompatible Druid versions.","solutions":["Check version.bin contents and route v8 segments through the legacy loader or convert them to v9","Re-download the segment from deep storage if version.bin is truncated or corrupt","Upgrade/downgrade so the Druid version supports the segment's format version, or re-ingest the data"],"exampleFix":"// before\nIndexableAdapter adapter = IndexIO.mapIO(segmentDir); // assumes v9\n// after\nbyte[] v = Files.toByteArray(new File(segmentDir, \"version.bin\"));\nif (Ints.fromByteArray(v) != IndexIO.V9_VERSION) {\n  // convert legacy segment before loading\n  segmentDir = convertToV9(segmentDir);\n}\nIndexableAdapter adapter = IndexIO.mapIO(segmentDir);","handlingStrategy":"try-catch","validationCode":"final int version = Ints.fromByteArray(Files.toByteArray(new File(inDir, \"version.bin\")));\nif (version != IndexIO.V9_VERSION) {\n  throw new IllegalStateException(\"Segment \" + inDir + \" is version \" + version + \", expected 9\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  indexIO.mapDir(inDir, config, mapper, factoryMap, loaderConfig);\n} catch (IAE e) {\n  if (e.getMessage().contains(\"Expected version[9]\")) {\n    // convert legacy segment or abort loading with clear message\n  }\n}","preventionTips":["Convert v8 segments to v9 before loading with modern Druid","Validate version.bin exists and parses after segment restore","Keep Druid version aligned with the segment format version in deep storage"],"tags":["druid","segment","version","unsupported-format"],"backgroundTag":"unsupported-enum-value","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}