{"record":{"id":"fdbcf377e3eeb08d","repo":"apache/cassandra","slug":"out-of-order-rows-found-in-partition-s","errorCode":null,"errorMessage":"Out of order rows found in partition: %s","messagePattern":"Out of order rows found in partition: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/java/org/apache/cassandra/io/sstable/format/SortedTableScrubber.java","lineNumber":309,"sourceCode":"        // that one row is out of order, it will stop returning them. The remaining rows will be sorted and added\n        // to the outOfOrder set that will be later written to a new SSTable.\n        try (OrderCheckerIterator sstableIterator = new OrderCheckerIterator(getIterator(key), cfs.metadata().comparator);\n             UnfilteredRowIterator iterator = withValidation(sstableIterator, dataFile.getPath()))\n        {\n            if (prevKey != null && prevKey.compareTo(key) > 0)\n            {\n                saveOutOfOrderPartition(prevKey, key, iterator);\n                return false;\n            }\n\n            if (writer.tryAppend(iterator) == null)\n                emptyPartitions++;\n            else\n                goodPartitions++;\n\n            if (sstableIterator.hasRowsOutOfOrder())\n            {\n                outputHandler.warn(\"Out of order rows found in partition: %s\", keyString(key));\n                outOfOrder.add(sstableIterator.getRowsOutOfOrder());\n            }\n        }\n\n        return true;\n    }\n\n    /**\n     * Only wrap with {@link FixNegativeLocalDeletionTimeIterator} if {@link IScrubber.Options#reinsertOverflowedTTLRows} option\n     * is specified\n     */\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,","sourceCodeStart":291,"sourceCodeEnd":327,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/io/sstable/format/SortedTableScrubber.java#L291-L327","documentation":"During scrubbing, tryAppend inspects the sstable iterator's hasRowsOutOfOrder() flag; when rows within a partition were stored out of clustering order, it warns with the partition key and collects those rows to be written to a separate in-order sstable. It indicates on-disk row ordering violates the expected clustering order.","triggerScenarios":"Scrubbing an sstable whose partition contains rows whose clustering values are not in sorted order — detected per-partition via sstableIterator.hasRowsOutOfOrder() in tryAppend.","commonSituations":"Legacy sstables written by versions with sorting bugs; partial corruption that shifted row boundaries; sstables migrated from non-Cassandra tooling.","solutions":["No immediate action: scrub relocates these rows into a properly ordered sstable (see the follow-up warning)","Run nodetool repair to ensure replica consistency","After scrub, consider compacting the repaired sstables so all data is in canonical order","Upgrade Cassandra if this stems from a fixed historical sorting bug"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Upgrade from legacy versions whose writers could emit unsorted rows","Scrub after major version upgrades to normalize on-disk layout","Monitor scrub output for warnings rather than ignoring them","Keep repairs scheduled to detect replica divergence"],"tags":["scrub","out-of-order","clustering","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"}