{"record":{"id":"4b154ee79463acca","repo":"apache/cassandra","slug":"cas-is-supported-only-for-type-samerow","errorCode":null,"errorMessage":"CAS is supported only for type 'samerow'","messagePattern":"CAS is supported only for type 'samerow'","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"tools/stress/src/org/apache/cassandra/stress/operations/userdefined/CASQuery.java","lineNumber":71,"sourceCode":"import org.apache.cassandra.stress.report.Timer;\nimport org.apache.cassandra.stress.settings.StressSettings;\nimport org.apache.cassandra.stress.util.JavaDriverClient;\n\npublic class CASQuery extends SchemaStatement\n{\n    private final ImmutableList<Integer> keysIndex;\n    private final ImmutableMap<Integer, Integer> casConditionArgFreqMap;\n    private final String readQuery;\n\n    private PreparedStatement casReadConditionStatement;\n\n    public CASQuery(Timer timer, StressSettings settings, PartitionGenerator generator, SeedManager seedManager, PreparedStatement statement, ConsistencyLevel cl, ArgSelect argSelect, final String tableName)\n    {\n        super(timer, settings, new DataSpec(generator, seedManager, new DistributionFixed(1), settings.insert.rowPopulationRatio.get(), argSelect == SchemaStatement.ArgSelect.MULTIROW ? statement.getVariables().size() : 1), statement,\n              statement.getVariables().asList().stream().map(ColumnDefinitions.Definition::getName).collect(Collectors.toList()), cl);\n\n        if (argSelect != SchemaStatement.ArgSelect.SAMEROW)\n            throw new IllegalArgumentException(\"CAS is supported only for type 'samerow'\");\n\n        ModificationStatement.Parsed modificationStatement;\n        try\n        {\n            modificationStatement = CQLFragmentParser.parseAnyUnhandled(CqlParser::updateStatement,\n                    statement.getQueryString());\n        }\n        catch (RecognitionException e)\n        {\n            throw new IllegalArgumentException(\"could not parse update query:\" + statement.getQueryString(), e);\n        }\n\n        final List<ColumnCondition.Raw> casConditionList = modificationStatement.getConditions();\n        List<Integer> casConditionIndex = new ArrayList<>();\n\n        boolean first = true;\n        StringBuilder casReadConditionQuery = new StringBuilder();\n        casReadConditionQuery.append(\"SELECT \");","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/tools/stress/src/org/apache/cassandra/stress/operations/userdefined/CASQuery.java#L53-L89","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nops: CAS(type=multirow)\n// after\nops: CAS(type=samerow)","handlingStrategy":"validation","validationCode":"if (argSelect != SchemaStatement.ArgSelect.SAMEROW)\n    throw new IllegalArgumentException(\"CAS requires argSelect=samerow\");","typeGuard":"boolean isCasCompatible(SchemaStatement.ArgSelect sel) { return sel == SchemaStatement.ArgSelect.SAMEROW; }","tryCatchPattern":"try { new CASQuery(timer, settings, gen, seeds, stmt, cl, argSelect, table); } catch (IllegalArgumentException e) { log.error(\"Set type=samerow for CAS in profile\"); }","preventionTips":["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"],"tags":["cli","lwt","configuration"],"backgroundTag":"unsupported-operation","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"}