{"record":{"id":"da6d5097d1d91eaf","repo":"apache/cassandra","slug":"out-of-order-partition-detected-s-found-after-s","errorCode":null,"errorMessage":"Out of order partition detected (%s found after %s)","messagePattern":"Out of order partition detected \\((.+?) found after (.+?)\\)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/java/org/apache/cassandra/io/sstable/format/SortedTableScrubber.java","lineNumber":338,"sourceCode":"     */\n    private UnfilteredRowIterator getIterator(DecoratedKey key)\n    {\n        RowMergingSSTableIterator rowMergingIterator = new RowMergingSSTableIterator(SSTableIdentityIterator.create(sstable,\n                                                                                                                    dataFile,\n                                                                                                                    key),\n                                                                                     outputHandler,\n                                                                                     sstable.descriptor.version,\n                                                                                     options.reinsertOverflowedTTLRows);\n        if (options.reinsertOverflowedTTLRows)\n            return new FixNegativeLocalDeletionTimeIterator(rowMergingIterator, outputHandler, negativeLocalDeletionInfoMetrics);\n        else\n            return rowMergingIterator;\n    }\n\n    private void saveOutOfOrderPartition(DecoratedKey prevKey, DecoratedKey key, UnfilteredRowIterator iterator)\n    {\n        // TODO bitch if the row is too large?  if it is there's not much we can do ...\n        outputHandler.warn(\"Out of order partition detected (%s found after %s)\", keyString(key), keyString(prevKey));\n        outOfOrder.add(ImmutableBTreePartition.create(iterator));\n    }\n\n    protected static void throwIfFatal(Throwable th)\n    {\n        if (th instanceof Error && !(th instanceof AssertionError || th instanceof IOError))\n            throw (Error) th;\n    }\n\n    protected void throwIfCannotContinue(DecoratedKey key, Throwable th)\n    {\n        if (isCommutative && !options.skipCorrupted)\n        {\n            outputHandler.warn(\"An error occurred while scrubbing the partition with key '%s'.  Skipping corrupt \" +\n                               \"data in counter tables will result in undercounts for the affected \" +\n                               \"counters (see CASSANDRA-2759 for more details), so by default the scrub will \" +\n                               \"stop at this point.  If you would like to skip the row anyway and continue \" +\n                               \"scrubbing, re-run the scrub with the --skip-corrupted option.\",","sourceCodeStart":320,"sourceCodeEnd":356,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/io/sstable/format/SortedTableScrubber.java#L320-L356","documentation":"saveOutOfOrderPartition is called by tryAppend when scrubbing encounters a partition whose decorated key sorts before the previously appended key — a violation of the sstable's key-order invariant. The partition is warned about and buffered into outOfOrder to be written to a separate sstable rather than merged into the main output.","triggerScenarios":"Scrub iterates partitions in file order; a key compares less than or equal to the previous key (prevKey), violating strictly increasing decorated-key order, so saveOutOfOrderPartition fires.","commonSituations":"Corrupted index/data pointing mid-file; sstables written by buggy older versions; botched manual copying/restoring of sstable components; disk corruption altering a key.","solutions":["Accept the automatic mitigation: the partition is preserved in the out-of-order sstable created by the scrubber","Run nodetool repair to re-sync with healthy replicas","Audit how the sstable was produced (restore tooling, version) to find the source of the ordering violation","Check storage integrity if multiple sstables show the same symptom"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Restore sstables only from snapshots taken on the same node/token ownership","Verify ring stability (no pending ranges) before heavy compaction/scrub operations","Check disk integrity when ordering violations appear repeatedly","Run nodetool verify after restores to catch misplaced data"],"tags":["scrub","out-of-order","sstable","data-integrity"],"backgroundTag":"internal-invariant-violation","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"}