{"record":{"id":"914ce83b7bdb1d46","repo":"apache/cassandra","slug":"duplicate-row-detected-in-s-s-s-s","errorCode":null,"errorMessage":"Duplicate row detected in %s.%s: %s %s","messagePattern":"Duplicate row detected in (.+?)\\.(.+?): (.+?) (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/java/org/apache/cassandra/io/sstable/format/SortedTableScrubber.java","lineNumber":523,"sourceCode":"            if (next.isRow())\n            {\n                boolean logged = false;\n                while (wrapped.hasNext())\n                {\n                    Unfiltered peek = wrapped.next();\n                    if (!peek.isRow() || !next.clustering().equals(peek.clustering()))\n                    {\n                        nextToOffer = peek; // Offer peek in next call\n                        return computeFinalRow((Row) next);\n                    }\n\n                    // Duplicate row, merge it.\n                    next = Rows.merge((Row) next, (Row) peek);\n\n                    if (!logged)\n                    {\n                        String partitionKey = metadata().partitionKeyType.getString(partitionKey().getKey());\n                        output.warn(\"Duplicate row detected in %s.%s: %s %s\", metadata().keyspace, metadata().name, partitionKey, next.clustering().toString(metadata()));\n                        logged = true;\n                    }\n                }\n            }\n\n            nextToOffer = null;\n            return computeFinalRow((Row) next);\n         }\n\n         private Row computeFinalRow(Row next)\n         {\n             // If the row has overflowed let rows skip them unless we need to keep them for the overflow policy\n             if (hasOverflowedLocalExpirationTimeRow(next) && !reinsertOverflowedTTLRows)\n                 return null;\n             else if (reinsertOverflowedTTLRows)\n                 return rebuildTimestamptsForOverflowedRows(next);\n             else\n                 return next;","sourceCodeStart":505,"sourceCodeEnd":541,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/io/sstable/format/SortedTableScrubber.java#L505-L541","documentation":"The scrubber's merging row iterator (next) detects two rows with identical clustering in the same partition while iterating static/data rows. It merges them (Rows.merge) and logs a one-time warning per partition identifying keyspace, table, partition key, and clustering. This indicates the sstable contains duplicate row entries, which the write path should have prevented.","triggerScenarios":"Scrubbing an sstable where the same clustering key appears twice within one partition during UnfilteredRowIterator iteration; the iterator merges the rows and warns once (logged flag).","commonSituations":"Historical bugs that appended duplicate rows on compaction/repair; corruption duplicating a row block; sstables produced by faulty tooling or repairs from a defective version.","solutions":["No data loss: rows are merged automatically; confirm the merge produced the intended reconciliation of timestamps/tombstones","Run nodetool repair to reconcile this node's view with replicas","Run scrub/compact to rewrite the sstable without duplicates","If reproducible on new data, check Cassandra version for known duplicate-row bugs and upgrade"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Upgrade Cassandra if running a version with known duplicate-row compaction bugs","Scrub known-affected sstables to merge duplicates and rewrite cleanly","Run regular repair so merged/corrupted rows are reconciled with replicas","Review scrub logs after upgrades and long-running cluster operations"],"tags":["scrub","duplicate-row","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"}