{"record":{"id":"cfea23a13b3ab23d","repo":"apache/cassandra","slug":"unsafe-mixed-mutations-msg","errorCode":null,"errorMessage":"UNSAFE_MIXED_MUTATIONS_MSG","messagePattern":"UNSAFE_MIXED_MUTATIONS_MSG","errorType":"exception","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/service/StorageProxy.java","lineNumber":1368,"sourceCode":"                Tracing.trace(\"{}\", getStackTraceAsToString(t));\n                throw t;\n            }\n            break;\n        }\n    }\n\n    private static void checkMixedTimeSourceHandling()\n    {\n        AccordConfig.MixedTimeSourceHandling handling = DatabaseDescriptor.getAccord().mixedTimeSourceHandling;\n        switch (handling)\n        {\n            case log:\n            case reject:\n            {\n                ClientWarn.instance.warn(UNSAFE_MIXED_MUTATIONS_MSG);\n                logger.warn(UNSAFE_MIXED_MUTATIONS_MSG);\n                if (handling == AccordConfig.MixedTimeSourceHandling.reject)\n                    throw new InvalidRequestException(UNSAFE_MIXED_MUTATIONS_MSG);\n            }\n            break;\n            case ignore:\n                // ignore\n                break;\n        }\n    }\n\n    private static ConsistencyLevel consistencyLevelForBatchLog(ConsistencyLevel consistencyLevel, boolean requireQuorumForRemove)\n    {\n        // If we are requiring quorum nodes for removal, we upgrade consistency level to QUORUM unless we already\n        // require ALL, or EACH_QUORUM. This is so that *at least* QUORUM nodes see the update.\n        ConsistencyLevel batchConsistencyLevel = requireQuorumForRemove\n                                                 ? ConsistencyLevel.QUORUM\n                                                 : consistencyLevel;\n\n        switch (consistencyLevel)\n        {","sourceCodeStart":1350,"sourceCodeEnd":1386,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/service/StorageProxy.java#L1350-L1386","documentation":"When mutations that use the (Accord) transactional time source are mixed with regular mutations in the same request, and cassandraaccord's mixed-time-source handling is set to 'log' or 'reject', Cassandra warns the client (ClientWarn) and logs; if handling is 'reject' it also throws InvalidRequestException with UNSAFE_MIXED_MUTATIONS_MSG. Mixing time sources is unsafe and can break ordering guarantees.","triggerScenarios":"A batch or request containing both Accord/Txn-aware mutations and plain mutations while AccordConfig.MixedTimeSourceHandling is log or reject (reject throws, log only warns).","commonSituations":"Applications partially migrated to Accord transactional writes still combining legacy mutations and Txn mutations in one batch; misconfigured cassandra_accord mixed_time_source_handling during experimentations.","solutions":["Split the request: send Accord transactional mutations and regular mutations in separate batches/requests.","Set MixedTimeSourceHandling to 'ignore' only if you understand the ordering implications (not recommended).","Migrate the remaining regular mutations in the mixed batch to Accord transactions.","Check ClientWarn.getWarnings() on the driver to catch the 'log' mode warning before it escalates."],"exampleFix":"// before: mixed batch\nBatchStatement b = new BatchStatement();\nb.add(txnMutation); b.add(regularMutation);\nsession.execute(b);\n// after: separate requests\nsession.execute(txnMutation);\nsession.execute(regularMutation);","handlingStrategy":"validation","validationCode":"// split mixed batches before sending\nif (batch.containsTxnMutations && batch.containsRegularMutations) {\n    throw new IllegalArgumentException(\"mixed Accord/regular mutations are unsafe; split the batch\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    session.execute(batch);\n} catch (InvalidRequestException e) {\n    if (e.getMessage().contains(\"time source\")) {\n        // resend as two separate single-type batches\n    }\n}\n// also check warnings in 'log' mode\nfor (String w : session.getWarnings()) { /* look for mixed-mutations warning */ }","preventionTips":["Never mix Accord Txn mutations and regular mutations in one batch.","Review ClientWarn warnings during the Accord migration period.","Keep mixed_time_source_handling at 'reject' in production to fail fast."],"tags":["accord","mixed-mutations","unsafe-operation","invalid-request","transactions"],"backgroundTag":"invalid-argument-value","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}