{"record":{"id":"3231dbece9557ce1","repo":"apache/cassandra","slug":"impossible-partition-size-greater-than-file-lengt-3231db","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/bti/BtiTableScrubber.java","lineNumber":182,"sourceCode":"                }\n            }\n\n            String keyName = key == null ? \"(unreadable key)\" : keyString(key);\n            outputHandler.debug(\"partition %s is %s\", keyName, FBUtilities.prettyPrintMemory(dataSizeFromIndex));\n\n            try\n            {\n                if (key == null)\n                    throw new IOError(new IOException(\"Unable to read partition key from data file\", keyReadError));\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                }\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();","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/io/sstable/format/bti/BtiTableScrubber.java#L164-L200","documentation":"Thrown during BTI scrub when the partition size recorded in the index (dataSizeFromIndex) is larger than the whole data file length — an impossible value. It guards the scrubber against reading past end-of-file and indicates a corrupt index entry or truncated data file.","triggerScenarios":"Scrubbing a sstable whose Index.db entry claims a partition size exceeding the actual Data.db length, typically after data-file truncation or index corruption.","commonSituations":"Truncated Data.db from a crash or incomplete copy, corrupt index entries, partial restore of sstable backups.","solutions":["Verify file sizes on disk (ls -l) against the snapshot/original; restore missing/truncated data files from backup","Drop the corrupt sstable and run `nodetool repair` to re-stream from replicas","Scrub with --no-validate to salvage readable partitions","Check storage subsystem for truncating faults"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// sanity check before scrub\nif (dataSizeFromIndex > dataFile.length()) throw new IOException(\"truncated data file: index claims \" + dataSizeFromIndex + \" but file is \" + dataFile.length());","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify sstable file sizes against snapshots after restores","Avoid killing the process during flush/compaction","Monitor for truncated files on shared/network storage","Run scrub with -n to keep unsalvageable files"],"tags":["io","corruption","sstable","truncation"],"backgroundTag":"file-size-limit-exceeded","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"}