{"record":{"id":"0d7d703f07c0b96f","repo":"apache/cassandra","slug":"impossible-partition-size-greater-than-file-lengt","errorCode":null,"errorMessage":"Impossible partition size (greater than file length): ","messagePattern":"Impossible partition size \\(greater than file length\\): ","errorType":"exception","errorClass":"IOError","httpStatus":null,"severity":"critical","filePath":"src/java/org/apache/cassandra/io/sstable/format/big/BigTableScrubber.java","lineNumber":164,"sourceCode":"\n            String keyName = key == null ? \"(unreadable key)\" : keyString(key);\n            outputHandler.debug(\"partition %s is %s\", keyName, FBUtilities.prettyPrintMemory(dataSizeFromIndex));\n            assert currentIndexKey != null || !indexAvailable();\n\n            try\n            {\n                if (key == null)\n                    throw new IOError(new IOException(\"Unable to read partition key from data file\"));\n\n                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                                                                    \"_too big_\", ByteBufferUtil.bytesToHex(currentIndexKey))));\n                }\n\n                if (indexFile != null && dataSizeFromIndex > dataFile.length())\n                    throw new IOError(new IOException(\"Impossible partition size (greater than file length): \" + dataSizeFromIndex));\n\n                if (indexFile != 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                    outputHandler.output(\"Retrying from partition index; data is %s bytes starting at %s\",\n                                         dataSizeFromIndex, dataStartFromIndex);","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/io/sstable/format/big/BigTableScrubber.java#L146-L182","documentation":"Thrown by the BigTable scrubber when the partition size recorded in the SSTable index file claims the partition extends beyond the end of the data file. This means the index and data components are inconsistent — the data file is truncated or the index is corrupt — and scrubbing cannot safely continue reading that partition.","triggerScenarios":"Running `nodetool scrub` on an SSTable whose data file is shorter than `dataSizeFromIndex` for some partition, typically after a crash mid-compaction/flush, disk-full during flush, or manual/corrupted file truncation.","commonSituations":"Power loss or OOM kill during flush leaving a truncated Data.db; disk full during writes; copying SSTables without all components or while being written; filesystem corruption.","solutions":["Run `nodetool scrub` (this tool itself) or restore the SSTable from a backup/snapshot","Restore from backup or re-stream/repair the affected ranges (`nodetool repair` after dropping/rebuilding data, or `nodetool rebuild` from other replicas)","Check disk health and free space (dmesg, SMART) to rule out hardware truncation","Run `nodetool verify` on other SSTables to find additional corruption"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Before relying on an SSTable, verify index/data consistency\nlong sizeFromIndex = getIndexDataSize(descriptor); // from Index.db entry\nif (sizeFromIndex > dataFile.length()) {\n    // schedule scrub/repair instead of reading\n    System.out.println(\"Truncated Data.db detected for \" + descriptor + \"; run nodetool scrub\");\n}","typeGuard":null,"tryCatchPattern":"try { scrubber.scrub(); }\ncatch (IOError e) { logger.error(\"SSTable corrupt, scheduling repair/replacement\", e); replacementSource.stream(); }","preventionTips":["Never truncate or hand-edit live SSTable files","Ensure adequate disk space before flushes/compactions","Take snapshots with nodetool snapshot rather than raw copies of live files","Monitor filesystem/disk health (SMART, fsck)"],"tags":["sstable","corruption","scrub","data-file"],"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"}