Skip to content

feat(consensus): persist retry receipts and shared sessions - #4387

Merged
hubcio merged 17 commits into
masterfrom
feat/durable-protocol-and-sessions
Oct 6, 2026
Merged

hubcio merged 17 commits into
masterfrom
feat/durable-protocol-and-sessions

Conversation

@hubcio

@hubcio hubcio commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Lost replies and retry-cache eviction could allow duplicate mutations after promotion or restart. This PR persists retry protection for shared sessions and publishes receipt checkpoints before reclaiming the corresponding WAL. Retained receipts replay the original result for the same session, group, request ID and operation, subject to current authorization. A partition session retains the highest applied request ID's receipt; committing an out-of-order lower request does not replace it. Already-applied requests without a retained outcome return RequestTooOld.

Shared sessions use client-owned binding proof, authenticated lease renewal and ordered retirement. Partition retirement barriers batch up to 128 ended sessions. Finalization still requires reports covering every allocated partition from a common replica quorum. Reports track a separate partition-incarnation revision; purge and segment deletion do not reset retirement progress. clients_table_max and dedup_clients_max become committed per-group limits, preserved across recovery and transfer. Live protection is not evicted to admit new clients.

Durable initialization records outside partition directories distinguish partitions that never initialized from initialized partitions whose history was lost. Missing history keeps initialized partitions fenced pending recovery. A permanently failed partition counts toward retirement only after publishing a durable incarnation fence. Replacing its files or restarting does not clear that fence; failure to persist it keeps the session retained.

Metadata snapshot installation and log-tail replay preserve revoked-session history and newer retry protection. HTTP JWT requests and write-session attachment recheck that the owner exists and is active against locally applied metadata.

Compatibility and limits:

  • This changes wire and storage formats. Unsupported existing data directories are refused before modification. No migration or rolling-upgrade adapter is supplied; servers and compatible clients deploy together. New empty roots initialize automatically, but complete metadata-directory loss is outside automatic recovery guarantees. Preserve the external initialization and retirement records with backups.
  • Development protocol bounds are 0.11.1..=0.11.1, including patch. Final stable-release bounds remain to be chosen. Released protocol 0.11.0 servers accept every 0.11.x patch, so an incompatible release needs a new minor version for those servers to reject it. Intermediate builds may share a number while requiring different layouts.
  • Replica admission compares protocol, release and storage-format identity. Stripping or repackaging an otherwise compatible executable does not change that identity.
  • Crash-safe send retries require Persisted; explicit offset retries require Persisted and Quorum. Replicated remains the default and uses buffered partition WAL writes without a per-send persistence barrier. HTTP ack=none confirms dispatch only; same-session/partition writes wait for the prior reply or bounded deadline. Purge preserves retained send receipts without restoring purged messages.
  • The binding proof is an independent session credential. Password changes and PAT revocation or expiry do not end an established session. Logout, lease expiry and user deactivation/deletion end session access. Current permissions govern requests, including receipt replays.
  • Rust ConsensusSession::bind and next_request_id now return Result. External VsrSessionControl implementations must provide session_identity and session_bind_secret. Explicit disconnect clears remembered login and local identity; configured AutoLogin can authenticate a later connection.
  • Rust producers create fresh binary retry attempts only after TransientNotAccepted or proven presubmission NotConnected/CannotEstablishConnection. HTTP failures use separate transport retry settings. Uncertain and terminal failures return the unconfirmed batch; an application resend can duplicate an earlier uncertain mutation. Receipt access after permission revocation and general replica-routing/cancellation APIs remain follow-up work.

Rust, Go, Java, C#, Node and Rust-backed bindings use the coordinated login/binding contract. Established Go/Java/C# sessions resume coordinator connections with BindSession, retaining identity and sequence; terminal Unauthenticated or StaleClient bind refusals permit fresh registration. Swift golden fixtures and error mirrors are updated from Rust.

Depends on merged #4365.

@github-actions github-actions Bot added the S-waiting-on-review PR is waiting on a reviewer label Oct 2, 2026
@codecov

codecov Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.20757% with 455 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.54%. Comparing base (f6dfbdb) to head (2aefa45).

Files with missing lines Patch % Lines
core/partitions/src/state_transfer.rs 76.89% 46 Missing and 30 partials ⚠️
core/server/src/partition_helpers.rs 87.83% 46 Missing and 17 partials ⚠️
core/sdk/src/websocket/websocket_client.rs 92.40% 28 Missing and 15 partials ⚠️
core/metadata/src/impls/recovery.rs 84.70% 29 Missing and 10 partials ⚠️
core/sdk/src/quic/quic_client.rs 91.62% 23 Missing and 8 partials ⚠️
core/server/src/boot/mod.rs 76.98% 16 Missing and 13 partials ⚠️
core/server/src/http/state.rs 73.19% 17 Missing and 9 partials ⚠️
core/server/src/consumer_group/liveness.rs 97.53% 15 Missing and 3 partials ⚠️
core/consensus/src/metadata_helpers.rs 93.33% 8 Missing and 6 partials ⚠️
core/sdk/src/tcp/tcp_client.rs 97.18% 11 Missing and 3 partials ⚠️
... and 25 more
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #4387      +/-   ##
============================================
- Coverage     87.91%   87.54%   -0.38%     
- Complexity     1578     1608      +30     
============================================
  Files          1298     1299       +1     
  Lines        233811   241165    +7354     
  Branches     194562   201571    +7009     
============================================
+ Hits         205563   211136    +5573     
- Misses        23339    24975    +1636     
- Partials       4909     5054     +145     
Components Coverage Δ
Rust Core 89.28% <92.20%> (+0.14%) ⬆️
Java SDK 68.82% <ø> (+0.09%) ⬆️
C# SDK 61.60% <ø> (-16.01%) ⬇️
Python SDK 91.25% <ø> (+<0.01%) ⬆️
PHP SDK 85.67% <ø> (ø)
Node SDK 96.53% <ø> (+1.65%) ⬆️
Go SDK 70.33% <ø> (+0.07%) ⬆️
C++ SDK 86.60% <ø> (ø)
Files with missing lines Coverage Δ
core/binary_protocol/src/codes.rs 100.00% <ø> (ø)
core/binary_protocol/src/consensus/command.rs 100.00% <100.00%> (ø)
core/binary_protocol/src/consensus/header.rs 83.36% <100.00%> (-0.02%) ⬇️
core/binary_protocol/src/consensus/operation.rs 97.26% <100.00%> (+0.15%) ⬆️
core/binary_protocol/src/dispatch.rs 89.58% <100.00%> (ø)
...inary_protocol/src/requests/system/bind_session.rs 100.00% <100.00%> (ø)
...nary_protocol/src/requests/users/login_register.rs 98.70% <100.00%> (-1.30%) ⬇️
...ocol/src/requests/users/login_register_with_pat.rs 100.00% <100.00%> (ø)
...ry_protocol/src/responses/messages/poll_routing.rs 100.00% <100.00%> (ø)
...y_protocol/src/responses/messages/send_messages.rs 97.85% <ø> (ø)
... and 120 more

... and 82 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@hubcio
hubcio force-pushed the feat/durable-protocol-and-sessions branch from 98a2f15 to 63eaf2a Compare October 2, 2026 22:32
@hubcio hubcio added the breaking:storage On-disk data format change - skips backwards compat CI label Oct 3, 2026
@hubcio
hubcio force-pushed the feat/durable-protocol-and-sessions branch from 7264016 to a621d98 Compare October 3, 2026 08:38
@hubcio

hubcio commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

/skill team-review-slim

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Summary: Four experts reviewed the pull request at 75c26b5. The review found throughput changes on the HTTP write path, a fatal-vs-degrade contradiction in the partition commit walk, a misleading session error, stale foreign-SDK docs and guards, and one redundant journal barrier.

Counts: critical 0, warning 8, nit 4, simplification 1


This review was generated by Claude Code 2.1.284 on deepseek-flash[1m]. Review the output before you act on it.

Comment thread core/server/src/http/submit.rs Resolved
Comment thread core/server/src/http/submit.rs Resolved
Comment thread core/consensus/src/impls.rs Resolved
Comment thread core/partitions/src/iggy_partition.rs Resolved
Comment thread core/partitions/src/iggy_partition.rs Resolved
Comment thread foreign/node/src/wire/command.code.ts Resolved
Comment thread foreign/go/internal/command/code.go Resolved
@github-actions github-actions Bot added S-waiting-on-author PR is waiting on author response and removed S-waiting-on-review PR is waiting on a reviewer labels Oct 3, 2026
@hubcio

hubcio commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

/skill team-review-slim

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Summary: One critical finding: a state-transfer install leaves pending_retry_checkpoint stale, so the next receipt reclaim deletes the live receipt file and the partition fails to reopen with StateFileCorrupted. The review also finds a full-reply copy on the primary commit path and a session-bind error that names the wrong cause, plus smaller items on a duplicate-reply copy, a redundant segment sync, HTTP retry docs, Java protocol parity, and a constant binding.

Counts: critical 1, warning 2, nit 4, simplification 1

Findings without an anchor on a changed line:

  • core/partitions/src/iggy_partition.rs:1062 critical: After a state-transfer install, pending_retry_checkpoint still holds the pre-install frontier while checkpoint_op() has moved to the install op. This reclaim then deletes the receipt file the install wrote, so the partition fails to reopen with StateFileCorrupted. Reclaim from persistence.checkpoint_op(), or clear the field on every reset.
  • core/partitions/src/iggy_partition.rs:6636 warning: reply.clone() allocates an aligned frame and copies the whole reply for every committed client operation on the primary. Freeze the reply once and share it with the commit cache, copying only for an in-process waiter.
  • core/partitions/src/iggy_partition.rs:4573 nit: cached.into_message() copies the retained reply into an owned frame, and the bus branch then converts it back to Frozen. Send the cached Frozen on the bus path, and build the owned copy only for an in-process waiter.

This review was generated by Claude Code 2.1.284 on deepseek-flash[1m]. Review the output before you act on it.

Comment thread core/sdk/src/session.rs Resolved
Comment thread core/sdk/src/clients/producer.rs Resolved
Comment thread core/partitions/src/iggy_partition.rs Resolved
Comment thread core/server/src/dispatch/partition.rs Resolved
Comment thread core/consensus/src/client_table.rs Resolved
Comment thread core/sdk/src/quic/quic_client.rs Resolved
Comment thread core/sdk/src/clients/producer.rs Resolved
Comment thread core/sdk/src/clients/client.rs Resolved
Comment thread core/metadata/src/impls/recovery.rs Resolved
Comment thread core/partitions/src/state_transfer.rs Resolved
Comment thread core/partitions/src/iggy_partition.rs Resolved
Comment thread core/consensus/src/client_table.rs Resolved
Comment thread core/consensus/src/client_table.rs Resolved
Comment thread core/consensus/src/client_table.rs Resolved
Comment thread core/server/src/session_manager.rs Resolved
Comment thread core/sdk/src/session.rs Resolved
Comment thread core/sdk/src/poll_routing.rs Resolved
@hubcio
hubcio force-pushed the feat/durable-protocol-and-sessions branch from 8e102ae to bb42eda Compare October 5, 2026 08:28
Comment thread core/server/src/dispatch/mod.rs Resolved
Comment thread core/server/src/partition_helpers.rs Resolved
Comment thread core/server/src/partition_helpers.rs Resolved
Comment thread core/server/src/http/submit.rs Resolved
Comment thread core/consensus/src/client_table.rs Resolved
Comment thread core/consensus/src/client_table.rs Resolved
@hubcio
hubcio force-pushed the feat/durable-protocol-and-sessions branch from 69ccfe8 to fac9374 Compare October 5, 2026 13:20
@apache apache deleted a comment from spetz Oct 5, 2026
@hubcio
hubcio force-pushed the feat/durable-protocol-and-sessions branch from fac9374 to 4fb724b Compare October 5, 2026 14:25
mmodzelewski
mmodzelewski previously approved these changes Oct 5, 2026
spetz
spetz previously approved these changes Oct 5, 2026
mmodzelewski
mmodzelewski previously approved these changes Oct 5, 2026
hubcio added 8 commits October 6, 2026 10:51
Lost replies and capacity eviction could erase retry evidence and
permit duplicate mutations after promotion or restart.

Persist original results by session, group and request identity.
Replay the first receipt even when a retry changes its payload, while
preserving principal, session and client-operation guards. Protect
committed capacity and publish receipt checkpoints before reclaiming
their WAL. Refuse recovery when protection is absent or corrupt.

Bind connections using client-owned proof, retain logical sessions
across reconnects, renew leases only on authenticated activity, and
retire protection across every allocated group before finalization.
Preserve uncertainty when a later attempt is refused.

Replay the exact encoded request after same-session resume and across
refused or unreachable roster peers within its deadline. Expired
sessions can log in again without replaying an ambiguous write under a
new identity. Keep HTTP attachments invalidatable and serialize writes
per partition under one deadline. Retain NoAck gates and reply slots
through resolution, clean cancelled registrations, and retransmit
retirement progress until all fences are acknowledged.

Restore recovered receipts before admission while allowing live
pipeline-backed commits. Allow intact empty WALs to elect, fence
missing history before replacement WAL creation, and compare bootstrap
revisions in the same domain.

Introduce protocol 0.11, mandatory storage admission and exact peer
build checks. Require explicit fresh-cluster initialization and
Persisted durability for explicit writes without changing defaults.
Align Go, Java, C# and Node login proofs and shared binding frames.
Validate unsigned binding epochs and expose explicit producer
durability in Rust and Python.

Cover changed-payload retries, reply loss, crash recovery and
reclamation, corruption, capacity pressure, lifecycle fences and
transport retries.

Document first-receipt integrity stamps and stable binding epochs.
Empty storage and Replicated writes were rejected despite existing
startup and SDK contracts. Restore automatic metadata initialization
and scope crash-safe retries to durable writes. Complete metadata
directory loss still requires verified restore.

Orderly shutdown must publish buffered WAL writes, and recovery must
checkpoint them before advancing reserved offsets. Retain repair
bodies across the gap and establish segment links before sends so
descriptor exhaustion cannot block the shutdown barrier.

Align replica, session and simulator fixtures, standalone formatting
and isolated Miri with the supported contracts.
Explicit QUIC and WebSocket disconnects reused remembered credentials.
Clear them like TCP while preserving involuntary transport recovery.

Python CI polluted empty storage with logs and expected terminal
errors to retry. Move logs beside data and align fixtures and docs
with the existing explicit non-admission retry contract.
Singleton offsets could acknowledge an undurable WAL entry, purge
recovery could replace the original receipt, and retirement could
count reports for an older namespace set. Session replacement and
later refusals also exposed retry identity and uncertainty gaps.

Wait for the singleton WAL barrier, preserve original receipt stamps
through purge, and fence missing partition history. Seal namespace
revisions into retirement reports and discard stale quorum evidence.
Queue checkpoint publication and reclaim only after completion.

Keep retained SDK requests within their session and preserve
uncertainty across later refusals. Fix explicit Node login after
confirmed expiry, first-boot marker ordering, lost metadata wakeups
and avoidable HTTP work.

Set current and minimum binary protocol to 0.11.1 and regenerate Swift
fixtures. Preserve automatic startup and Replicated writes; total
metadata-directory loss remains outside automatic recovery.

Document the public Rust API break: ConsensusSession bind and
next_request_id return Result. Producers start fresh retries only
after TransientNotAccepted; other failures return the unconfirmed
batch. Explicit disconnect requires a new login.

Validate with the full just nextest gate, affected foreign SDK suites,
strict Clippy, configured hooks and Miri peer-frame tests.
Poll routes accepted malformed or mismatched bind replies, and the
Node protocol guard missed patch drift. Validate bindings before
polling and report both session identities on a resume mismatch.

Avoid capacity scans when queue bounds prove space and retain only
retirement entries during commit. Preserve receipt fences and HTTP
ordering without adding reservation counters. Remove a redundant
journal sync and correct session and protocol documentation.
Delayed persistence completion could delete the receipt checkpoint
installed by state transfer. Reclaim against the published frontier.

Share immutable replies on bus paths and avoid redundant retained-file
barriers while preserving recovery truncation durability. Correct SDK
session diagnostics and retry docs, and check Java protocol parity.
RequestIdExhausted was added to the Rust catalog without updating
Swift's mirror, failing the golden check. Regenerate the fixture and
add the matching Swift case so error-code parity stays intact.
Retirement could race with queued writes and reuse obsolete quorum
reports. Transferred retry tables could also be checkpointed before
their effects were applied, making restart recovery fail.

Exclude writes while their session retirement is pending, qualify
reports by view, and checkpoint only after applied state catches up.
Retain one partition receipt, distinguish uncommitted transfer
capacity, and isolate corrupt receipt recovery to its partition.
Reuse resolved HTTP partitions and capture the admission frontier
before routing waits. Warm peer identity outside shard runtimes.
hubcio added 8 commits October 6, 2026 10:52
Transport loss reset established sessions in Go, Java and C#,
leaving old protection slots reserved and obscuring retry identity.
Java, Node and C# also let later refusals overwrite an unknown
mutation outcome.

Resume established sessions with their original proof and permit
fresh registration only after a definitive bind refusal. Preserve
uncertainty across later refusals, fence retained Rust frames after
transport locking, and restore retries for proven unsent attempts.
Document session and API contracts and synchronize error catalogs.
Uninitialized partitions could remain offline after restart, while
failed partitions stalled retirement and exhausted session capacity.
Deleted or disabled users could also retain authenticated bindings.

Persist incarnation evidence and retirement fences outside partition
directories, batch retirement barriers, and preserve progress across
truncation. Revoke sessions and memberships during commit and replay.
Use protocol, release and storage identity for peer admission, and
correct the NoAck and capacity contracts.

Require storage format 3 and metadata snapshot format 8. Cover the
reviewed failures with regressions and a three-replica restart test.
A retirement deadline could cancel an admitted WAL append and strand
subsequent logins. Finish the active retirement before ending the
budgeted pass and cover the cancellation window with a regression.

Check full protocol version bounds and document stable release policy.
Box initialization-test futures rejected by macOS Clippy.
Revoked sessions could invalidate snapshots, skip group cleanup during
state transfer, and retain HTTP access through unexpired JWTs. Preserve
retry receipts, replay against historical session state, and reject
inactive principals before serving reads or attaching write sessions.

Handle SDK lock poisoning and request exhaustion without losing session
identity. Add regressions and correct the reviewed protocol and storage
documentation.
Session eviction triggers automatic SDK login, which returns
InvalidCredentials for a deleted account. Accept that denial.
After a lower request commits out of order, the higher request ID
still owns the retained receipt. Correct the simulator's reversed
retry expectations and compare the replayed receipt byte for byte,
while asserting neither retry appends another message.
Replicated sends can wait for the next consensus tick after their
body write completes. Resume eligible commits from the completion
path while preserving recovery and durability gates.

Cover replies without a tick and correct the WAL configuration
comments for both durability policies.
External offset fixtures need committed retry capacity and the
current directory layout after merging durable sessions.

Use valid retry snapshots, preserve transfer and quota assertions,
and reject legacy artifacts that lack session-qualified receipts.
@hubcio
hubcio dismissed stale reviews from mmodzelewski and spetz via 77d9f51 October 6, 2026 09:05
@hubcio
hubcio force-pushed the feat/durable-protocol-and-sessions branch from ac036de to 77d9f51 Compare October 6, 2026 09:05
The retention recovery test still writes the old offset layout,
so boot rejects its receipt checkpoint before checking the WAL tail.

Use version 4 and include every consumer kind's count plus dedup.
@hubcio
hubcio merged commit 56e109a into master Oct 6, 2026
110 checks passed
@hubcio
hubcio deleted the feat/durable-protocol-and-sessions branch October 6, 2026 17:42
@github-actions github-actions Bot removed the S-waiting-on-author PR is waiting on author response label Oct 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking:storage On-disk data format change - skips backwards compat CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants