{"record":{"id":"af86bd9f2567cc50","repo":"apache/cassandra","slug":"this-is-not-supported-as-conditional-update-co","errorCode":null,"errorMessage":"this + \" is not supported as conditional update commit consistency. Use ANY if you mean \\\"make sure it is accepted but I don't care how many replicas commit it for non-SERIAL reads\\\"\"","messagePattern":"this \\+ \" is not supported as conditional update commit consistency\\. Use ANY if you mean \\\\\"make sure it is accepted but I don't care how many replicas commit it for non-SERIAL reads\\\\\"\"","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/db/ConsistencyLevel.java","lineNumber":253,"sourceCode":"            case LOCAL_SERIAL:\n            case UNSAFE_DELAY_LOCAL_SERIAL:\n                throw new InvalidRequestException(\"You must use conditional updates for serializable writes\");\n        }\n    }\n\n    // This is the same than validateForWrite really, but we include a slightly different error message for SERIAL/LOCAL_SERIAL\n    public void validateForCasCommit(AbstractReplicationStrategy replicationStrategy) throws InvalidRequestException\n    {\n        switch (this)\n        {\n            case EACH_QUORUM:\n                requireNetworkTopologyStrategy(replicationStrategy);\n                break;\n            case SERIAL:\n            case UNSAFE_DELAY_SERIAL:\n            case LOCAL_SERIAL:\n            case UNSAFE_DELAY_LOCAL_SERIAL:\n                throw new InvalidRequestException(this + \" is not supported as conditional update commit consistency. Use ANY if you mean \\\"make sure it is accepted but I don't care how many replicas commit it for non-SERIAL reads\\\"\");\n        }\n    }\n\n    public void validateForCas() throws InvalidRequestException\n    {\n        if (!isSerialConsistency())\n            throw new InvalidRequestException(\"Invalid consistency for conditional update. Must be one of SERIAL or LOCAL_SERIAL\");\n    }\n\n    public boolean isSerialConsistency()\n    {\n        switch (this)\n        {\n            case SERIAL:\n            case UNSAFE_DELAY_SERIAL:\n            case LOCAL_SERIAL:\n            case UNSAFE_DELAY_LOCAL_SERIAL:\n                return true;","sourceCodeStart":235,"sourceCodeEnd":271,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/ConsistencyLevel.java#L235-L271","documentation":"validateForCasCommit checks the consistency level at which the commit phase of a lightweight transaction is performed. Serial-family levels are illegal there (the serial phase already handled them), and only levels backed by NetworkTopologyStrategy make sense for the topology-aware checks. The error message hints that ANY is the intended level for callers that do not care how many replicas commit.","triggerScenarios":"Executing a conditional update (LWT) whose commit consistency is SERIAL/LOCAL_SERIAL/UNSAFE_DELAY_*, or a serial commit consistency with a keyspace not using NetworkTopologyStrategy for topology-requiring levels.","commonSituations":"Drivers letting users set one consistency for the whole LWT; misconfigured keyspace replication (SimpleStrategy) while using LOCAL_SERIAL; tutorials conflating serial and commit consistencies.","solutions":["Set the LWT commit consistency to ANY (or SERIAL for the serial phase only, via serial consistency).","Use SimpleStrategy-free keyspace config: create the keyspace with NetworkTopologyStrategy if using LOCAL_SERIAL/topology-aware levels.","In drivers, explicitly pass both consistency levels for LWTs: serial consistency for the Paxos phase, QUORUM/ANY for the commit.","Review documentation for the two-consistency model of lightweight transactions."],"exampleFix":"// before\nstmt.setConsistencyLevel(ConsistencyLevel.LOCAL_SERIAL); // used as commit CL\n// after\nstmt.setConsistencyLevel(ConsistencyLevel.ANY);\nstmt.setSerialConsistencyLevel(ConsistencyLevel.LOCAL_SERIAL);","handlingStrategy":"validation","validationCode":"// Ensure commit CL is not serial and keyspace uses NTS\nif (cl.isSerialConsistency())\n    throw new IllegalArgumentException(\"use serial CL as serial consistency, not commit CL\");","typeGuard":null,"tryCatchPattern":"catch (InvalidRequestException e) {\n    if (e.getMessage().contains(\"conditional update commit consistency\")) {\n        statement.setConsistencyLevel(ConsistencyLevel.ANY); // or QUORUM\n        retry();\n    } else throw e;\n}","preventionTips":["For LWTs always pass commit CL (e.g. QUORUM/LOCAL_QUORUM/ANY) separately from serial CL.","Use NetworkTopologyStrategy for any keyspace touched by topology-aware CAS.","Avoid frameworks that copy one CL into both slots of an LWT.","Review the LWT documentation before configuring serial/commit levels."],"tags":["cassandra","consistency-level","lwt","validation"],"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-14T16:17:12.679Z"}