{"record":{"id":"26a2b79d3be2b4d5","repo":"apache/cassandra","slug":"data-file-for-segment-doesn-t-exist","errorCode":null,"errorMessage":"Data file for segment  doesn't exist","messagePattern":"Data file for segment  doesn't exist","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/journal/StaticSegment.java","lineNumber":104,"sourceCode":"        {\n            StaticSegment<K, V> segment = open(descriptor, keySupport, crcFailurePolicy);\n            segments.add(segment);\n        }\n\n        return segments;\n    }\n\n    /**\n     * Load the segment corresponding to the provided desrciptor\n     *\n     * @param descriptor descriptor of the segment to load\n     * @return the loaded segment\n     */\n    @SuppressWarnings({ \"resource\", \"RedundantSuppression\" })\n    static <K, V> StaticSegment<K, V> open(Descriptor descriptor, KeySupport<K> keySupport, RecoverableCrcFailurePolicy crcFailurePolicy)\n    {\n        if (!Component.DATA.existsFor(descriptor))\n            throw new IllegalArgumentException(\"Data file for segment \" + descriptor + \" doesn't exist\");\n\n        Metadata metadata = null;\n        if (Component.METADATA.existsFor(descriptor))\n        {\n            try\n            {\n                metadata = Metadata.load(descriptor);\n            }\n            catch (Throwable t)\n            {\n                logger.error(\"Could not load metadata component for {}; rebuilding\",  descriptor, t);\n                Component.METADATA.markCorrupted(descriptor);\n            }\n        }\n\n        if (metadata == null)\n            metadata = Metadata.rebuildAndPersist(descriptor, keySupport, crcFailurePolicy);\n","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/journal/StaticSegment.java#L86-L122","documentation":"StaticSegment.open requires the segment's DATA component file to exist. If it doesn't, it throws IllegalArgumentException naming the segment descriptor. The segment cannot be loaded without its primary data file.","triggerScenarios":"Opening/recovering a journal directory where a segment's DATA file is missing while other components (INDEX, METADATA, CRC) reference it — e.g. leftover descriptors after a crash or manual deletion.","commonSituations":"Crash during segment rollover leaving orphaned index files; manual cleanup deleting data files; incomplete backup restore; running against a directory from a different node.","solutions":["Ensure the DATA file for the named segment exists; restore it from backup if deleted","Remove orphaned non-DATA files for the missing segment so recovery doesn't try to open it","Run journal recovery with a policy that tolerates/repairs missing segments","Verify the configured journal directory is the correct, complete data directory"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if (!Component.DATA.existsFor(descriptor)) skipSegment(descriptor); // pre-check identical to the library's own guard","typeGuard":"boolean loadable(Descriptor d) { return Component.DATA.existsFor(d); }","tryCatchPattern":"try { StaticSegment.open(desc, keySupport, policy); } catch (IllegalArgumentException e) { handleMissingSegment(desc, e); }","preventionTips":["Use journal recovery instead of manual file surgery","Verify complete backups before restoring","Keep index/metadata files and their data file together","Alert on unexpected files disappearing from the journal directory"],"tags":["file-not-found","journal","segment"],"backgroundTag":"file-not-found","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}