Fix nested subquery move replay across restarts - #1
Merged
Conversation
…l timeout The per-dependency moves-position is now staged when the move pipeline drains and only committed+persisted once the writer confirms the flush has passed the move's splice (and, at terminate, after the writer has been flushed). This keeps the persisted position from running ahead of durable storage across a restart, which could otherwise leave a subquery shape permanently missing rows. Also raise the oracle-restore test's long_poll_timeout: a very short one trips a separate post-restart long-poll readiness race (bug 3), unrelated to the subquery-restore behaviour under test. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
It is called from terminate/2 after terminate_writer/1 has popped :writer off
the state, so the value is no longer typed as %State{} and the %State{} clauses
were flagged as never matching. Match a bare map and read the fields via
Map.get instead.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Author
|
CI triage: the red checks are fork infrastructure failures, not test failures.
Equivalent sync-service coverage passed locally: warnings-as-errors compilation, 206 focused tests, the full suite, repeated nested restart oracles, 200-transaction catch-up, and the 100-shape/500-mutation property oracle. The stacked upstream-only PR is electric-sql#4699 and will receive the upstream repository's normal matrix once a maintainer approves fork workflows. |
joshdchang
marked this pull request as ready for review
July 13, 2026 03:04
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Integrates Electric's restart-replay work from electric-sql#4681 into the Sapien fork and fixes nested dependency replay when generated control records and spliced move-in rows do not encode their persisted log offsets.
Linear: SAP-7363
Root cause
The dependency materializer reconstructed replay positions from JSON headers. Ordinary replication records contain an LSN and operation position, but generated move controls, snapshot-end controls, and spliced move-in rows do not. Nested materializers therefore tagged replay with the wrong cursor and outer shapes could miss dependency move-ins or move-outs after restart.
Changes
No on-disk format, database schema, HTTP Shape API, or model behavior changes.
Verification
mix format --check-formattedmix compile --force --warnings-as-errorsThe inherited PR matrix will additionally run PostgreSQL 14/15/17/18, oracle, performance, formatting, and Lux checks.
Rollout
This PR does not publish an image while it is open. After review and green CI, merging to
sapien/shape-startuppublishes the multi-architecture Sapien image. Sapien Core will pin the resulting immutable digest only after its disposable exact-citation restart harness passes. Rollback is the prior digest; storage format remains compatible.Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.