apache/cassandra · error · InvalidRequestException

Write operation require a read but consistency

Error message

Write operation require a read but consistency %s is not supported on reads

What it means

ModificationStatement.readRequiredLists() is used when a write (e.g. UPDATE with a list add/remove) must first read existing data. Before issuing those reads it validates the statement's consistency level via cl.validateForRead(); if the level is invalid for reads (e.g. SOME variants of serial write levels), this InvalidRequestException is thrown naming the offending level.

Solutions

  1. Check the consistency level being sent with the list-modifying statement and switch to a level valid for reads (e.g. ONE/QUORUM).
  2. Verify client-side CL configuration; set per-statement CL instead of a global invalid one.
  3. Ensure the driver/tool is not sending serial-only levels as regular consistency.

Example fix

// before
stmt.setConsistencyLevel(ConsistencyLevel.LOCAL_SERIAL); // invalid for the read phase
// after
stmt.setConsistencyLevel(ConsistencyLevel.QUORUM);
Defensive patterns

Strategy: validation

Validate before calling

if (stmtTouchingLists && !isReadValidConsistency(cl)) { cl = ConsistencyLevel.QUORUM; }

Try / catch

try { session.execute(stmt); } catch (InvalidRequestException e) { if (e.getMessage().contains("not supported on reads")) { /* fix CL and retry */ } else throw e; }

Prevention

When it happens

Trigger: Executing an UPDATE or DELETE that touches list columns (read-before-write) with a consistency level that fails validateForRead(), e.g. passing an inappropriate CL to the driver for such a statement.

Common situations: Application configures a custom consistency level globally, then runs list mutations; scripts generated for normal writes reused for list writes.

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


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

Appendix: source

Thrown at src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java:652

    private <F> Map<DecoratedKey, Partition> readRequiredLists(Collection<ByteBuffer> partitionKeys,
                                                           java.util.function.Function<F, ClusteringIndexFilter> filterBuilder,
                                                           F filterArg,
                                                           DataLimits limits,
                                                           boolean local,
                                                           ConsistencyLevel cl,
                                                           long nowInSeconds,
                                                           Dispatcher.RequestTime requestTime)
    {
        if (!requiresRead())
            return null;

        try
        {
            cl.validateForRead();
        }
        catch (InvalidRequestException e)
        {
            throw new InvalidRequestException(String.format("Write operation require a read but consistency %s is not supported on reads", cl));
        }

        List<SinglePartitionReadCommand> commands = new ArrayList<>(partitionKeys.size());
        for (ByteBuffer key : partitionKeys)
            commands.add(SinglePartitionReadCommand.create(metadata(),
                                                           nowInSeconds,
                                                           ColumnFilter.selection(this.requiresRead),
                                                           RowFilter.none(),
                                                           limits,
                                                           metadata().partitioner.decorateKey(key),
                                                           filterBuilder.apply(filterArg)));

        SinglePartitionReadCommand.Group group = SinglePartitionReadCommand.Group.create(commands, DataLimits.NONE);

        if (local)
        {
            try (ReadExecutionController executionController = group.executionController();
                 PartitionIterator iter = group.executeInternal(executionController))

View on GitHub (pinned to 88fd0f6a0e)