{"record":{"id":"be2e2fa57f27c25a","repo":"apache/cassandra","slug":"prepare-phase-failed-because-it-encountered-legacy","errorCode":null,"errorMessage":"Prepare phase failed because it encountered legacy sstables that don't support pending repair, run upgradesstables before starting incremental repairs, repair session (%s)","messagePattern":"Prepare phase failed because it encountered legacy sstables that don't support pending repair, run upgradesstables before starting incremental repairs, repair session \\((.+?)\\)","errorType":"exception","errorClass":"SSTableAcquisitionException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/db/repair/PendingAntiCompaction.java","lineNumber":133,"sourceCode":"        }\n\n        public boolean apply(SSTableReader sstable)\n        {\n            if (!sstable.intersects(ranges))\n                return false;\n\n            StatsMetadata metadata = sstable.getSSTableMetadata();\n\n            // exclude repaired sstables\n            if (metadata.repairedAt != UNREPAIRED_SSTABLE)\n                return false;\n\n            if (!sstable.descriptor.version.hasPendingRepair())\n            {\n                String message = String.format(\"Prepare phase failed because it encountered legacy sstables that don't \" +\n                                               \"support pending repair, run upgradesstables before starting incremental \" +\n                                               \"repairs, repair session (%s)\", prsid);\n                throw new SSTableAcquisitionException(message);\n            }\n\n            // exclude sstables pending repair, but record session ids for\n            // non-finalized sessions for a later error message\n            if (metadata.pendingRepair != NO_PENDING_REPAIR)\n            {\n                if (!ActiveRepairService.instance().consistent.local.isSessionFinalized(metadata.pendingRepair))\n                {\n                    String message = String.format(\"Prepare phase for incremental repair session %s has failed because it encountered \" +\n                                                   \"intersecting sstables belonging to another incremental repair session (%s). This is \" +\n                                                   \"caused by starting an incremental repair session before a previous one has completed. \" +\n                                                   \"Check nodetool repair_admin for hung sessions and fix them.\", prsid, metadata.pendingRepair);\n                    throw new SSTableAcquisitionException(message);\n                }\n                return false;\n            }\n            Collection<CompactionInfo> cis = CompactionManager.instance.active.getCompactionsForSSTable(sstable, OperationType.ANTICOMPACTION);\n            if (cis != null && !cis.isEmpty())","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/repair/PendingAntiCompaction.java#L115-L151","documentation":"Incremental repair requires all sstables to support pending-repair metadata (sstable format 'mc' and later). During PendingAntiCompaction's prepare phase, if an intersecting sstable was written by an older sstable format lacking pending repair support, it throws SSTableAcquisitionException with this message, telling the operator to run upgradesstables first.","triggerScenarios":"Running nodetool repair with incremental repair enabled on a table containing sstables written by a pre-3.0 sstable format (e.g. after upgrading from Cassandra 2.x without upgradesstables); newly streamed/compacted legacy files untouched since upgrade.","commonSituations":"Post-upgrade environments where upgradesstables was skipped; restoring old backups onto upgraded nodes; nodes with long-lived legacy sstables never rewritten.","solutions":["Run 'nodetool upgradesstables' on the affected keyspace/table (or entire cluster) so all sstables use the current format","Verify sstable versions with 'nodetool tablestats' / sstablemetadata and confirm no pre-mc files remain","Re-run the incremental repair after the upgrade completes","Prevent recurrence by running upgradesstables as a standard post-upgrade step"],"exampleFix":"// before\nnodetool repair -inc my_keyspace\n// after\nnodetool upgradesstables my_keyspace\nnodetool repair -inc my_keyspace","handlingStrategy":"validation","validationCode":"// shell: detect legacy sstables before incremental repair\nnodetool tablestats -- keyspace.table | grep -i 'sstable' # then verify versions via sstablemetadata","typeGuard":null,"tryCatchPattern":"try { repairService.submitIncremental(); } catch (Exception e) { if (e.getMessage().contains(\"legacy sstables\")) { runUpgradeSstables(); retry(); } else throw e; }","preventionTips":["Always run upgradesstables after major-version upgrades","Audit restored backups for old sstable formats","Use full repairs until the cluster is fully upgraded"],"tags":["cassandra","repair","sstable","upgrade","incremental-repair"],"backgroundTag":"unsupported-operation","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}