{"record":{"id":"4d65ed6a7bfa84ee","repo":"apache/cassandra","slug":"data-file-partition-position-d-differs-from-index","errorCode":null,"errorMessage":"Data file partition position %d differs from index file row position %d","messagePattern":"Data file partition position (.+?) differs from index file row position (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/java/org/apache/cassandra/io/sstable/format/big/BigTableScrubber.java","lineNumber":167,"sourceCode":"            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);\n                    key = sstable.decorateKey(currentIndexKey);\n                    try\n                    {","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/io/sstable/format/big/BigTableScrubber.java#L149-L185","documentation":"While scrubbing, the partition's actual start position in the -Data.db file is compared with the position recorded in the -Index.db. A mismatch means the index is stale or the data file was modified; the scrubber logs a warning and continues using the data-file-derived position.","triggerScenarios":"scrubInternal reads a partition whose dataStart differs from dataStartFromIndex — typically when the data file was truncated, partially rewritten, or the index belongs to a different/older version of the sstable.","commonSituations":"Interrupted writes leaving data/index inconsistency, sstable files restored from mismatched backups, corrupted or truncated -Data.db after a disk failure.","solutions":["Let the scrub complete; the warning is informational and the scrubber uses the data-file position","Run `nodetool repair` after scrubbing to re-sync with healthy replicas","Replace the sstable from a healthy replica via repair/rebuild","Check disk/filesystem health (SMART, fsck) before re-adding the node"],"exampleFix":"// before: scrub warns on position mismatch\n// after: verify component consistency before scrub\nFile data = sstable.descriptor.fileFor(Components.DATA);\nFile index = sstable.descriptor.fileFor(Components.PRIMARY_INDEX);\nif (data.lastModified() != index.lastModified())\n    logger.warn(\"{} data/index timestamps differ; restore consistent copies before scrub\", sstable);","handlingStrategy":"validation","validationCode":"long dataLen = sstable.descriptor.fileFor(Components.DATA).length();\nlong idxLen = sstable.descriptor.fileFor(Components.PRIMARY_INDEX).length();\nif (idxLen == 0 || dataLen == 0)\n    logger.warn(\"Empty data or index component; scrub will report position mismatches\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always restore Data+Index components from the same snapshot","Run `nodetool verify` to validate index/data consistency before scrub","Avoid editing or truncating sstable files manually","Monitor disk health to prevent partial writes"],"tags":["cassandra","sstable","scrub","index-mismatch"],"backgroundTag":"checksum-mismatch","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}