Skip to content

Cassandra: use one consistency policy (LOCAL_QUORUM / LOCAL_SERIAL) for every statement #770

Closed

Description

@jcshepherd

Why

The Cassandra backend has no consistency policy. Statements default to the
driver's ONE, and individual call sites have been upgraded to
LOCAL_QUORUM one at a time, as bugs turned up. With RF 3, a ONE read can
miss an acknowledged write, and the code often acts on "not found" as a fact
(see the comments at cassandra_util.rs:116, put_get_item.rs:606,
data/index.rs:50, and PR #508). Upgrading reads alone does not help: a
quorum read overlaps only writes that were also made at quorum. A single
rule — LOCAL_QUORUM for every statement, LOCAL_SERIAL for every
conditional one — is correct for DynamoDB's strong reads, conditional writes
and transactions. It costs nothing on single-node (RF 1) deployments and
removes the per-call-site decision that keeps going wrong. Separately,
init creates every keyspace, including the catalog, with RF 1, so a
multi-node cluster set up by the docs keeps all control-plane state on one
node.

Changes

  1. In crates/storage-cassandra/src/cassandra_util.rs, make every helper set
    its level explicitly:
    • query_rows, query_optional, execute: LOCAL_QUORUM
      (query_rows_quorum / execute_quorum become redundant);
    • query_lwt: unchanged (LOCAL_SERIAL, commit at LOCAL_QUORUM);
    • add a helper that returns a BatchQueryBuilder at LOCAL_QUORUM.
  2. Move every direct session.query_with_values, query_with_params,
    .query( and BatchQueryBuilder::new() call in non-test source onto
    those helpers. Every IF ... statement goes through query_lwt.
  3. Add a test that fails if non-test source in the crate makes those calls
    outside cassandra_util.rs.
  4. Do not add a consistency setting. Serve ConsistentRead=false at
    LOCAL_QUORUM too; a strong read is a valid eventually-consistent read.
  5. init: create keyspaces with the configured replication_factor and
    datacenter, not 1. serve: log a warning when a keyspace's RF differs
    from the config. Docs: raising RF needs nodetool repair before serving.
  6. CI: add one job that runs the Cassandra integration tests on a 3-node,
    RF 3 cluster. On RF 1, every consistency level behaves the same, so
    today's CI cannot catch these bugs.

Items 1-3 are one PR. Items 5 and 6 can be separate.

Activity

  1. self-assigned this
    on Nov 3, 2026
  2. added
    backend:cassandra
    on Nov 3, 2026
  3. jcshepherd commented on Nov 6, 2026

    @jcshepherd
    CollaboratorAuthor

    WIP

  4. added theissue type on Nov 12, 2026
  5. jcshepherd commented on Nov 13, 2026

    @jcshepherd
    CollaboratorAuthor

    RFC and ADR decision for #909 (#770 item 5)

    docs/rfcs/README.md asks for an RFC for a change to "Public CLI flags or the configuration file format". #909 adds two init flags. Under the README's "If you are unsure" paragraph ("A maintainer will tell you whether an RFC, an ADR, or neither is needed"), I decide, as a maintainer, that #909 needs neither:

    • --replication-factor N and --datacenter NAME set replication_factor and datacenter in [storage.cassandra]. Both keys exist on main. The configuration file format does not change.
    • Without the flags and with no config file, init behaves as on main. With init --overwrite, init now uses the file's datacenter for CREATE KEYSPACE, and writes the file's replication_factor and datacenter instead of 1 and datacenter1. init --overwrite now returns an error for replication_factor = 0 and for a datacenter name outside [A-Za-z0-9_.-].
    • init refuses a keyspace at another replication. serve logs a warning at start-up for each keyspace whose replication differs from the config.

    The decisions that an ADR would record:

    • A section with no replication_factor line means RF=3 as on main today. extenddb init with no --replication-factor flag defaults the RF to 1. Changing the serde default from 3 to 1 (for consistency with extenddb init) would silently give new account keyspaces just one replica on a deployment that relied on 3.
    • ExtendDB uses one datacenter per deployment.
    • serve warns of a keyspace at another replication factor but does not refuse to start.

    A second maintainer can object here. Without an objection, #909 links this comment in its checklist.

  6. jcshepherd commented on Nov 18, 2026

    @jcshepherd
    CollaboratorAuthor

    Closing this one. Items 1 to 5 are done. Item 6 moves to #1152.

    Item Status
    1-3: one consistency level per statement kind, every call site on the helpers, a test that fails on a call that sets its own level Done in PR#945
    4: no consistency setting; ConsistentRead=false reads at LOCAL_QUORUM Done in PR#945
    5: init creates keyspaces with the configured replication factor and datacenter; serve warns when a keyspace differs Done in PR#909
    6: a CI job that runs the Cassandra integration tests on a 3-node, RF 3 cluster Moved to #1152
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

backend:cassandra

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions