feat(git): coordinate snapshot generation across replicas#391
Merged
Conversation
worstell
force-pushed
the
worstell/snapshot-generation-coordination
branch
6 times, most recently
from
July 21, 2026 18:52
a63103d to
3f1ae69
Compare
worstell
marked this pull request as ready for review
July 21, 2026 19:14
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3f1ae6936b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Every replica independently runs the periodic snapshot, mirror-snapshot, and LFS-snapshot jobs for each repository, so N replicas regenerate and re-upload the same artifact every interval. For large repositories an LFS snapshot generation takes ~20 minutes, multiplied across every replica, every interval — and because a new pod's schedule store is empty, every deploy triggers an immediate full regeneration on every replica at once. Share per-artifact generation state through the metadata store: before generating, a replica checks whether a peer completed a generation within the interval or holds an unexpired in-progress claim, and skips if so. Claims expire after 30 minutes so a crashed generator can't block peers indefinitely. Steady-state ticks get per-replica jitter and first runs after registration are spread over a few minutes, so claims (which sync asynchronously) propagate before peers decide. Coordination is advisory — the store is last-write-wins — so replicas deciding within the same sync window can still generate concurrently; that's rare with the spread, and a duplicate generation is wasteful but harmless. Without a metadata store, behavior is unchanged. Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-019f85b8-d346-7243-961f-fbf2236a7f94
worstell
force-pushed
the
worstell/snapshot-generation-coordination
branch
from
July 21, 2026 19:29
3f1ae69 to
6416cc0
Compare
alecthomas
approved these changes
Jul 21, 2026
| } | ||
| } | ||
|
|
||
| // jitterInterval spreads replicas' periodic snapshot schedules apart so that |
Contributor
Author
There was a problem hiding this comment.
we know you love your comments
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.
Every replica independently runs the periodic snapshot, mirror-snapshot, and LFS-snapshot jobs for each repository, so N replicas regenerate and re-upload the same artifact every interval. For large repositories an LFS snapshot generation takes ~20 minutes — multiplied across every replica, every interval. And because a new pod's schedule store is empty, every deploy triggers an immediate full regeneration on every replica at once.
This shares per-artifact generation state through the metadata store: before generating, a replica checks whether a peer completed a generation within the interval or holds an unexpired in-progress claim, and skips if so. Claims expire after 30 minutes so a crashed generator can't block peers. Periodic schedules get per-replica jitter so claims (which sync asynchronously) propagate before peers decide.
Coordination is advisory — the store is last-write-wins — so replicas deciding within the same sync window can still generate concurrently; that's rare with jitter, and a duplicate generation is wasteful but harmless. Without a metadata store configured, behavior is unchanged.