{"record":{"id":"0e74275f913e8460","repo":"apache/cassandra","slug":"could-not-reference-sstables","errorCode":null,"errorMessage":"Could not reference sstables","messagePattern":"Could not reference sstables","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/db/repair/CassandraValidationIterator.java","lineNumber":149,"sourceCode":"            // were marked as repairing, we would miss any ranges that were compacted away and this would cause us to overstream\n            predicate = (s) -> !prs.isIncremental || !s.isRepaired();\n        }\n\n        try (ColumnFamilyStore.RefViewFragment sstableCandidates = cfs.selectAndReference(View.selectFunction(SSTableSet.CANONICAL)))\n        {\n            for (SSTableReader sstable : sstableCandidates.sstables)\n            {\n                if (new Bounds<>(sstable.getFirst().getToken(), sstable.getLast().getToken()).intersects(ranges) && predicate.apply(sstable))\n                {\n                    sstablesToValidate.add(sstable);\n                }\n            }\n\n            sstables = Refs.tryRef(sstablesToValidate);\n            if (sstables == null)\n            {\n                logger.error(\"Could not reference sstables for {}\", parentId);\n                throw new RuntimeException(\"Could not reference sstables\");\n            }\n        }\n\n        return sstables;\n    }\n\n    private final ColumnFamilyStore cfs;\n    private final Refs<SSTableReader> sstables;\n    private final String snapshotName;\n    private final boolean isGlobalSnapshotValidation;\n\n    private final boolean isSnapshotValidation;\n    private final AbstractCompactionStrategy.ScannerList scanners;\n    private final ValidationCompactionController controller;\n\n    private final CompactionIterator ci;\n\n    private final long estimatedBytes;","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/repair/CassandraValidationIterator.java#L131-L167","documentation":"During validation (anti-entropy repair read phase), the CassandraValidationIterator selects sstables and tries to take references via Refs.tryRef; a null return means some sstables were compacted away or otherwise released between selection and referencing, so the iterator cannot safely read them. It logs an error for the parent repair session and throws this RuntimeException, aborting the validation for that session.","triggerScenarios":"Heavy compaction activity concurrently removing candidate sstables while a validator is starting; races between lifecycle tracking and compaction leaving the sstable refcount unable to be acquired.","commonSituations":"Very active write workload with constant compaction during repair; many parallel repairs/compactions; long GC pauses delaying reference acquisition.","solutions":["Retry the repair once compaction pressure subsides; transient races typically succeed on retry","Reduce concurrent compaction during repair (throttle compaction throughput with nodetool compactionthroughput)","Check node.log around the error for which sstable/parent session raced and whether compaction or cleanup removed it","Ensure the repair uses consistent versions and no storage bugs; if reproducible on idle nodes, file with logs for investigation"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { runRepair(); } catch (RuntimeException e) { if (e.getMessage().equals(\"Could not reference sstables\")) { waitForCompactionQuiet(); retryRepair(); } else throw e; }","preventionTips":["Schedule repairs during low-compaction windows","Throttle compaction throughput while repairing","Avoid many simultaneous repairs on the same node"],"tags":["cassandra","repair","compaction","race-condition","sstable"],"backgroundTag":"internal-invariant-violation","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}