apache/cassandra · error · IllegalArgumentException
Data file for segment doesn't exist
Error message
Data file for segment doesn't exist
What it means
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.
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
Defensive patterns
Strategy: validation
Validate before calling
if (!Component.DATA.existsFor(descriptor)) skipSegment(descriptor); // pre-check identical to the library's own guard
Type guard
boolean loadable(Descriptor d) { return Component.DATA.existsFor(d); } Try / catch
try { StaticSegment.open(desc, keySupport, policy); } catch (IllegalArgumentException e) { handleMissingSegment(desc, e); } Prevention
- 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
When it happens
Trigger: 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.
Common situations: Crash during segment rollover leaving orphaned index files; manual cleanup deleting data files; incomplete backup restore; running against a directory from a different node.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- Can't open %r for reading: no matching file found
- Cannot locate . If this is a local file, please confirm…
- Cannot reset state and replay from a save point; must…
- Cannot return configuration when accord.enabled = false in…
- Could not compact segments: " + toCompact
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/26a2b79d3be2b4d5.
Report an issue: GitHub.
Appendix: source
Thrown at src/java/org/apache/cassandra/journal/StaticSegment.java:104
{
StaticSegment<K, V> segment = open(descriptor, keySupport, crcFailurePolicy);
segments.add(segment);
}
return segments;
}
/**
* Load the segment corresponding to the provided desrciptor
*
* @param descriptor descriptor of the segment to load
* @return the loaded segment
*/
@SuppressWarnings({ "resource", "RedundantSuppression" })
static <K, V> StaticSegment<K, V> open(Descriptor descriptor, KeySupport<K> keySupport, RecoverableCrcFailurePolicy crcFailurePolicy)
{
if (!Component.DATA.existsFor(descriptor))
throw new IllegalArgumentException("Data file for segment " + descriptor + " doesn't exist");
Metadata metadata = null;
if (Component.METADATA.existsFor(descriptor))
{
try
{
metadata = Metadata.load(descriptor);
}
catch (Throwable t)
{
logger.error("Could not load metadata component for {}; rebuilding", descriptor, t);
Component.METADATA.markCorrupted(descriptor);
}
}
if (metadata == null)
metadata = Metadata.rebuildAndPersist(descriptor, keySupport, crcFailurePolicy);
View on GitHub (pinned to 88fd0f6a0e)