apache/cassandra · error · InvalidRequestException

this + " is not supported as conditional update commit consi

Error message

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\""

What it means

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.

Source

Thrown at src/java/org/apache/cassandra/db/ConsistencyLevel.java:253

            case LOCAL_SERIAL:
            case UNSAFE_DELAY_LOCAL_SERIAL:
                throw new InvalidRequestException("You must use conditional updates for serializable writes");
        }
    }

    // This is the same than validateForWrite really, but we include a slightly different error message for SERIAL/LOCAL_SERIAL
    public void validateForCasCommit(AbstractReplicationStrategy replicationStrategy) throws InvalidRequestException
    {
        switch (this)
        {
            case EACH_QUORUM:
                requireNetworkTopologyStrategy(replicationStrategy);
                break;
            case SERIAL:
            case UNSAFE_DELAY_SERIAL:
            case LOCAL_SERIAL:
            case UNSAFE_DELAY_LOCAL_SERIAL:
                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\"");
        }
    }

    public void validateForCas() throws InvalidRequestException
    {
        if (!isSerialConsistency())
            throw new InvalidRequestException("Invalid consistency for conditional update. Must be one of SERIAL or LOCAL_SERIAL");
    }

    public boolean isSerialConsistency()
    {
        switch (this)
        {
            case SERIAL:
            case UNSAFE_DELAY_SERIAL:
            case LOCAL_SERIAL:
            case UNSAFE_DELAY_LOCAL_SERIAL:
                return true;

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Set the LWT commit consistency to ANY (or SERIAL for the serial phase only, via serial consistency).
  2. Use SimpleStrategy-free keyspace config: create the keyspace with NetworkTopologyStrategy if using LOCAL_SERIAL/topology-aware levels.
  3. In drivers, explicitly pass both consistency levels for LWTs: serial consistency for the Paxos phase, QUORUM/ANY for the commit.
  4. Review documentation for the two-consistency model of lightweight transactions.

Example fix

// before
stmt.setConsistencyLevel(ConsistencyLevel.LOCAL_SERIAL); // used as commit CL
// after
stmt.setConsistencyLevel(ConsistencyLevel.ANY);
stmt.setSerialConsistencyLevel(ConsistencyLevel.LOCAL_SERIAL);
Defensive patterns

Strategy: validation

Validate before calling

// Ensure commit CL is not serial and keyspace uses NTS
if (cl.isSerialConsistency())
    throw new IllegalArgumentException("use serial CL as serial consistency, not commit CL");

Try / catch

catch (InvalidRequestException e) {
    if (e.getMessage().contains("conditional update commit consistency")) {
        statement.setConsistencyLevel(ConsistencyLevel.ANY); // or QUORUM
        retry();
    } else throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: Drivers letting users set one consistency for the whole LWT; misconfigured keyspace replication (SimpleStrategy) while using LOCAL_SERIAL; tutorials conflating serial and commit consistencies.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/af86bd9f2567cc50. Report an issue: GitHub.