apache/cassandra · error · InvalidRequestException
Invalid consistency for conditional update. Must be one of S
Error message
Invalid consistency for conditional update. Must be one of SERIAL or LOCAL_SERIAL
What it means
validateForCas ensures the serial consistency used for a lightweight transaction is one of SERIAL or LOCAL_SERIAL. Any other level passed as the serial consistency of a conditional update is rejected, because Paxos phases only support these two serial modes.
Source
Thrown at src/java/org/apache/cassandra/db/ConsistencyLevel.java:260
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;
default:
return false;
}
}
public void validateCounterForWrite(TableMetadata metadata) throws InvalidRequestException
{View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Set the serial consistency to ConsistencyLevel.SERIAL (default) or LOCAL_SERIAL.
- Keep regular (commit) consistency separate; only the serial slot is validated here.
- Audit code that copies one consistency enum into both consistency and serial-consistency parameters.
- In cqlsh use `SERIAL CONSISTENCY LOCAL_SERIAL;` with only those two values.
Example fix
// before stmt.setSerialConsistencyLevel(ConsistencyLevel.QUORUM); // after stmt.setSerialConsistencyLevel(ConsistencyLevel.LOCAL_SERIAL);
Defensive patterns
Strategy: validation
Validate before calling
// Guard serial CL before LWT execution
if (serialCl != ConsistencyLevel.SERIAL && serialCl != ConsistencyLevel.LOCAL_SERIAL)
throw new IllegalArgumentException("serial CL must be SERIAL or LOCAL_SERIAL"); Try / catch
catch (InvalidRequestException e) {
if (e.getMessage().contains("Invalid consistency for conditional update")) {
statement.setSerialConsistencyLevel(ConsistencyLevel.SERIAL);
retry();
} else throw e;
} Prevention
- Rely on the driver default (SERIAL) unless LOCAL_SERIAL is specifically needed.
- Do not propagate application-wide consistency enums into the serial-consistency parameter.
- In cqlsh use `SERIAL CONSISTENCY` only with SERIAL/LOCAL_SERIAL.
- Centralize LWT execution in one helper that enforces valid serial levels.
When it happens
Trigger: Calling execute with a conditional update whose serial consistency is set to something like QUORUM, ONE, or SERIAL-derived UNSAFE variants not accepted, e.g. stmt.setSerialConsistencyLevel(ConsistencyLevel.QUORUM).
Common situations: Application-wide consistency settings accidentally applied to the serial consistency slot; old drivers exposing serial consistency incorrectly; copy-pasted consistency configuration.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- this + " is not supported as conditional update commit consi
- ANY ConsistencyLevel is only supported for writes
- You must use conditional updates for serializable writes
- Consistency level ANY is not yet supported for counter table
- Counter operations are inherently non-serializable
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/198787ace89c4c96.
Report an issue: GitHub.