{"record":{"id":"1ef2f91b8581bb6a","repo":"apache/cassandra","slug":"an-error-occurred-while-scrubbing-the-partition-wi-1ef2f9","errorCode":null,"errorMessage":"An error occurred while scrubbing the partition with key '%s' for an index table. Scrubbing will abort for this table and the index will be rebuilt.","messagePattern":"An error occurred while scrubbing the partition with key '(.+?)' for an index table\\. Scrubbing will abort for this table and the index will be rebuilt\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/io/sstable/format/big/BigTableScrubber.java","lineNumber":271,"sourceCode":"            catch (Throwable th)\n            {\n                throwIfFatal(th);\n                outputHandler.warn(th, \"Failed to seek to next partition position %d\", nextPartitionPositionFromIndex);\n                badPartitions++;\n            }\n\n            updateIndexKey();\n        }\n\n        return false;\n    }\n\n    @Override\n    protected void throwIfCannotContinue(DecoratedKey key, Throwable th)\n    {\n        if (isIndex)\n        {\n            outputHandler.warn(\"An error occurred while scrubbing the partition with key '%s' for an index table. \" +\n                               \"Scrubbing will abort for this table and the index will be rebuilt.\", keyString(key));\n            throw new IOError(th);\n        }\n\n        super.throwIfCannotContinue(key, th);\n    }\n\n    @Override\n    public void close()\n    {\n        fileAccessLock.writeLock().lock();\n        try\n        {\n            FileUtils.closeQuietly(dataFile);\n            FileUtils.closeQuietly(indexFile);\n        }\n        finally\n        {","sourceCodeStart":253,"sourceCodeEnd":289,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/io/sstable/format/big/BigTableScrubber.java#L253-L289","documentation":"When scrubbing an SAI/index-backed table, if a partition belonging to the index's base table fails to scrub and the SSTable is an index table, BigTableScrubber warns and aborts the scrub for that table (throws IOError). The rationale is that a corrupt index table should not be 'repaired' by skipping — dropping and rebuilding the index regenerates it correctly from base data.","triggerScenarios":"nodetool scrub on a table with SAI (storage-attached) indexes when a corrupt partition is found in the underlying index SSTable.","commonSituations":"Disk corruption or torn writes affecting index SSTables; scrubbing after unclean shutdown on tables with SAI indexes.","solutions":["Let the abort stand (correct behavior), then rebuild the index: ALTER TABLE ... DROP INDEX and re-CREATE the SAI index, or drop/re-add the index column index.","Scrub the base table separately; index tables are rebuilt from base data so base-table scrubbing should succeed.","Investigate the corruption source (disk, filesystem, version-specific bugs) before re-running the scrub."],"exampleFix":"// before: scrub aborts on corrupt index SSTable\nnodetool scrub <keyspace> <table_with_sai>\n// after: drop and rebuild the index to regenerate index SSTables\nALTER TABLE ks.tbl DROP INDEX tbl_idx;\nCREATE CUSTOM INDEX tbl_idx ON ks.tbl (col) USING 'StorageAttachedIndex';","handlingStrategy":"fallback","validationCode":"# Before scrubbing SAI-backed tables, verify index and base SSTables\nnodetool verify <keyspace> <table_with_sai>\nnodetool snapshot <keyspace> --table <table_with_sai>  # snapshot first","typeGuard":null,"tryCatchPattern":"// CLI-level: scrub aborts (IOError) on corrupt index SSTable — expected.\n// Fallback: DROP INDEX, scrub base table, re-CREATE index to regenerate index SSTables cleanly\n// ALTER TABLE ks.tbl DROP INDEX idx;\n// nodetool scrub ks tbl;\n// CREATE CUSTOM INDEX idx ON ks.tbl (col) USING 'StorageAttachedIndex';","preventionTips":["Snapshot before scrubbing any table with SAI indexes.","Run nodetool verify to find corrupt index SSTables before scrubbing.","Treat index corruption as rebuildable: prefer DROP/CREATE INDEX over data-skipping scrubs.","Monitor disk health and repair after unclean shutdowns to prevent index SSTable corruption."],"tags":["cassandra","scrub","sai","index","data-corruption"],"backgroundTag":"checksum-mismatch","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"}