apache/cassandra · error · InvalidRequestException
Consistency level ANY is not yet supported for counter table
Error message
Consistency level ANY is not yet supported for counter table " + metadata.name
What it means
Counter writes cannot use ANY consistency because counter increments require reading and writing on replicas (a read-modify-write), so recording only a hint as ANY would lose the increment. validateCounterForWrite rejects ANY for writes to counter tables.
Source
Thrown at src/java/org/apache/cassandra/db/ConsistencyLevel.java:280
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
{
if (this == ConsistencyLevel.ANY)
throw new InvalidRequestException("Consistency level ANY is not yet supported for counter table " + metadata.name);
if (isSerialConsistency())
throw new InvalidRequestException("Counter operations are inherently non-serializable");
}
/**
* With a replication factor greater than one, reads that contact more than one replica will require
* reconciliation of the individual replica results at the coordinator.
*
* @return true if reads at this consistency level require merging at the coordinator
*/
public boolean needsReconciliation()
{
return this != ConsistencyLevel.ONE && this != ConsistencyLevel.LOCAL_ONE && this != ConsistencyLevel.NODE_LOCAL;
}
private void requireNetworkTopologyStrategy(AbstractReplicationStrategy replicationStrategy) throws InvalidRequestException
{View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Use consistency ONE or higher for counter writes (LOCAL_ONE works for DC-local counters).
- Ensure default consistency in the driver/session is at least ONE when writing counters.
- Change cqlsh with `CONSISTENCY ONE;` before updating counter tables.
- Separate counter-write code paths with their own consistency constants.
Example fix
// before
session.execute(SimpleStatement.builder("UPDATE counts SET c = c + 1 WHERE k = 'x'")
.setConsistencyLevel(ConsistencyLevel.ANY).build());
// after
session.execute(SimpleStatement.builder("UPDATE counts SET c = c + 1 WHERE k = 'x'")
.setConsistencyLevel(ConsistencyLevel.ONE).build()); Defensive patterns
Strategy: validation
Validate before calling
// Reject ANY for counter writes before sending
if (cl == ConsistencyLevel.ANY && isCounterTable(table))
throw new IllegalArgumentException("ANY is invalid for counter writes"); Try / catch
catch (InvalidRequestException e) {
if (e.getMessage().contains("ANY is not yet supported for counter table")) {
statement.setConsistencyLevel(ConsistencyLevel.ONE);
retry();
} else throw e;
} Prevention
- Never default write consistency to ANY in shared clients; use ONE minimum.
- Tag counter-write code paths and enforce their own consistency policy in review.
- Reset cqlsh consistency after ad-hoc ANY experiments.
- Add integration tests covering counter writes at production consistency settings.
When it happens
Trigger: Executing UPDATE <counter_table> SET c = c + 1 (or a counter INSERT) with consistency level ANY.
Common situations: Generic write helpers defaulting to ANY for 'fire and forget' writes; cqlsh session left at ANY; scripts shared between regular and counter tables.
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
- ANY ConsistencyLevel is only supported for writes
- this + " is not supported as conditional update commit consi
- Invalid consistency for conditional update. Must be one of S
- Counter operations are inherently non-serializable
- REVOKE operation is not supported by AllowAllAuthorizer
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/f19e1ac71b6e6111.
Report an issue: GitHub.