Skip to content

Group commit - #42

Merged
patricklbell merged 16 commits into
masterfrom
group-commit
Nov 30, 2026
Merged

patricklbell merged 16 commits into
masterfrom
group-commit

Conversation

@patricklbell

Copy link
Copy Markdown
Owner

No description provided.

patricklbell and others added 16 commits November 29, 2026 05:24
Tracy pops the *current* fiber's zone stack on every ZoneEnd (no zone id),
so a zone held across a suspension must end with the same fiber current.
The previous scheme assumed every suspension returned to the event loop
(Awaitable::await_suspend left to the bare thread). That broke whenever a
coroutine was resumed by another coroutine (BufferPool release, tx_waiters,
slot_waiters), by eager when_all runners, or destroyed while suspended,
producing "Zone is ended twice." / "Invalid order of zone begin and end
events." (e.g. on pager::checkpoint under concurrent connections).

- track a per-thread stack of resumer contexts: fresh entry pushes and
  switches, suspension to the resumer pops and restores, symmetric transfer
  passes the level through
- give each when_all Runner its own fiber, since siblings interleave
- destroy suspended frames inside their own fiber
- regression tests for each pattern, checked against fiber::g_current

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Native protocol:
- PasswordAuthenticator (SASL PLAIN) via --auth-file; AUTH_RESPONSE /
  AUTH_SUCCESS / BAD_CREDENTIALS, requests gated until authenticated
- REGISTER validates event types; SCHEMA_CHANGE EVENTs are pushed to
  registered connections, serialized per socket by a write lock
- runtime-versioned v3/v4/v5 handling (v3 had been answered with v4
  headers); OPTIONS mirrors the request version and lists
  PROTOCOL_VERSIONS; unsupported versions get the error drivers use to
  downgrade
- v4 LZ4 envelope decompression (was silently misparsed), custom
  payload skipping, v5 large envelopes split/reassembled per spec
- v5 per-query keyspace on QUERY / PREPARE / BATCH
- every read is bounds checked: malformed framing returns
  PROTOCOL_ERROR, ill-formed values (wrong fixed width, bad UTF-8,
  null collection elements, short collections) return INVALID instead
  of asserting or reading out of bounds; bind value counts are checked
- schema change results/events carry the right change type and target
  (DROP was UPDATED, CREATE TYPE was a KEYSPACE change)

Engine:
- prepared ids include the prepare-time keyspace and execute against
  it; stale entries return UNPREPARED; the cache evicts instead of
  asserting when full
- system_schema.keyspaces reports the keyspace's real replication

Core:
- tcp connections have independent read and write waiters
- MapFixedSentinel removal uses tombstones; it previously broke probe
  chains so colliding keys became unreachable

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collecting bind specs and substituting values used two separate walks
that disagreed: DELETE bound USING before its column subscripts, nested
collection-literal markers were typed as the whole collection (and not
bound at all in INSERT), WHERE markers had no names, and an unknown
column was reported as int. A single walker now drives both, types
every marker from the schema, names them like Cassandra ([limit],
[ttl], key(m), in(c)), and rejects markers it cannot type (function
arguments, select clause) instead of guessing. Count mismatches and
null LIMIT values are errors; an unbound marker reaching evaluation
asserts instead of reading as null. The unused evaluator numbering
pass is removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A row is live while its primary-key marker or any regular cell is live.
INSERT writes a marker carrying the statement TTL; UPDATE and column
deletes keep the existing marker and never create one. Row metadata now
records 'no marker' (inverted, so rows already on disk keep their
meaning) and an optional marker expiry, and the precomputed row expiry
covers the marker. A row left with neither marker nor regular cells is
deleted (and unindexed) instead of being stored as an all-null row, so:
- UPDATE ... SET v = null on a missing row creates nothing
- an UPDATE-created row disappears with its last cell
- an INSERTed row survives losing all of its cells

Related fixes found on the way:
- expired cells read as absent; they were returned after their TTL
- deleting the last clustering row no longer drops the partition's
  static row (only a partition delete does)
- DROP COLUMN rewrites rows without the dropped cells and deletes rows
  only those cells kept alive; dropping key or indexed columns is
  rejected instead of corrupting the table

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- USING TIMESTAMP (INSERT/UPDATE/DELETE/BATCH) is rejected: writes apply
  in arrival order with no timestamp reconciliation or tombstones, so an
  explicit timestamp was only right when it matched arrival order. The
  protocol default timestamp drivers send is accepted as arrival time
  within 5 minutes of the server clock and rejected beyond that.
- LIMIT <= 0 is rejected; it wrapped to 'no limit'.
- Residual filtering on collection, tuple and UDT columns used an
  untyped comparison that treated them as incomparable, so =, IN and
  slices silently matched nothing. Values are now materialized as the
  column type and compared with Cassandra's ordering.
- Sets and maps are encoded in element / key order (they are hash
  containers and went out in hash order).
- Slices are rejected on any type containing duration, not just
  top-level duration columns.
- Token-only partition keying is marked @todo; TODO.md and the
  conformance status doc record the remaining simplifications (paging,
  tracing, timestamps). mustpass.txt drops the eight USING TIMESTAMP
  tests and adds twelve newly passing ones.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	cql/native/native.cppm
Each frame now carries a commit flag and an xxh64 checksum over its
position, page index, flags and full data, salted per WAL generation.
Recovery scans frames and keeps everything up to the last commit frame
before the first bad checksum, so the frame_count header write and its
second fsync are gone (WAL format 0.2).

Opening a WAL always rotates the salt so a new generation can never be
followed by stale, checksum-valid frames from a crashed one; a missing
or invalid WAL header is recreated. Read-only transactions no longer
fsync or count towards the checkpoint interval.

Adds the group commit plan with the consistent-read analysis.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…plan

Readers read the acknowledged snapshot from immutable page versions
without locks or fsync waits; writers work on private copies; flushing
only advances durable_seq and old versions age out via CLOCK.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…bles

- tcp: replace acquire/read/write/release buffer functors with receive
  (append into a caller buffer, holds no network buffer while waiting)
  and send (whole payload); connections carry a generation to reject
  completions for a reused handle; add EdgeTriggered poll registration
- aio/uring/signal: consumers only drain their own handle when it was
  reported (has_event_for) instead of a syscall per foreign wake-up
- cql: system_virtual_schema keyspaces/tables/columns virtual tables;
  reading an unimplemented system table is table-not-found
- native/resp: use tcp::receive/send
- tools: cassandra-stress, conformance and python driver script updates

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The page cache now holds immutable committed page versions tagged with
their commit sequence instead of being cleared on every commit. Write
transactions work on private copies (one buffer per page for every
access in the transaction) that are published as new versions on
commit; rollback just drops the copies. Read transactions see the
durable snapshot taken at begin. Versions no snapshot can select are
trimmed, and the cache is swept back under page_cache_pages with a
second-chance bit.

pager::Config replaces the positional checkpoint interval and is passed
through every init overload, so --checkpoint-interval now applies with a
WAL (it was silently 0, checkpointing every commit). Adds
--page-cache-pages. In WAL mode the db file only grows at checkpoint,
removing an ftruncate per new page. SELECT and iterator transactions
run in read mode.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A write transaction publishes its versions into the open batch and
releases the transaction lock before any I/O. The first committer with
no flush in progress leads: it seals the batch, writes it with one WAL
commit (one fsync), advances durable_seq and wakes the batch's writers,
repeating while a new batch formed during the fsync. Readers started in
the meantime read the durable snapshot and never wait.

Pages written again while still in the open batch replace their batch
version, so a batch writes one frame per page. Writers that wrote
nothing wait for the commits they read; hold_lock_until_durable keeps
other transactions out until the commit is durable, which the CQL
engine uses for DDL because engine.schema changes in memory. Batches
are bounded by group_commit_max_batch_tx / _bytes.

The flush and checkpoint now overlap other transactions, so they use
heap buffers instead of the scratch arena; eviction pauses during a
checkpoint, read_frame captures the salt it verifies against, and the
checkpoint waits for in-flight WAL reads before resetting the WAL.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The flush loop ran inside the first committer's commit, so that writer
got no reply until a fsync passed with no new batch forming, which
under steady load can be indefinitely. Committers now start the loop as
a task the pager owns and each waits only for its own batch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cture issues

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… readers

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@patricklbell
patricklbell merged commit 424c472 into master Nov 30, 2026
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant