apache/cassandra · error · IllegalArgumentException
CAS is supported only for type 'samerow'
Error message
CAS is supported only for type 'samerow'
What it means
CASQuery performs lightweight-transaction (Compare-And-Set) operations, which cassandra-stress only supports when arguments are selected with the 'samerow' ArgSelect (all values taken from the same row). If a CAS statement is configured with 'multirow' or another arg-select type, the constructor throws IllegalArgumentException.
Source
Thrown at tools/stress/src/org/apache/cassandra/stress/operations/userdefined/CASQuery.java:71
import org.apache.cassandra.stress.report.Timer;
import org.apache.cassandra.stress.settings.StressSettings;
import org.apache.cassandra.stress.util.JavaDriverClient;
public class CASQuery extends SchemaStatement
{
private final ImmutableList<Integer> keysIndex;
private final ImmutableMap<Integer, Integer> casConditionArgFreqMap;
private final String readQuery;
private PreparedStatement casReadConditionStatement;
public CASQuery(Timer timer, StressSettings settings, PartitionGenerator generator, SeedManager seedManager, PreparedStatement statement, ConsistencyLevel cl, ArgSelect argSelect, final String tableName)
{
super(timer, settings, new DataSpec(generator, seedManager, new DistributionFixed(1), settings.insert.rowPopulationRatio.get(), argSelect == SchemaStatement.ArgSelect.MULTIROW ? statement.getVariables().size() : 1), statement,
statement.getVariables().asList().stream().map(ColumnDefinitions.Definition::getName).collect(Collectors.toList()), cl);
if (argSelect != SchemaStatement.ArgSelect.SAMEROW)
throw new IllegalArgumentException("CAS is supported only for type 'samerow'");
ModificationStatement.Parsed modificationStatement;
try
{
modificationStatement = CQLFragmentParser.parseAnyUnhandled(CqlParser::updateStatement,
statement.getQueryString());
}
catch (RecognitionException e)
{
throw new IllegalArgumentException("could not parse update query:" + statement.getQueryString(), e);
}
final List<ColumnCondition.Raw> casConditionList = modificationStatement.getConditions();
List<Integer> casConditionIndex = new ArrayList<>();
boolean first = true;
StringBuilder casReadConditionQuery = new StringBuilder();
casReadConditionQuery.append("SELECT ");View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Set the operation's arg select type to 'samerow' in the stress profile, e.g. ops= CAS(type=samerow)
- Remove or rewrite the CAS operation if multirow semantics are needed, since LWT on multiple rows is not supported by stress
Example fix
// before ops: CAS(type=multirow) // after ops: CAS(type=samerow)
Defensive patterns
Strategy: validation
Validate before calling
if (argSelect != SchemaStatement.ArgSelect.SAMEROW)
throw new IllegalArgumentException("CAS requires argSelect=samerow"); Type guard
boolean isCasCompatible(SchemaStatement.ArgSelect sel) { return sel == SchemaStatement.ArgSelect.SAMEROW; } Try / catch
try { new CASQuery(timer, settings, gen, seeds, stmt, cl, argSelect, table); } catch (IllegalArgumentException e) { log.error("Set type=samerow for CAS in profile"); } Prevention
- Always use type=samerow for CAS operations in stress profiles
- Do not share arg-select settings between LWT and non-LWT ops
- Review profile YAML ops entries for CAS-specific requirements
When it happens
Trigger: Executing a user-defined stress profile CAS operation whose statement arguments are specified with type='multirow' (or any ArgSelect other than SAMEROW) in the profile's ops spec.
Common situations: Copy-editing a stress profile YAML and changing the arg select type for an UPDATE ... IF condition; using generic multirow argument selection for an LWT operation.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Username provided but no password
- Malformed target host: ${s}
- You need to state at least one --target host to replay the q
- sample range is invalid
- Invalid lookback distribution; max value is ${maxValue}, but
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/4b154ee79463acca.
Report an issue: GitHub.