Skip to content

Cassandra: four catalog and queue metadata reads on the data path run at LOCAL_ONE and feed a write or a cleanup #592

Closed

Description

@LeeroyHannigan

Summary

Four reads of catalog and queue metadata on the Cassandra data path run at LOCAL_ONE and feed a write or a cleanup. Each can miss a row written moments earlier at LOCAL_QUORUM on a keyspace with a replication factor above 1. None changes what a base-table GetItem, Query or Scan with ConsistentRead: true returns, so they were left out of #560 (fixed in #591).

The four reads

Read File Feeds A missed row means
fetch_indexes_for_table on the put, update and delete paths crates/storage-cassandra/src/data/index.rs (fetch_indexes_for_table_at(.., false)) the set of GSI rows a write maintains a write after an UpdateTable that added a GSI writes no index row for the item; if the backfill already passed its range, the GSI never holds the item
the gsi_pending last_ready_at read data/index.rs the clamp ready_at_ms = max(jittered, last_ready_at + 1) that orders async GSI mutations a later mutation of the same worker partition can take an earlier ready_at, so the GSI can end on the older image
delete_indexes_for_table data/index.rs the index ids whose data tables DeleteTable drops an index's data table is left undropped after its catalog rows are deleted
the TTL bucket read in clear_ttl_entries data/ttl.rs the queue partitions deleted when TTL is disabled queue rows left behind after the registration is removed

The write paths also read the TTL configuration through ttl_config_for_table (metadata_engine.rs), which runs through cassandra_util::query_rows at the driver default outside data/; a write that misses a TTL just enabled inserts no expiration entry.

Expected

The gsi_pending read decides a write and the rows it reads are written at LOCAL_QUORUM inside data/, so passing true there closes it in one argument. The other three read catalog rows that CreateTable and UpdateTable write at the driver default outside data/, so a quorum read alone does not intersect those writes; the catalog writes need a stated level first.

Where

  • crates/storage-cassandra/src/data/index.rs
  • crates/storage-cassandra/src/data/ttl.rs
  • crates/storage-cassandra/src/metadata_engine.rs (ttl_config_for_table)
  • crates/storage-cassandra/src/create_table.rs, update_table.rs (the catalog writes)

Activity

  1. added
    backend:cassandra
    on Oct 27, 2026
  2. jcshepherd commented on Nov 14, 2026

    @jcshepherd
    Collaborator

    #945 fixes this issue. When #945 merges, this issue can close.

    #945 makes every read and write in the Cassandra backend run at LOCAL_QUORUM, and conditional statements run with Paxos at LOCAL_SERIAL. The level comes from one place, cassandra_util.rs. The consistency_policy test fails when a statement does not use it.

    Each read in this issue now runs at LOCAL_QUORUM, through query_rows:

    Read File Level in #945
    fetch_indexes_for_table data/index.rs LOCAL_QUORUM
    the gsi_pending last_ready_at read data/index.rs LOCAL_QUORUM
    delete_indexes_for_table data/index.rs LOCAL_QUORUM
    the TTL bucket read in clear_ttl_entries data/ttl.rs LOCAL_QUORUM
    ttl_config_for_table (through read_ttl_config) metadata_engine.rs LOCAL_QUORUM

    The issue also says the catalog writes in create_table.rs and update_table.rs need a stated level first. #945 sets that level. The plain catalog writes and the indexes batch run at LOCAL_QUORUM, and the tables insert is an LWT at LOCAL_SERIAL. A quorum read now overlaps each quorum write, so each read sees the row.

    ttl_config_for_table still keeps its 5-second cache from main. #945 does not change that cache. The TTL audit re-registers items that a write misses while the cache is stale.

  3. LeeroyHannigan commented on Nov 14, 2026

    @LeeroyHannigan
    CollaboratorAuthor

    bulk_load in crates/storage-cassandra/src/restore_engine.rs (lines 434 to 442 at 95425f5) is one more read of this kind. It reads the restore target's indexes with fetch_indexes_for_table at the driver default. It then writes each restored item's index rows for the indexes that read returns. So an index that the read omits gets no rows for any item of the file.

    #527 makes the legacy restore copy (copy_backup_into_target) read the same list with fetch_indexes_for_table_quorum. As this issue says for the other reads, a quorum read meets the catalog rows only once the writes of those rows state a level.

  4. jcshepherd commented on Nov 18, 2026

    @jcshepherd
    Collaborator

    @LeeroyHannigan, PR#945 covers both points in your comment.

    The read. bulk_load reads the target's indexes with fetch_indexes_for_table. That function calls query_rows, which now runs at LOCAL_QUORUM. Before PR#945 it sent no level, so the driver default applied.

    The writes. create_table writes the GSI and LSI rows of indexes with Stmt::Write. update_table writes them in a batch built by batch(). Both run at LOCAL_QUORUM, so the quorum read meets them.

    For #527, PR#945 removed fetch_indexes_for_table_quorum. fetch_indexes_for_table now does the same job, and the legacy restore copy reads through it.

    tests/consistency_policy.rs fails the build if code sets its own level or skips the helpers.

  5. jcshepherd commented on Nov 18, 2026

    @jcshepherd
    Collaborator

    Closing with #945

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    backend:cassandra

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions