[claude] Roll snapshots back to a checkpoint when a commit arrives out of order - #106
Closed
myieye wants to merge 3 commits into
Closed
[claude] Roll snapshots back to a checkpoint when a commit arrives out of order#106myieye wants to merge 3 commits into
myieye wants to merge 3 commits into
Conversation
A late commit makes the replica delete the snapshots after it and replay from the newest surviving snapshot of each entity. That snapshot can predate edits that a sync batch pruned, so the replay loses them, or revives an entity that a cascade delete only ever recorded as a snapshot. Covers both parities of the intermediate snapshot pruning, so one case of each theory fails today. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017BaNW6P4wKvx82fgvh7q1j
A late commit used to delete the snapshots after it and replay from each entity's newest surviving snapshot. That snapshot can predate edits whose snapshots a sync batch pruned, so the replay lost them and revived cascade-deleted entities (#105). Mark the last commit of every snapshot update as a checkpoint: the snapshot table is complete as of that commit. A late commit now rolls back to the newest checkpoint before it and replays everything after it. Commits replayed inside that batch lose their checkpoint. Existing databases have no checkpoints, so their first late commit replays from scratch, which also heals snapshots the old rollback corrupted. Also runs RegenerateSnapshots under the lock and in a transaction, so checkpoints and snapshots move together. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017BaNW6P4wKvx82fgvh7q1j
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017BaNW6P4wKvx82fgvh7q1j
Contributor
Author
|
Superceded by #107 |
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.
[Claude, autonomous]
Fixes #105. The first commit adds the repro tests (
LateCommitTests, one theory case of each fails onmain), the second the fix.Commit.IsSnapshotCheckpoint([JsonIgnore], likeHash): the last commit of every snapshot update is a checkpoint, meaning the snapshot table is complete as of that commit. A late commit rolls back to the newest checkpoint before it and replays everything after it; commits replayed inside that batch lose the flag.SnapshotCheckpointTestspins that contract for Refactor snapshot selection #34/Implement snapshot cleanup #35/Refactor snapshot selection #36.Commits, consumers need a migration (EF scaffoldsdefaultValue: false).RegenerateSnapshotsonce, since flagging its head would preserve the corruption.RegenerateSnapshotsnow runs under the lock and in a transaction, so flags and snapshots move together.GetAtCommit/GetBeforeCommit/GetSnapshotsAtCommitseed a replay the same way and have the same staleness (plus a double-apply of other entities' changes); they can use the checkpoint later. Making the sampler keep each entity's state at checkpoints inside a batch would make hub rollbacks cheaper and fits PR Refactor snapshot selection #34's post-pass.🤖 Generated with Claude Code
https://claude.ai/code/session_017BaNW6P4wKvx82fgvh7q1j
Generated by Claude Code