{"record":{"id":"0968be3d31b25182","repo":"apache/cassandra","slug":"error-reading-partition-s-stacktrace-follows-0968be","errorCode":null,"errorMessage":"Error reading partition %s (stacktrace follows):","messagePattern":"Error reading partition (.+?) \\(stacktrace follows\\):","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/java/org/apache/cassandra/io/sstable/format/bti/BtiTableScrubber.java","lineNumber":193,"sourceCode":"                if (currentIndexKey != null && !key.getKey().equals(currentIndexKey))\n                {\n                    throw new IOError(new IOException(String.format(\"Key from data file (%s) does not match key from index file (%s)\",\n                                                                    ByteBufferUtil.bytesToHex(key.getKey()), ByteBufferUtil.bytesToHex(currentIndexKey))));\n                }\n\n                if (indexIterator != null && dataSizeFromIndex > dataFile.length())\n                    throw new IOError(new IOException(\"Impossible partition size (greater than file length): \" + dataSizeFromIndex));\n\n                if (indexIterator != null && dataStart != dataStartFromIndex)\n                    outputHandler.warn(\"Data file partition position %d differs from index file row position %d\", dataStart, dataStartFromIndex);\n\n                if (tryAppend(prevKey, key, writer))\n                    prevKey = key;\n            }\n            catch (Throwable th)\n            {\n                throwIfFatal(th);\n                outputHandler.warn(th, \"Error reading partition %s (stacktrace follows):\", keyName);\n\n                if (currentIndexKey != null\n                    && (key == null || !key.getKey().equals(currentIndexKey) || dataStart != dataStartFromIndex))\n                {\n\n                    // position where the row should start in a data file (right after the partition key)\n                    long rowStartFromIndex = dataStartFromIndex + TypeSizes.SHORT_SIZE + currentIndexKey.remaining();\n                    outputHandler.output(\"Retrying from partition index; data is %s bytes starting at %s\",\n                                         dataSizeFromIndex, rowStartFromIndex);\n                    key = sstable.decorateKey(currentIndexKey);\n                    try\n                    {\n                        if (!isIndex)\n                            partitionKeyType.validate(key.getKey());\n                        dataFile.seek(rowStartFromIndex);\n\n                        if (tryAppend(prevKey, key, writer))\n                            prevKey = key;","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/io/sstable/format/bti/BtiTableScrubber.java#L175-L211","documentation":"While scrubbing a BTI sstable, reading a partition from the data file threw an unexpected (non-fatal) exception. The scrubber logs this warning with the partition key and full stacktrace, then attempts recovery: if the index is still usable it seeks to the next indexed partition position and retries reading the partition once from the correct offset.","triggerScenarios":"`nodetool scrub` encounters an unreadable/undecodable partition in the data file — malformed partition header, corrupt row data, truncated file, or deserialization failure while reading the partition at dataStart.","commonSituations":"Disk corruption or bit-rot on Data.db; crash during compaction leaving half-written partitions; hardware faults; sstables copied while Cassandra was writing them.","solutions":["Review the logged stacktrace to identify the corruption type (IO vs deserialization).","Let scrub finish — bad partitions are counted and skipped or retried; then compact to rebuild.","Run `nodetool repair` (or full/repaired-datanote-based repair) so replicas restore missing data.","Check storage health and replace failing disks; restore from snapshot if corruption is severe."],"exampleFix":"// Operational recovery flow:\n// before: scrub warns 'Error reading partition <key>'\n// after:\n$ nodetool scrub <keyspace> <table>\n$ nodetool repair <keyspace> <table>","handlingStrategy":"try-catch","validationCode":"// Detect bad sstable ahead of scrub using offline validation\n$ sstableverify keyspace table   # or nodetool verify after node up","typeGuard":null,"tryCatchPattern":"// Wrap scrub-triggering maintenance in monitoring of badPartitions output\nOutputHandler handler = new OutputHandler.LogOutput();\n// after scrub: inspect ScrubResult/badPartitions and alert if > 0","preventionTips":["Run scrub on a maintenance schedule so corruption is caught and repaired early.","Ensure RF>=3 and run regular repair so bad local data can be re-fetched from replicas.","Monitor disk SMART/FREE space; most read errors trace to storage faults.","Keep Cassandra and JVM versions current for deserialization bug fixes."],"tags":["cassandra","scrub","sstable","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"}