{"record":{"id":"9722bc489fcc5432","repo":"apache/druid","slug":"s-9722bc","errorCode":null,"errorMessage":"%s","messagePattern":"%s","errorType":"exception","errorClass":"SegmentLoadingException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/segment/loading/MMappedQueryableSegmentizerFactory.java","lineNumber":52,"sourceCode":" */\npublic class MMappedQueryableSegmentizerFactory implements SegmentizerFactory\n{\n\n  private final IndexIO indexIO;\n\n  public MMappedQueryableSegmentizerFactory(@JacksonInject IndexIO indexIO)\n  {\n    this.indexIO = Preconditions.checkNotNull(indexIO, \"Null IndexIO\");\n  }\n\n  @Override\n  public Segment factorize(DataSegment dataSegment, File parentDir, boolean lazy, SegmentLazyLoadFailCallback loadFailed) throws SegmentLoadingException\n  {\n    try {\n      return new QueryableIndexSegment(indexIO.loadIndex(parentDir, lazy, loadFailed), dataSegment.getId());\n    }\n    catch (IOException e) {\n      throw new SegmentLoadingException(e, \"%s\", e.getMessage());\n    }\n  }\n}\n","sourceCodeStart":34,"sourceCodeEnd":56,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/segment/loading/MMappedQueryableSegmentizerFactory.java#L34-L56","documentation":"MMappedQueryableSegmentizerFactory.factorize loads the segment via indexIO.loadIndex and wraps any resulting IOException in a SegmentLoadingException carrying the IO error message. It means the segment could not be memory-mapped/read from its local files.","triggerScenarios":"factorize is invoked during segment loading but loadIndex throws IOException due to missing/corrupt index files, mmapping failure, or unreadable segment directory.","commonSituations":"Corrupted historical segment cache; segment deleted mid-load; NFS/overlay filesystem mmapping issues; wrong Druid version reading segments written by an incompatible writer version.","solutions":["Check the segment files exist and are complete in parentDir","Clear the corrupted segment from the local cache and let Druid re-download it","Verify segment was written by a compatible Druid version","Look at the wrapped IOException cause for the exact filesystem failure"],"exampleFix":"// before\n// retry load against corrupt dir forever\n// after\nif (!indexIO.segmentExists(parentDir)) { cacheCleaner.cleanup(parentDir); }\nSegment seg = new MMappedQueryableSegmentizerFactory(indexIO).factorize(segment, parentDir, lazy, cb);","handlingStrategy":"try-catch","validationCode":"if (!indexIO.segmentExists(parentDir)) { throw new SegmentNotLoadedException(parentDir); }","typeGuard":"boolean loadable(File dir) { return dir.isDirectory() && new File(dir, \"meta.json\").isFile() && new File(dir, \"index.drd\").isFile(); }","tryCatchPattern":"try { return new MMappedQueryableSegmentizerFactory(indexIO).factorize(segment, dir, lazy, cb); } catch (SegmentLoadingException e) { cacheCleaner.cleanup(dir); log.error(e, \"Dropped corrupt segment dir %s\", dir); throw e; }","preventionTips":["Enable segment cache integrity verification","Avoid sharing segment cache dirs across different Druid versions","Alert on deep-storage download completion failures"],"tags":["segment-loading","io-exception","filesystem"],"backgroundTag":"file-read-failed","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}