Skip to content

[PR] fix(persistence): retain peer snapshots after failed KV reads - #7304

Open
Afloat16 wants to merge 1 commit into
ranxianglei:masterfrom
Afloat16:2026-11-19_snapshot-kv-read-failures
Open

Afloat16 wants to merge 1 commit into
ranxianglei:masterfrom
Afloat16:2026-11-19_snapshot-kv-read-failures

Conversation

@Afloat16

Copy link
Copy Markdown
Contributor

Fixes #7303

What and why

The unified prefix-affinity and session-order writers catch a failed snapshot read and proceed as if the row were absent. A successful subsequent write can then replace another process's durable chains or order skeletons with only this process's local view. The same failure occurs during legacy migration at startup.

Let rejected reads reach each writer's existing outer failure handler before merging, importing or publishing any replacement. Hydration remains retryable; a failed steady-state merge selects the documented legacy path for later writes. Affinity hydration reads content and presence from the same result, eliminating its separate presence probe while preserving existing present/missing semantics.

Validation

  • Four regressions use the actual unified SQLite store and temporary legacy files. Only the first relevant getKvAsync() rejects; all other reads/writes are real. Both hydration and later flush delete peer-only snapshot entries on the base, and all four fail there.
  • The corrected writers retain the stored peer snapshot exactly. Hydration retry recovers both peer and legacy entries; after a failed flush, the next flush writes local state to the legacy carrier and successful hydration reunites both sides.
  • Two missing-row migration controls pass before and after the change.
  • All six related test modules pass: 34 passed, 0 failed, 0 skipped. These include the existing unified migration, legacy persistence, shutdown-wait and debounce cases.
  • npm run typecheck, npm run build including both dist guards, the unused-export and test-import-graph checks, and git diff --check pass.
  • Independent review checked the failure handler, serialized promise chain, retry behavior, presence semantics and real-store assertions; no blocking finding.

Validation used Linux / Node.js 24.22.3 against 6453feeeb842bd1e471d875bf00287e5036a96c7 (0.1.216), with both standard isolation preloads. The full repository regression verdict remains remote CI on this PR's head.

Scope and boundaries

This is one failure-handling correction across the two snapshot carriers. It adds no configuration, format, kernel or wire change. It does not make cross-process read/merge/write atomic, and it does not claim that the failed flush immediately persists its local update: the existing failure policy switches subsequent writes to the legacy carrier.

#6186 fixed the async write lifecycle, #6477 fixes capacity accounting, and #5480 implements legacy journals. Their changes do not prevent this unified-read failure from authorizing an overwrite.

@ranxianglei ranxianglei changed the title fix(persistence): retain peer snapshots after failed KV reads [PR] fix(persistence): retain peer snapshots after failed KV reads Nov 19, 2026

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Snapshot readers overwrite peer session state after a transient KV read failure

2 participants