Skip to content

feat(storage-cassandra): run reads and writes at LOCAL_QUORUM - #945

Merged
jcshepherd merged 15 commits into
mainfrom
fix/issue-770-consistency-policy
Nov 17, 2026
Merged

jcshepherd merged 15 commits into
mainfrom
fix/issue-770-consistency-policy

Conversation

@jcshepherd

@jcshepherd jcshepherd commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

Refs #770 (items 1-3)
Refs #560

What

The Cassandra backend now sets the consistency level of each statement in one place, cassandra_util.rs. Each statement has a "kind" (Stmt), and params() gives the kind its level:

Kind Statements Level
Read SELECT, but not from system.* or system_schema.* LOCAL_QUORUM
Write INSERT, UPDATE, DELETE, BEGIN BATCH with no IF LOCAL_QUORUM
Lwt INSERT, UPDATE, DELETE with an IF condition Paxos at LOCAL_SERIAL, commit at LOCAL_QUORUM
SerialRead a SELECT that must see every committed Paxos round LOCAL_SERIAL
Ddl CREATE, ALTER, DROP, GRANT, REVOKE ONE
SystemRead a SELECT from system.* or system_schema.* ONE

PolicySession::run sends one statement with the parameters of its kind. batch() builds a batch at LOCAL_QUORUM, with LOCAL_SERIAL for a conditional batch, and PolicySession::run_batch sends it. Every statement and every batch outside cassandra_util.rs and migrations/ goes through run(), run_batch() or a helper that calls them.

There is no setting to change these levels. GetItem, Query and Scan with ConsistentRead=false also read at LOCAL_QUORUM.

Three kinds of statements use a level other than LOCAL_QUORUM:

  • DDL runs at ONE. Cassandra does not use the client's consistency level for schema statements or for role statements (CREATE ROLE, GRANT).
  • SystemRead runs at ONE: this is normal for reading Cassandra system-keyspace tables. Each node keeps its own copy of system.local, system.peers and system_schema.
  • migrations/ keeps its own levels. This PR does not change that directory.

Why

Currently, most statements in the Cassandra backend run at the driver's default level, ONE. Some call sites were changed to LOCAL_QUORUM one at a time, as bugs were found. With a replication factor of 3, a read at ONE can miss a write that Cassandra acknowledged. The code then acts on "not found" as a fact. A quorum read sees a write only when that write also ran at quorum, so changing the reads alone does not fix this.

This PR replaces the choice at each call site with one rule: LOCAL_QUORUM for every statement, and LOCAL_SERIAL for every conditional statement. A test fails when new code does not follow the rule. One a single node cluster, these behave as the driver default of ONE.

Not in this PR

Testing done

  • Unit tests in cassandra_util: the level of each kind and of batch(); shape_error for each kind, a system table, a quoted IF, and role statements; batch_level_error for a batch from batch(), BatchQueryBuilder::new() and Default.
  • tests/consistency_policy.rs: the scan above, plus tests that the scan finds each forbidden call and skips comments, test modules and marked lines.
  • direct::consistency_shape: run() panics on an LWT with no IF condition, and run_batch() panics on a batch at the driver's default level, before either sends anything.
  • The Cassandra integration suites, the Python suites and cargo test --workspace, against a local Cassandra 4.1 node.

The tests run on one node. On one node, LOCAL_QUORUM and ONE wait for the same replica, so these runs do not show the new levels. The unit tests and the scan test check them.

Checklist

  • I have read CONTRIBUTING.md
  • All tests pass (cargo test --workspace)
  • Code is formatted (cargo fmt --check)
  • Clippy is clean (cargo clippy --all-targets -- -D warnings, as CI runs it)
  • I have added or updated tests for new functionality
  • I have updated documentation if behavior changed
  • [N/A] Breaking changes are noted below (if any)
  • [N/A] If this changes the wire protocol, Storage trait, auth model, on-disk
    format, or public CLI surface, an RFC has been accepted or is linked
    below. Otherwise, an ADR captures the decision (link below).

By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache License 2.0 and I agree to the Developer Certificate of
Origin (DCO). See CONTRIBUTING.md for details.

…one place

Add the Stmt enum and params(), which set the consistency level for
each kind of statement:
- Read, Write: LOCAL_QUORUM.
- Lwt: Paxos at LOCAL_SERIAL, commit at LOCAL_QUORUM.
- SerialRead: LOCAL_SERIAL.
- Ddl, SystemRead: ONE.
Add batch(), which returns a batch builder at LOCAL_QUORUM with
LOCAL_SERIAL, and the ddl() and system_read() helpers.
query_rows, query_optional and execute now run at LOCAL_QUORUM, not
ONE. apply_lwt now commits at LOCAL_QUORUM, not ONE, and runs Paxos at
LOCAL_SERIAL, not SERIAL. The _quorum helpers now call these helpers.
A later commit removes them.
Refs #770
The wrappers in data/mod.rs now run each statement at the level that
params() gives its kind. query_with_pk_sk and select_by_pk_at take the
kind from the caller. The three wrappers with a transaction id run
only LWTs, so they use Stmt::Lwt.
PutItem, GetItem, DeleteItem, UpdateItem, Scan, index writes and table
DDL now use the helpers and batch():
- Reads and plain writes run at LOCAL_QUORUM, not ONE.
- LWTs commit at LOCAL_QUORUM, not ONE, and run Paxos at LOCAL_SERIAL,
  not SERIAL.
- DDL stays at ONE.
- Batches stay at LOCAL_QUORUM. A conditional batch now runs Paxos at
  LOCAL_SERIAL.
…olicy

TransactWriteItems, TransactGetItems and the transaction ledger now
use params() and batch():
- The partition read in PREPARE runs at LOCAL_QUORUM, not ONE.
- The PREPARE, COMMIT and rollback LWTs, and the ledger INSERT, commit
  at LOCAL_QUORUM, not ONE, and run Paxos at LOCAL_SERIAL, not SERIAL.
- The ledger's state and items updates and its DELETE run at
  LOCAL_QUORUM, not ONE.
- The commit batch stays at LOCAL_QUORUM.

Refs #770
…onsistency policy

Stream reads, TTL queue and bucket deletes, and table worker's
scans and tag delete now use params(), query_rows and batch():
- The 11 stream reads and the 2 table worker scans run at
  LOCAL_QUORUM, not ONE.
- The TTL queue and bucket DELETEs and the tag DELETE run at
  LOCAL_QUORUM, not ONE.
- The read of system_schema.keyspaces runs at ONE through
  system_read() (consistent with Cassandra behavior)
- The TTL repair batch and the GSI worker batch stay at LOCAL_QUORUM.

Refs #770
… consistency policy

The catalog store, table DDL and metadata, the engine and the backup
code now use params() and batch():
- Catalog, table, tag, settings and backup reads and writes run at
  LOCAL_QUORUM, not ONE.
- The CreateTable INSERT ... IF NOT EXISTS commits at LOCAL_QUORUM,
  not ONE, and runs Paxos at LOCAL_SERIAL, not SERIAL.
- CREATE KEYSPACE and DROP KEYSPACE run at ONE through Stmt::Ddl. The
  read of system_schema.keyspaces runs at ONE through Stmt::SystemRead.
- The backup catalog's conditional writes, its list read and the
  batches keep their levels; params() and batch() now set them.

Refs #770
…ncy policy

refactor(storage-cassandra): move IAM and bootstrap onto the consistency policy
The IAM, credential, admin and account stores and the bootstrapper now
use params():
- IAM policy, group, boundary, session and tag reads, and access key
  reads, run at LOCAL_QUORUM, not ONE.
- The admin, account and access key LWTs commit at LOCAL_QUORUM, not
  ONE, and run Paxos at LOCAL_SERIAL, not SERIAL.
- The self-service policy INSERT runs at LOCAL_QUORUM, not ONE.
- init's reads of system_auth and of the catalog run at LOCAL_QUORUM,
  not ONE.
- CREATE ROLE and GRANT use Stmt::Ddl. Cassandra ignores the client's
  consistency level for these statements.
- The read of system_schema.keyspaces runs at ONE through
  Stmt::SystemRead.

Refs #770
…d 'kind'

Add PolicySession::run, which runs one statement at the level that
params() gives its kind. In a debug build, run() panics when the CQL
does not match the kind (shape_error): a read must be a SELECT, a
write must have no IF condition, an LWT must have one, and DDL must
be CREATE, ALTER, DROP, GRANT or REVOKE. Every helper and every
statement outside cassandra_util.rs and migrations/ now goes through
run().

The check found two statements with the wrong kind:
- The backup payload DELETE used Stmt::Read. It now uses Stmt::Write.
  Both run at LOCAL_QUORUM.
- A transaction ledger test sent an LWT through execute(). It now
  uses apply_lwt() and asserts that the fence applied.

Refs #770
…tency policy

Add tests/consistency_policy.rs. It reads every non-test source file
of the crate and fails on a driver call that sets its own consistency
level or uses the driver's default: .query(, .query_with_values(,
.query_with_params(, .exec*(, StatementParamsBuilder::new(,
BatchQueryBuilder::new( or ::default(, QueryBatch::new( and
Consistency::.

Two paths are exempt, each with its reason: cassandra_util.rs, which
sets every level, and migrations/, which uses QUORUM, SERIAL, ALL and
LOCAL_QUORUM, and ONE only for reads of node-local system tables. One
call opts out with a comment: the stream record batch copies the
levels of the index batch that batch() built.

Refs #770
…nsistency policy handler

Add PolicySession::run_batch. Refuses a batch that does not have
the policy levels. The scan test now forbids .batch() and
.batch_with_params(). Change 17 batch sends to use run_batch.

Convert 3 reads of node-local system tables to SystemRead: the token
read in scan, the system_schema.tables read in restore, and
coordinator_now_millis in the backup catalog. shape_error now
refuses a Read or SerialRead of system.* or system_schema.*.

Change the test helpers in index, backup_engine and
keyspace_migrations to read system tables with system_read.

docs: the Known Limitations bullet now names LOCAL_QUORUM and
LOCAL_SERIAL for reads, writes and lightweight transactions.
@jcshepherd jcshepherd added the backend:cassandra Related to the Cassandra backend specifically label Nov 10, 2026

@LeeroyHannigan LeeroyHannigan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I read the change against main at cbc3680. I ran nothing, so each point below comes from reading the code.

This branch conflicts with main in backup_catalog.rs, create_table.rs and stream_engine.rs, so no pull_request workflow except CodeQL has run on 58d2763. Main also added statements that the new scan rejects: self.session.query(&batch) in stream_lifecycle.rs:355 (#515), new .query_with_values( reads in stream_engine.rs, and a third LOCAL_QUORUM batch in backup_catalog.rs (#825). That batch sets no serial level, so run_batch would refuse it in a debug build. The rebase has to move those onto the policy too.

docs/design/11-high-availability.md:139-142 still maps ConsistentRead = false to ONE and calls the Cassandra model multi-datacenter. After this change both reads run at LOCAL_QUORUM, on one datacenter.

In the PR body, #770 item 5 also stays open. init still creates every keyspace at RF 1, and there LOCAL_QUORUM is the same as ONE. "One a single node cluster" should read "On a single node cluster", and that sentence holds only for RF 1 keyspaces.

"{kind:?} statement: {}: {query}",
shape_error(kind, &query).unwrap_or_default()
);
async move { self.query_with_params(query, params(kind, values)).await }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing tests what run() sends. With params(Stmt::Ddl, values) here, every statement goes out at ONE and every test still passes. The unit tests call params() directly, and every integration suite uses RF 1 keyspaces. rows_at passing Stmt::Read for kind survives the same way. A keyspace created with NetworkTopologyStrategy and datacenter1: 3 on the single CI node makes LOCAL_QUORUM and LOCAL_SERIAL fail with Unavailable, while ONE succeeds. Could a test there check each kind, the helpers and run_batch(batch())?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added tests/direct/consistency_levels.rs. On a keyspace whose quorum is larger than the node count, each kind, each helper and run_batch(batch()) get an Unavailable error that names its consistency level, and system.paxos distinguishes a serial read from a quorum read. Your two examples, and three more mutants, each fail a test. One node cannot show an LWT's commit level, so only the params() unit test checks it.

debug_assert!(
shape_error(kind, &query).is_none(),
"{kind:?} statement: {}: {query}",
shape_error(kind, &query).unwrap_or_default()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CodeQL fails on this message because it prints the whole CQL. For the bootstrap CREATE ROLE ... WITH PASSWORD = '...', that includes the password. It cannot fire for that statement today, and release builds drop it. Printing the kind, the first word and the shape error keeps the diagnosis and clears the check.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 0d8e61a: removed the CQL from the message.

use std::path::{Path, PathBuf};

/// Calls that bypass the policy, and what to use instead.
const FORBIDDEN: &[(&str, &str)] = &[

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scan matches substrings such as .query(, so these forms all send at ONE and pass: session.paged(n).query_with_pager_state(..), a raw Envelope::new_req_query on persistent_connection() (the pattern migrations/agreement.rs uses), Session::query(&s, cql) and .query::<String>(cql). Please add them. the_scan_finds_each_forbidden_call iterates this list, so deleting an entry such as .batch( still passes. Could a test pin the expected entries?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scan now finds each send method as .m(, .m::<, ::m( and ::m::<, plus the pager methods, the raw frame builders and send_envelope(. KNOWN_BYPASSES pins one bypass per pattern, your four included.

Comment thread docs/cassandra-setup.md Outdated
DynamoDB semantics.
- **Single-datacenter writes per table.** Transaction and TTL lifecycle
operations use `LOCAL_QUORUM` / `LOCAL_SERIAL`, which are linearizable only
- **Single-datacenter writes per table.** Reads, writes and lightweight

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Every statement now needs a quorum of live replicas. Line 293 allows RF 2 over two nodes. There, while either node is down, GetItem, Query, Scan and the plain writes all fail. Credential and IAM reads that miss the cache fail too. Before this change they ran at ONE and kept serving. The client gets HTTP 500 InternalServerError. Please say which node failures each RF survives: one node for RF 3, none for RF 2 and RF 1. Please also recommend RF 3 on at least three nodes, and say what the client receives.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a paragraph: a request needs a quorum of its keyspace's replicas, and fails with HTTP 500 when fewer are up. It recommends a replication factor of 3 on at least three nodes, and links to the Cassandra docs for the quorum rules.

Comment thread docs/cassandra-setup.md Outdated
- **Single-datacenter writes per table.** Transaction and TTL lifecycle
operations use `LOCAL_QUORUM` / `LOCAL_SERIAL`, which are linearizable only
- **Single-datacenter writes per table.** Reads, writes and lightweight
transactions use `LOCAL_QUORUM` / `LOCAL_SERIAL`, which are linearizable only

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOCAL_QUORUM reads and writes are not linearizable. Concurrent writes resolve by write timestamp, so clock skew between coordinators can reorder them within one datacenter. Please keep "linearizable" for the lightweight transactions, and say what the quorum reads give: they see every write acknowledged before them in that datacenter.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. A LOCAL_QUORUM read sees each write that its datacenter acknowledged before it, and "linearizable" now applies only to the lightweight transactions.

The shape check in PolicySession::run printed the statement's CQL
when the CQL did not match its kind. The CQL can hold a password
(CREATE ROLE ... WITH PASSWORD) and account keyspace names. CodeQL
reported this as cleartext logging of sensitive information.
The message now names the kind and the shape error only. The
consistency_shape test checks that the message does not hold the
CQL text.
…ency-policy

Send main's new IAM delete calls through the consistency policy:
- users: delete_user_impl takes main's delete_principal_row.
- dependents and accounts: the iam_users and accounts
  DELETE ... IF EXISTS use apply_lwt.
- catalog_store: account_exists_quorum reads with query_rows.
…t 'kind'

Add direct::consistency_levels. The tests check the level that run(),
the helpers and run_batch() send to Cassandra. They use two signals
that one node gives:
- The Unavailable error. The test keyspace has a replication factor
  of 2N + 1 on an N-node cluster. So a quorum of its replicas is
  N + 1 nodes, and the cluster cannot supply them. Each statement at
  a quorum level gets an Unavailable error that names the level.
  execute and apply_lwt return only "Database error". For these two,
  the test reads the level from the error that they log.
- The system.paxos table. A read at LOCAL_SERIAL saves a Paxos
  promise there. A read at LOCAL_QUORUM saves none.

The tests do not check the commit level of an LWT. The unit test on
params() checks it.

The policy scan now finds each send method in three forms: a method
call, a method call with type arguments, and a path call. It also
finds the pager methods, the raw request frames and send_envelope.

KNOWN_BYPASSES lists one bypass for each pattern, so a removed
pattern fails a test. The stream record batch in transact_stream.rs
gets a second opt-out comment for its BodyReqBatch::new call.

The comment on index_propagation_delay in engine.rs now says that the
read and the settings write run at LOCAL_QUORUM.

docs: cassandra-setup.md says that each request needs a quorum of its
keyspace's replicas, and that a request fails with HTTP 500 while
fewer are up. It recommends a replication factor of 3 on at least
three nodes. It uses "linearizable" only for lightweight transactions.
11-high-availability.md no longer maps ConsistentRead = false to ONE.
It also clarifies that table reads are strongly consistent when the
clocks are in sync.
@jcshepherd

Copy link
Copy Markdown
Collaborator Author

Thanks. I had to do a couple merges to catch up with main, and then apply the consistency policy to new statements there. The Cassandra integration tests also found close_shards_as_read (#515) sending an UPDATE ... IF as a plain write, so it now uses apply_lwt. The HA design doc and the PR body are fixed, and the body now names #909 for item 5.

@jcshepherd

Copy link
Copy Markdown
Collaborator Author

Thanks for the review, Elise:

Broken on main

Fixed in 6b250d7: I merged main, resolved the conflict in docs/cassandra-setup.md, and routed both new statements through the policy.

  • The paged read of backups_by_arn now uses PolicySession::run_paged(Stmt::Read, ...). A page has the level of its kind, so no new kind is needed.
  • The read of the items pages now uses Stmt::ReadAll, at ALL. A quorum read can miss a row that an older version wrote at ONE to one replica only. The doc comment on Stmt::ReadAll says to remove the kind when backup migrate-legacy is removed.
  • A unit test (the_legacy_item_pages_are_read_at_all) checks that read_items_page, the one function that items calls to read a page, sends Stmt::ReadAll.
  • tests/direct/consistency_levels.rs checks on a one-node keyspace that ReadAll, and a page of Read, SerialRead and ReadAll, get an Unavailable error that names their level. run_paged panics on a kind that is not a read (consistency_shape.rs).
  • main's new tests called query_rows_quorum, which this PR removed. They now call query_rows, which also reads at LOCAL_QUORUM.

Forms overlooked by the scan passes

Fixed in c2cbbb6. Each form is in KNOWN_BYPASSES or has its own test, and each failed before the fix:

  • A raw frame: the scan now forbids persistent_connection(, write_envelope( and Envelope::new(.
  • A method taken as a value: the scan now finds ::name for each send method when ;, ,, ), ], }, a space, a tab or the end of the line follows. rustfmt can put the method last on a line, so the end of the line counts. Text such as cdrs_tokio::query::QueryBatch is not a match.
  • A brace in a string: without_test_modules now skips braces inside strings, raw strings and char literals. It also ignores a #[cfg(test)] that sits inside a string. Two tests cover a { that hid the rest of the file, and a } that ended a test module early.

I added each of your forms to src/workers.rs as a string constant. The scan reported each one, including the .query( after the test module that held a {. I removed them again.

PR description

Fixed. The description no longer says "One a single node cluster". It no longer says that the tests do not show the new levels: consistency_levels.rs shows them, and only the commit level of an LWT is not shown. It says that #770 item 5 is in #909, and that init now creates keyspaces with a replication factor of 1 by default. It has Closes #560 and Closes #592. #770 stays a Refs line (items 1-4).

@eliseong eliseong self-assigned this Nov 17, 2026

@eliseong eliseong left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

I merged current main into the head and it builds with no conflict. The two statements from the backups work route through the consistency policy now. run_paged(Stmt::Read, ...) reads a page at LOCAL_QUORUM, and Stmt::ReadAll reads the legacy item pages at ALL. On a one-node keyspace with three replicas, a page of each read kind fails Unavailable at its own level, and ALL asks for three replicas where LOCAL_QUORUM asks for two. The read_items_page and run_paged tests fail when I revert the kind. close_shards_as_read runs through apply_lwt now, so its IF commits at LOCAL_QUORUM. The reads behind #560 and #592 run at LOCAL_QUORUM.

One non-blocking note. The three scan forms I reported before are caught now. A further pass found that the text scan can still be evaded by path-level forms, such as a macro that wraps a send or an aliased import. A text scan cannot catch these. A resolved-path guard, such as a clippy disallowed-methods lint on the send methods, would close the class, and CI already runs clippy with -D warnings. I will file a follow-up issue. It does not block this change.

@jcshepherd
jcshepherd dismissed LeeroyHannigan’s stale review November 17, 2026 22:04

Comments addressed and re-reviewed.

@jcshepherd
jcshepherd added this pull request to the merge queue Nov 17, 2026
Merged via the queue into main with commit 51cb18c Nov 17, 2026
71 of 73 checks passed
@jcshepherd
jcshepherd deleted the fix/issue-770-consistency-policy branch November 17, 2026 22:41
LeeroyHannigan added a commit that referenced this pull request Nov 18, 2026
…e setup guide

The merge of #945 added Stmt::WriteAll and Stmt::LwtAll for the encryption-key statements. The direct level test now sends both kinds to an under-replicated keyspace. WriteAll fails at ALL, and the Paxos round of LwtAll fails at LOCAL_QUORUM before its commit. One cassandra_util unit test now checks the levels of the three ALL kinds. The shape error for a conditional write names both LWT kinds. execute_at and apply_lwt_at are pub(crate), as rows_at is. docs/cassandra-setup.md says that the encryption-key commands need every replica of the catalog keyspace, because they read and write the key rows at ALL.
@robinnsc robinnsc mentioned this pull request Nov 18, 2026
6 of 8 tasks
robinnsc added a commit that referenced this pull request Nov 18, 2026
Moves the workspace version from 0.1.15 to 1.0.0 on every surface that
carries it: the root Cargo.toml version and its 13 exact pins, the 14
workspace entries in Cargo.lock (no third-party entry changes),
packaging/npm/package.json (version and the five platform pins), the
four licence-notice files (regenerated with cargo-about 0.9.0), and the
example `extenddb version` and `serve` output in docs/getting-started.md
and docs/manuals/04-quickstart-setup-guide.md.

RELEASED_THROUGH stays 12: migration 12 is still the last one, so 1.0.0
carries the catalog of 0.1.15 and freezes nothing new.

Upgrade manual:

- Behavior Changes by Release gets a v1.0.0 entry for #945: the
  Cassandra backend reads and writes at LOCAL_QUORUM where 0.1.15 ran
  many of them at ONE, so a request fails with HTTP 500 while fewer
  than a quorum of its keyspace's replicas are up. It says what to do
  before upgrading: a replication factor of 3, as cassandra-setup.md
  describes.
- Current Status, the General Upgrade Procedure and the Rollback
  Procedure cover 0.1.15 to 1.0.0, with that Cassandra step. Current
  Status says which of its paragraphs are for 0.1.14 and earlier and
  that the backup store notes apply to every deployment.
- A v0.1.15 entry for the request validation of #619, #620, #830 and
  #1000, which had none. It says the expression depth limit is
  ExtendDB's own.
- The rollback to 0.1.14 or earlier states what a binary of those
  releases does on a migrated catalog, as measured on PostgreSQL with
  0.1.14 and 0.1.10: exit status 1, "invalid catalog version '12'".

docs/versioning.md: the 0.1.x releases get no more fixes. The Docker Hub
pages name 0.1.15 as the first keyless-signed release.
docker/README-mongodb.md ran extenddb/extenddb-mongodb:0.1.8; it now
runs X.Y.Z, as the other image READMEs do.

doc_version_literals now reads docker/ as well, so a stale image tag
there fails it. It reports each image tag once, and skips another
project's image tag and a link to a release. The npm launcher test now
checks that the launcher refuses the release line before an X.0.0
launcher, which it skipped at patch 0.

Signed-off-by: Scott Robinson <robinnsc@amazon.com>
robinnsc added a commit that referenced this pull request Nov 18, 2026
Moves the workspace version from 0.1.15 to 1.0.0 on every surface that
carries it: the root Cargo.toml version and its 13 exact pins, the 14
workspace entries in Cargo.lock (no third-party entry changes),
packaging/npm/package.json (version and the five platform pins), the
four licence-notice files (regenerated with cargo-about 0.9.0), and the
example `extenddb version` and `serve` output in docs/getting-started.md
and docs/manuals/04-quickstart-setup-guide.md.

RELEASED_THROUGH stays 12: migration 12 is still the last one, so 1.0.0
carries the catalog of 0.1.15 and freezes nothing new.

Upgrade manual:

- Behavior Changes by Release gets a v1.0.0 entry for #945: the
  Cassandra backend reads and writes at LOCAL_QUORUM where 0.1.15 ran
  many of them at ONE, so a request fails with HTTP 500 while fewer
  than a quorum of its keyspace's replicas are up. It says what to do
  before upgrading: a replication factor of 3, as cassandra-setup.md
  describes.
- A v1.0.0 entry for #1003. Without key_file the stored format and the
  catalog key stay as they are, and 0.1.15 and 1.0.0 each read the
  access keys the other wrote. serve and the backup commands refuse a
  catalog key that is not 32 bytes in base64, where 0.1.15 started and
  failed every signed request with HTTP 500; the entry says how to
  check the key before upgrading. The key moves into a locked key
  store, with a warning when the memlock limit is too low. key_file and
  the encryption-key commands are opt-in and link to the admin guide.
- The rollback section of #1003 now gives the PostgreSQL refusal of
  0.1.15 on a switched catalog: the encrypted connection string row
  stops it with exit status 1 before the missing key does.
- Current Status, the General Upgrade Procedure and the Rollback
  Procedure cover 0.1.15 to 1.0.0, with the Cassandra step, the key
  check, and the rollback after encryption-key switch. Current Status
  says which of its paragraphs are for 0.1.14 and earlier and that the
  backup store notes apply to every deployment.
- A v0.1.15 entry for the request validation of #619, #620, #830 and
  #1000, which had none. It says the expression depth limit is
  ExtendDB's own.
- The rollback to 0.1.14 or earlier states what a binary of those
  releases does on a migrated catalog, as measured on PostgreSQL with
  0.1.14 and 0.1.10: exit status 1, "invalid catalog version '12'".

docs/versioning.md: the 0.1.x releases get no more fixes. The Docker Hub
pages name 0.1.15 as the first keyless-signed release.
docker/README-mongodb.md ran extenddb/extenddb-mongodb:0.1.8; it now
runs X.Y.Z, as the other image READMEs do.

doc_version_literals now reads docker/ as well, so a stale image tag
there fails it. It reports each image tag once, and skips another
project's image tag and a link to a release. The npm launcher test now
checks that the launcher refuses the release line before an X.0.0
launcher, which it skipped at patch 0.

Signed-off-by: Scott Robinson <robinnsc@amazon.com>
LeeroyHannigan added a commit that referenced this pull request Nov 20, 2026
Main is at 2ef5613, 25 commits after the last merge. No file has a
conflict. Six files changed on both sides, and git merged each of them
with no overlap: crates/core/src/validation/mod.rs,
crates/engine/src/update_item.rs,
crates/storage-cassandra/src/data/transactions.rs,
crates/storage-mongodb/src/data_engine.rs, crates/storage/src/lib.rs and
docs/differences-from-dynamodb.md.

In the Cassandra transactions file, #945 moved every statement to the
consistency policy of `cassandra_util`. The token statements of this
branch use the `query_optional`, `apply_lwt` and `execute` helpers,
which take their consistency level from that policy, so they need no
change.
amrith pushed a commit to amrith/extenddb that referenced this pull request Nov 20, 2026
…e the catalog (ExtendDB#1003)

* feat(auth): wrap the credential encryption key with a KEK file

This change implements RFC-0000 for ExtendDB#707. The server can keep the key
that encrypts stored secrets outside the catalog, and it holds less
key material in memory.

- [auth.encryption] key_file names a key-encryption key (KEK) file by
  an absolute path. The KEK wraps a data encryption key (DEK), and the
  catalog holds the wrapped DEK in an encryption_key_ring settings row.
  The DEK encrypts the secret of each access key and each AssumeRole
  session. On PostgreSQL it also encrypts the
  data_database_connection_string row.
- The server refuses a KEK file that another user can read or replace.
  It checks the canonical path, each parent directory, the open
  descriptor and, on Linux, the POSIX ACL. It accepts group access
  only on a file that root owns.
- The additional authenticated data (AAD) of AES-GCM binds each stored
  secret to its row, and each wrapped DEK to every field of the ring.
- The credential cache holds one SigV4 signing key per access key and
  scope date, and the SHA-256 of each session token. It holds no
  plaintext secret or token. A key for a new scope date comes with the
  identity of the read that derives it.
- A locked key store holds the DEK or the catalog key, and the signing
  keys. It uses memfd_secret where the kernel has it, and otherwise
  mlock with MADV_DONTDUMP and MADV_WIPEONFORK.
- extenddb encryption-key has six commands: status, switch, rewrap,
  rotate, reset and set-data-connection. rewrap changes the KEK while
  the server runs. switch, rotate and reset run while every server is
  stopped, under the migration lock. rewrap, rotate and reset write the
  ring only while its row holds the ring they read.
- On Cassandra the commands read and write the key rows at ALL. On
  SQLite, switch, rotate and reset end with a VACUUM under
  secure_delete, so no free page keeps a ciphertext they replaced.
- At startup the server refuses a catalog whose key state does not
  match its configuration. The message names the command or the
  restore that fixes it.
- From ExtendDB#863: each backend and each extenddb backup command refuses a
  catalog key that is not base64 or does not decode to 32 bytes.
  ADR-0026 records that the MongoDB driver builds its TLS
  configuration with rustls::crypto::ring.

Without key_file, the stored format and the catalog key stay as they
are. The catalog key and the signing keys move into the locked key
store. When locking fails, the server logs a warning and starts.

The docs cover the KEK file, its delivery routes, the commands,
rollback, restore and a troubleshooting entry for each refusal.

Refs ExtendDB#707
Refs ExtendDB#776

* fix(storage-cassandra): run the encryption-key statements through the consistency policy

Main sets the consistency level of each Cassandra statement through a Stmt kind and PolicySession::run. Its source scan refuses Consistency values and StatementParamsBuilder outside cassandra_util.rs.

The encryption-key statements of this branch named Consistency::All. They now use Stmt::ReadAll, Stmt::WriteAll and Stmt::LwtAll, and the read of a page of stored secrets uses run_paged. The ring update runs Paxos at LOCAL_SERIAL in place of SERIAL, as every other LWT on main does.

The doc comments now say that the other settings statements and the startup read of the key rows run at LOCAL_QUORUM.

* fix(storage-cassandra): cover the ALL kinds in the level tests and the setup guide

The merge of ExtendDB#945 added Stmt::WriteAll and Stmt::LwtAll for the encryption-key statements. The direct level test now sends both kinds to an under-replicated keyspace. WriteAll fails at ALL, and the Paxos round of LwtAll fails at LOCAL_QUORUM before its commit. One cassandra_util unit test now checks the levels of the three ALL kinds. The shape error for a conditional write names both LWT kinds. execute_at and apply_lwt_at are pub(crate), as rows_at is. docs/cassandra-setup.md says that the encryption-key commands need every replica of the catalog keyspace, because they read and write the key rows at ALL.

* test(storage-cassandra): check that the secret store sends at ALL

The direct level test gives a migrated catalog keyspace a replication factor of 2N + 1 on N nodes. The first statement of read_secret_page, write_secrets, delete_secrets and delete_setting then fails with an Unavailable error that names ALL. If the page read, the write-time read or the rewrite runs as Stmt::Read or Stmt::Write, the test fails. level_in now reads "cl: All". under_replicated and the new test share no_quorum_replicas, and with_replicas and the new test share one replication map. The test drops its catalog keyspace when it ends.
amrith pushed a commit to amrith/extenddb that referenced this pull request Nov 20, 2026
Moves the workspace version from 0.1.15 to 1.0.0 on every surface that
carries it: the root Cargo.toml version and its 13 exact pins, the 14
workspace entries in Cargo.lock (no third-party entry changes),
packaging/npm/package.json (version and the five platform pins), the
four licence-notice files (regenerated with cargo-about 0.9.0), and the
example `extenddb version` and `serve` output in docs/getting-started.md
and docs/manuals/04-quickstart-setup-guide.md.

RELEASED_THROUGH stays 12: migration 12 is still the last one, so 1.0.0
carries the catalog of 0.1.15 and freezes nothing new.

Upgrade manual:

- Behavior Changes by Release gets a v1.0.0 entry for ExtendDB#945: the
  Cassandra backend reads and writes at LOCAL_QUORUM where 0.1.15 ran
  many of them at ONE, so a request fails with HTTP 500 while fewer
  than a quorum of its keyspace's replicas are up. It says what to do
  before upgrading: a replication factor of 3, as cassandra-setup.md
  describes.
- A v1.0.0 entry for ExtendDB#1003. Without key_file the stored format and the
  catalog key stay as they are, and 0.1.15 and 1.0.0 each read the
  access keys the other wrote. serve and the backup commands refuse a
  catalog key that is not 32 bytes in base64, where 0.1.15 started and
  failed every signed request with HTTP 500; the entry says how to
  check the key before upgrading. The key moves into a locked key
  store, with a warning when the memlock limit is too low. key_file and
  the encryption-key commands are opt-in and link to the admin guide.
- The rollback section of ExtendDB#1003 now gives the PostgreSQL refusal of
  0.1.15 on a switched catalog: the encrypted connection string row
  stops it with exit status 1 before the missing key does.
- Current Status, the General Upgrade Procedure and the Rollback
  Procedure cover 0.1.15 to 1.0.0, with the Cassandra step, the key
  check, and the rollback after encryption-key switch. Current Status
  says which of its paragraphs are for 0.1.14 and earlier and that the
  backup store notes apply to every deployment.
- A v0.1.15 entry for the request validation of ExtendDB#619, ExtendDB#620, ExtendDB#830 and
  ExtendDB#1000, which had none. It says the expression depth limit is
  ExtendDB's own.
- The rollback to 0.1.14 or earlier states what a binary of those
  releases does on a migrated catalog, as measured on PostgreSQL with
  0.1.14 and 0.1.10: exit status 1, "invalid catalog version '12'".

docs/versioning.md: the 0.1.x releases get no more fixes. The Docker Hub
pages name 0.1.15 as the first keyless-signed release.
docker/README-mongodb.md ran extenddb/extenddb-mongodb:0.1.8; it now
runs X.Y.Z, as the other image READMEs do.

doc_version_literals now reads docker/ as well, so a stale image tag
there fails it. It reports each image tag once, and skips another
project's image tag and a link to a release. The npm launcher test now
checks that the launcher refuses the release line before an X.0.0
launcher, which it skipped at patch 0.

Signed-off-by: Scott Robinson <robinnsc@amazon.com>
LeeroyHannigan added a commit that referenced this pull request Nov 20, 2026
…session

Main now sends every Cassandra statement through PolicySession::run (#945),
and tests/consistency_policy.rs fails on the seek's query_with_values call.
The seek now calls query_rows, as last_sequence_in does, so it reads at
LOCAL_QUORUM like the tip read.

The two AT_TIMESTAMP tests move from tests/direct/streams.rs to
tests/direct/stream_at_timestamp.rs unchanged. streams.rs is back at its
length on main.
amrith pushed a commit to amrith/extenddb that referenced this pull request Nov 24, 2026
…ndDB#468)

* feat(streams): AT_TIMESTAMP shard iterator on all four backends

DynamoDB Streams added the AT_TIMESTAMP shard iterator type on 2026-10-15.
GetShardIterator takes ShardIteratorType AT_TIMESTAMP with a Timestamp
member (epoch seconds, fractional milliseconds allowed) and returns an
iterator positioned at the first record created at or after that time.
ExtendDB answered SerializationException for the type.

Behaviour, measured on the service (us-east-1, 2026-10-23; raw requests and
responses recorded in the issue):

- The seek compares at millisecond precision. A Timestamp of 14:04:08.5
  skips records written at 14:04:08.050 to .071 and starts at the next
  group, while the integer 14:04:08 includes them.
- A timestamp older than the oldest retained record returns everything
  with no error; one past the newest record positions after it, so
  GetRecords returns records written from then on.
- Validation order: the type enum, then Timestamp presence or absence for
  the type, then SequenceNumber presence or absence for the type, then the
  future check, then stream and shard existence. Every parameter message
  carries the prefix "One or more parameter values were invalid: ".
- The future buffer is about one second: now + 1 s was accepted, now + 2 s
  refused. A Timestamp sent as a JSON string, boolean or object is a
  SerializationException; null, zero and negative are the "Valid timestamp
  must be provided" refusal.

Implementation:

- ShardIteratorType::AtTimestamp and GetShardIteratorInput.timestamp.
- The handler refuses a missing or null type with the service's "Member
  must not be null" text, pre-validates the type enum (the service's member
  order, rendered without the offending value as the service does), refuses
  a Timestamp whose JSON type is not a number with the service's
  deserializer texts, then runs the parameter rules in
  streams_iterator_params.rs. The same module now owns the
  AT_SEQUENCE_NUMBER to AFTER conversion.
- StreamEngine::first_sequence_number_at_or_after(shard_id, at_ms) on all
  four backends, each in its own stream_at_timestamp.rs. SQLite,
  PostgreSQL and MongoDB take MIN(sequence_number) over created_at >= T.
  Cassandra seeks the clustering key with the HLC millisecond prefix of T
  as the lower bound and filters created_at within that partition:
  created_at_ms <= hlc_ms holds for every record since the one-clock-read
  change, so created_at_ms >= T implies the sequence is at or after the
  bound and no qualifying record is skipped, and the filter drops a record
  written under a clamped clock whose prefix clears the bound while its
  created_at is before T. MongoDB and SQLite gain a (shard_id, created_at)
  index for the seek; on MongoDB the existing index walked 50,000
  documents (84 ms) for a mid-range seek over a 100,000-record shard.
- Resolution: a match positions AT that record (the existing n - 1
  conversion); no match positions after the newest record. The tip is
  read before the seek so a write landing between the two reads is not
  skipped.
- TRIM_HORIZON and LATEST with a SequenceNumber now refuse as the service
  does (ExtendDB#461), since the same check covers them.

Tests: tests/test_streams_at_timestamp.py, eleven tests with every
expected value from the measurement, including the at-or-after boundary
at a record's own millisecond, passing on SQLite, PostgreSQL, MongoDB and
Cassandra; nine of the original ten fail against a server built from the
base commit. The existing tests/test_streams.py passes on all four. Unit
tests cover the millisecond floor, the validation order and texts, the
Timestamp JSON-type texts, the future buffer, the Cassandra bound, and
the tip-then-seek order against a double that writes during the tip read
(the test fails with the reads swapped). A Cassandra direct test inserts a
clamped record and asserts the seek does not return it for a T after its
created_at.

Docs: a Streams section in differences-from-dynamodb.md, the usage guide
example, the streams design doc, and EXTENDDB_STREAM_SINCE in
samples/stream_consumer.py.

Closes ExtendDB#460. Closes ExtendDB#461.

* fix(streams): seek the shard's own range on Cassandra, and adapt AT_TIMESTAMP to main

Main names each stream's shards by stream. On Cassandra it keeps a shard's records in the partition of its index, which every stream of the table shares. The Cassandra seek bound the client's shard id, which no record row carries, so every AT_TIMESTAMP iterator started after the newest record. The seek now reads the shard's partition and sequence range through shard_range, as latest_sequence_number does. Its lower bound is the higher of the shard's start (exclusive) and the time bound (inclusive), because CQL takes one start bound per clustering column. The direct test seeks with the stream's shard id. A new test checks that a closed shard and the next stream's shard each answer only their own records.

The missing ShardIteratorType sentence now comes from the constraint helper that main added for the streams constraint sentences.

On PostgreSQL the seek numbers the shard's committed writes first, as the LATEST read does, so it sees every write that committed before it.

The Shards row in docs/differences-from-dynamodb.md now says four shards per stream that close when a disable closes the stream, which is what main does. The AT_TIMESTAMP usage example takes a <shard-id> placeholder, because main refuses a shard id under 28 characters.

* fix(streams): GetShardIterator rounds Timestamp and checks in the service's order

Timestamp is now rounded half up to the millisecond, as the service does.
Measured on us-east-1, 2026-11-20, against a record created at
millisecond ...389: a Timestamp of ...389.4900 returns the record and
...389.5000 does not. The service refuses 0.0004 with "Valid timestamp
must be provided when the iterator type is AT_TIMESTAMP" and accepts
0.0005. So the rounded value must be at least one millisecond.

The checks run in the order the service runs them:

- A member of the wrong JSON type is a SerializationException before any
  other check. The check reads SequenceNumber before Timestamp, the model
  order. An array has no message, as on the service.
- The constraints on SequenceNumber length, ShardIteratorType and ShardId
  length join one "N validation errors detected" message, in that order.
- AT_SEQUENCE_NUMBER and AFTER_SEQUENCE_NUMBER refuse a missing
  SequenceNumber before they refuse a Timestamp.
- TRIM_HORIZON and LATEST refuse a SequenceNumber after the shard check. On
  a shard that does not exist the answer is "Shard does not exist".

The envelope of the combined message moves into validation_errors_detected
in lib.rs, which validate_enum_fields now calls too.

* fix(storage-cassandra): run the AT_TIMESTAMP seek through the policy session

Main now sends every Cassandra statement through PolicySession::run (ExtendDB#945),
and tests/consistency_policy.rs fails on the seek's query_with_values call.
The seek now calls query_rows, as last_sequence_in does, so it reads at
LOCAL_QUORUM like the tip read.

The two AT_TIMESTAMP tests move from tests/direct/streams.rs to
tests/direct/stream_at_timestamp.rs unchanged. streams.rs is back at its
length on main.

* test(streams): pin the AT_TIMESTAMP boundary to the record's millisecond

The wire test bisects the record's second and asserted only that one
millisecond returns the record and the next does not. A seek with a strict
comparison, or a store that keeps whole seconds, passes that. The test now
writes mid-second, keeps the write's wall-clock window, and checks that the
bisected millisecond lies in that window. It also seeks a fraction before
the window, which returns the record, and one after it, which does not.

The strict comparison moves the boundary by one millisecond inside the
window. The wire carries creation time in whole seconds. So a wire test
cannot tell the two comparisons apart on every run. The SQLite stream tests
get a seek over records with known created_at values: a record's own
millisecond returns it and the next one does not.

The wire test file is dual-target now. Without EXTENDDB_TEST_ENDPOINT the
streams client and the raw requests go to the region's Streams endpoint.
The matrix gains the rows of this review round:

- The service refuses a Timestamp of 0.0004 and accepts 0.0005.
- AT_SEQUENCE_NUMBER refuses a missing SequenceNumber before a Timestamp.
- TRIM_HORIZON and LATEST answer a missing shard before a SequenceNumber.
- The constraint violations join one message.
- An ill-typed member is a SerializationException before the enum check.

* test(streams): sign the raw requests with the default session's credentials

A new boto3.Session() does not see a profile set with setup_default_session,
so the raw requests had no credentials against the service. The signer now
takes the default session when there is one.

* refactor(core): share the validation errors envelope

The "N validation errors detected" envelope moves next to validation_errors
in extenddb_core::error, which now builds on it. The engine's enum check and
the GetShardIterator constraint check call it from there. The engine's
lib.rs goes back under 600 lines.

* test(streams): name the parameter table's row type

Clippy 1.97.0 refuses the tuple type of the parameter rows and a float
literal with more digits than its double holds. The rows get a type alias,
and the row for the measured .3894999 literal uses .3895, the double it is.

* fix(streams): refuse a missing StreamArn and name a missing ShardId in the joined constraints

GetShardIterator answered a body without a StreamArn or without a ShardId
with a SerializationException and serde's text. The service answers
`Invalid StreamArn` for an absent, null or empty StreamArn, before any
constraint clause. For an absent or null ShardId it puts `Value at
'shardId' failed to satisfy constraint: Member must not be null` in the
shardId position of the joined message. Both were measured 2026-11-23 in
us-east-1 on a stream that does not exist. The member type checks still
run first.

The text moves to `extenddb_core::error::INVALID_STREAM_ARN`, and the
server's shape gate reads it from there. The unit table gets the StreamArn
on every row and rows for the seven measured bodies. The wire test gets
the same rows, plus two that put the type check before the StreamArn check.

* test(streams): pin the at-or-after seek on PostgreSQL and MongoDB, and the SQLite shard filter

The `>=` of the seek had a unit test on SQLite only. PostgreSQL gets
`tests/stream_at_timestamp.rs` on a scratch database, and MongoDB a
`records_live` test beside the page tests. Both use the rows of the SQLite
table on records with known `created_at` values. With `>` in place of
`>=`, each fails at the record's own millisecond.

The other shard's record in all three tests is now sequence 4 at `base +
2` instead of sequence 8 at `base - 1000`. It has the lowest sequence
number and sits inside the table's range. A seek without the shard filter
answers it for the first five rows. The old record was never the minimum,
so the SQLite test passed without the filter.

* fix(storage-cassandra): keep the seek module private and assert the clamp test's first record

`stream_at_timestamp` and `sequence_lower_bound` were `pub` with no user
outside the file. Both are private now.

The clamp test's last probe, T before every record, asserted only that
some record came back. Its comment named the clamped record as the answer.
The seek returns the lowest sequence number that passes the filter, and
the real record's prefix is 8 s before the clamped one. So the real record
is the answer, and the test now asserts it by equality.

* test(streams): assert the measured messages and run the guarded probe last

Three assertions checked the error code alone. They now compare the code
and the full message. A past Timestamp on a shard that does not exist is
`Requested resource not found: Shard does not exist` (measured
2026-11-20). Now + 5 s on the wire and now + 2 s in the unit test are the
future refusal (measured 2026-10-23).

The positioning test skipped when group 2 spanned past +0.5 s, and the
skip also dropped the two checks after it. The guarded probe runs last
now, so a slow write skips that probe alone.

* docs(streams): list AT_TIMESTAMP and the sample's EXTENDDB_STREAM_SINCE

The iterator type lists in the design guide, REQ-STREAM-003 and the
MongoDB storage design gain AT_TIMESTAMP. The sample's usage docstring and
its walkthrough describe EXTENDDB_STREAM_SINCE, which the sample reads to
start each shard with AT_TIMESTAMP.

* test(storage-postgres): allow the fixture's unused re-exports in the seek test

The shared fixture re-exports the types the stream disable tests use. The
seek test uses its scratch database and shard helpers only, so clippy's
`-D warnings` failed on the `StreamStatus` re-export. The module
declaration allows unused imports.
LeeroyHannigan added a commit that referenced this pull request Nov 24, 2026
No conflicts. Main changed 13 of the files this branch touches, among
them the Cassandra read path (#945, LOCAL_QUORUM), the Cassandra and
PostgreSQL engine constructors (#1003) and the admin guide, in lines this
branch does not change.
LeeroyHannigan added a commit that referenced this pull request Nov 24, 2026
… read

Since #945 the reads run at LOCAL_QUORUM, and a debug build asserts that a
SELECT from system_schema goes through system_read, which reads at ONE. The
claim test's data_table helper read system_schema.tables with
query_optional, so the test panicked on the merged tree. It now uses
system_read, as the two-account test in index.rs does.
LeeroyHannigan added a commit that referenced this pull request Nov 24, 2026
…ncy claims

Review of 204827d found four statements in the new text that do not hold at
this head. It also found two keys in a sample that the server refuses.

- 04-component-storage 5.2 and 5.3: the 5.2 label pointed at 5.3 for what the
  backend does today. 5.3 still described the replica mode in the present
  tense. Both sections now read as the proposal. The backend serves every item
  read and write from data_pool. The read_pool helper and read_replica_url
  exist only in the sketch. The single-node paragraph carries the label
  "what the backend does today", the replica paragraph the label "proposed".
- 02-high-level-design 4.7: "its reads are strongly consistent whatever
  ConsistentRead says" holds for base table and local secondary index reads.
  Global secondary index rows go through the propagation queue
  (index_propagation_delay_ms, default 10 ms), so a read on a GSI can lag the
  base table. The decision says so. The last rationale bullet now reads the
  same before and after the trait carries the flag: the proposal depends on
  design document 11, Stage 1.
- 08-component-config: connection_timeout_secs and statement_timeout_secs are
  removed from the [storage.postgres] sample. PostgresStorageConfig refuses
  them with the same unknown field error as read_replica_url. A commented
  catalog_pool_size line lists the third key the struct has, as the admin
  guide does. The rest of the section 3 sample is #585.
- 01-requirements REQ-PG-008: the pointer names sections 5.2 and 5.3 of
  document 04, since the code sketch is in 5.2 and the prose in 5.3.

Corrections to the message of 204827d. The flag reaches the engine as
GetItemInput::consistent_read and does not reach storage. The SQLite,
PostgreSQL and MongoDB backends serve every read from the copy that took the
write. The Cassandra backend reads at LOCAL_QUORUM since #945. The struct
that refuses unknown fields is PostgresStorageConfig, not PostgresConfig.
docs/todo-index.md has no change in this PR, because its line already reads
in the future tense.

Refs #561
LeeroyHannigan added a commit that referenced this pull request Nov 25, 2026
… that passes true

Since #945 the Cassandra backend runs its item reads and base-row writes at
LOCAL_QUORUM, with Paxos at LOCAL_SERIAL for the lightweight transactions.
Issue #560 is closed. The Cassandra get_item comment, ADR-0024, the storage
design and the storage extension manual still described reads at ONE and an
open #560. They now describe the merged levels, with the clock condition the
high availability design states. The ReadOptions doc no longer says that
every in-tree backend serves reads from the copy that took the write.
Cassandra does not: its read and write levels intersect. MongoDB does on a
replica-set connection only.

The lists of the reads that carry the flag named GetItem, Query, Scan,
BatchGetItem and export. The ReadOptions doc and the ADR's Decision now list
every read, the three PartiQL reads and the global secondary index read
included. The base-table read under an LSI SELECT carries the client's
value. The read that evaluates an UPDATE past the item limit and the read
that sizes a failed batch write's charge pass true. The get_item doc, the
storage design, the high availability design and the manual point at the
ReadOptions doc. They keep no copy of the list.

The MongoDB get_item comment said every read goes to the primary. That holds
for a replica-set connection, whose non-primary read preferences the
connection guard refuses. With directConnection=true the driver sends reads
with $readPreference primaryPreferred, as the server selection specification
asks for a direct connection. So a member that stepped down keeps answering
reads. The comment now says so.
rlunar pushed a commit to rlunar/extenddb that referenced this pull request Nov 25, 2026
…DB#584)

* docs: describe the PostgreSQL read replica mode as a proposal, not current behaviour

Four design documents stated a read replica mode in the present tense: a
storage.postgres.read_replica_url setting with read_replica_pool_size, a
read_pool field on PostgresEngine, a read_pool() helper, and
ConsistentRead=false reads routed to a streaming replica. None of it exists:
grep read_replica over crates/ returns nothing, PostgresConfig carries
deny_unknown_fields, and every item read and write runs on data_pool. An
operator who copied read_replica_url from the configuration reference got a
server that refused to start.

- 01-requirements: REQ-DATA-015 states what the backends do (the flag reaches
  storage as ReadOptions::consistent_read; every in-tree backend serves both
  values from the copy that took the write) and REQ-PG-008 is marked proposed
  with the startup refusal named.
- 02-high-level-design 4.7: the decision is strongly consistent reads today,
  the replica route a proposal; the rationale bullets are in the conditional.
- 04-component-storage 5.2: the pool sketch is labelled a proposal (5.3 is
  rewritten by ExtendDB#559).
- 08-component-config: the read_replica_url environment row and the two
  sample lines are removed, since the setting stops the server.
- technical-debt F-2 and the TODO index line say the same in the same tense.

Closes ExtendDB#561

* docs: label section 5.3 as the proposal and correct the read consistency claims

Review of 204827d found four statements in the new text that do not hold at
this head. It also found two keys in a sample that the server refuses.

- 04-component-storage 5.2 and 5.3: the 5.2 label pointed at 5.3 for what the
  backend does today. 5.3 still described the replica mode in the present
  tense. Both sections now read as the proposal. The backend serves every item
  read and write from data_pool. The read_pool helper and read_replica_url
  exist only in the sketch. The single-node paragraph carries the label
  "what the backend does today", the replica paragraph the label "proposed".
- 02-high-level-design 4.7: "its reads are strongly consistent whatever
  ConsistentRead says" holds for base table and local secondary index reads.
  Global secondary index rows go through the propagation queue
  (index_propagation_delay_ms, default 10 ms), so a read on a GSI can lag the
  base table. The decision says so. The last rationale bullet now reads the
  same before and after the trait carries the flag: the proposal depends on
  design document 11, Stage 1.
- 08-component-config: connection_timeout_secs and statement_timeout_secs are
  removed from the [storage.postgres] sample. PostgresStorageConfig refuses
  them with the same unknown field error as read_replica_url. A commented
  catalog_pool_size line lists the third key the struct has, as the admin
  guide does. The rest of the section 3 sample is ExtendDB#585.
- 01-requirements REQ-PG-008: the pointer names sections 5.2 and 5.3 of
  document 04, since the code sketch is in 5.2 and the prose in 5.3.

Corrections to the message of 204827d. The flag reaches the engine as
GetItemInput::consistent_read and does not reach storage. The SQLite,
PostgreSQL and MongoDB backends serve every read from the copy that took the
write. The Cassandra backend reads at LOCAL_QUORUM since ExtendDB#945. The struct
that refuses unknown fields is PostgresStorageConfig, not PostgresConfig.
docs/todo-index.md has no change in this PR, because its line already reads
in the future tense.

Refs ExtendDB#561

* docs: name the GSI lag in the single-node paragraph of section 5.3

Section 4.7 of the high-level design now says that base table and local
secondary index reads are strongly consistent. It also says that GSI rows go
through the propagation queue. The single-node paragraph of document 04, section 5.3, still said that all
reads are strongly consistent. This PR relabels that paragraph. It now says
the same as section 4.7 and points at section 6 for the queue.

Refs ExtendDB#561

Signed-off-by: Lee Hannigan <29015211+LeeroyHannigan@users.noreply.github.com>

---------

Signed-off-by: Lee Hannigan <29015211+LeeroyHannigan@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend:cassandra Related to the Cassandra backend specifically

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants