Skip to content

feat(6o-i): caps=txn1, consecutive group offsets and group headers to capable replicas (PR 3) - #197

Merged
akosidencio merged 5 commits into
devfrom
feat/v0.6o-i-replication-framing
Nov 26, 2026
Merged

akosidencio merged 5 commits into
devfrom
feat/v0.6o-i-replication-framing

Conversation

@akosidencio

Copy link
Copy Markdown
Member

Phase 6O-I, PR 3: transaction groups on the replication stream (caps=txn1). This implements the approved design (#195, §6–§7).

Draft until its independent review approves it. It must not ship in a release without PR 4 (atomic replica apply, review A R2-L1). Until PR 4, a replica applies a received group's members one by one, exactly as it applies frames today.

Changes

  • Negotiation: every node advertises txn1, and a replica accepts it whenever it is offered. It is never inferred from a version, and older replicas ignore the token.
  • Consecutive offsets: fan_out_group replicates an EXEC's frames under one stream-lock hold, advancing the offset by the count in one step. Two or more frames are marked as a group in the backlog (ReplGroup).
  • Group header: a replica that accepted txn1 is sent a 24-byte header at offset 0 before a group's first frame, on the live stream and in partial syncs. Any other replica gets today's stream.
  • Replica assembler: it buffers one group, checking version, kind, count, first offset, a 64 MiB / 524,288-frame bound from the header, consecutive offsets, the declared byte total and that no member is a DEDUP record.
    • Nothing of a group is applied or acknowledged before its last frame arrives.
    • A link that ends inside a group resumes before it.
    • A malformed group is a protocol error, which forces a full sync.
  • Resume mode: ReplResume remembers txn1 as it remembers expirylog1.

Tests

tests/replication_framing_6oi.rs:

  • the exact header bytes, sent to a capable fake replica but not to an older one;
  • consecutive group offsets among concurrent writers;
  • a fake primary that ends a link mid-group, then resumes partially;
  • ten malformed-group cases, each forcing a full sync;
  • a header on a link without txn1;
  • all four expirylog1 × txn1 combinations converging.

The 6O-H tests that pin the advertised capability string are updated.

… capable replicas (PR 3)

Every node advertises txn1; a replica accepts it whenever offered. An
EXEC's frames are replicated with fan_out_group: one stream-lock hold
gives them consecutive offsets and, two or more, marks them as a group in
the backlog. A replica that accepted txn1 is sent a 24-byte header at
offset 0 before a group's first frame (live stream and partial sync); any
other replica gets today's stream.

The replica buffers a group from its header to its last frame, checking
every field (version, kind, count, first offset, declared bytes against a
512 MiB bound, consecutive offsets, no DEDUP member), and applies or
acknowledges nothing of it before then: a link that ends inside a group
resumes before it, and a malformed group is a protocol error, which forces
a full synchronization. Members are then applied in order, as frames are
today; atomic application is PR 4.

Design: benchmarks/v0.6.0/6o-i/V0.6O-I-PROTOCOL-DESIGN.md §6.
…me bound; a resume point remembers its framing mode

Review A M4: the replica's group bound is the read-ahead's own (64 MiB,
charged at 128 bytes per frame), with an explicit 524,288-frame bound
checked from the header. L5: ReplResume remembers txn1 as it remembers
expirylog1, so a resume point taken one frame at a time is never offered
to a grouped stream. The capability strings the 6O-H tests pin now end in
txn1; the fake primary's sends are best-effort, since a replica that
refused a frame may already have closed the link.
…ocol error

The assembler's next offset and a header's last offset are checked: an
overflow ends the link with InvalidData (a full sync) instead of panicking
the replication task or accepting an offset twice.
…he test ends

follow_reconnecting returns a guard that stops its loop when dropped. A
loop that outlived its test could reconnect to whatever later bound its
primary's port, such as another test's fake primary.
@akosidencio
akosidencio marked this pull request as ready for review November 26, 2026 14:03
@akosidencio

Copy link
Copy Markdown
Member Author

Review D (replication offsets) approved this in round 2: D-2 (offset overflow is a protocol error) and R2-1 (test follow loops stop with their test) are fixed here. The mutant M10 is now killed by a_resume_point_is_offered_only_in_the_framing_mode_it_was_taken_in. Reminder: #198 (atomic replica apply, review C approved) must ship together with this.

@akosidencio
akosidencio merged commit 815c392 into dev Nov 26, 2026
13 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