Skip to content

fix(git): prepare cold snapshot misses in background - #409

Merged
worstell merged 1 commit into
mainfrom
worstell/fast-cold-snapshot-misses
Sep 16, 2026
Merged

worstell merged 1 commit into
mainfrom
worstell/fast-cold-snapshot-misses

Conversation

@worstell

@worstell worstell commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

On a cold snapshot miss, Cachew returns HTTP 404 with Cache-Control: no-store. The client can then use a normal Git clone.

Cachew prepares the snapshot in a background job. The job continues after the client disconnects. Queue limits and timeouts limit resource use. Shared claims reduce duplicate work across replicas, but they do not prevent all duplicates.

The first periodic base snapshot waits one full interval after cold preparation ends, including failed uploads. This change does not alter client refresh checks.

Generated with Amp

@worstell
worstell force-pushed the worstell/fast-cold-snapshot-misses branch from f81ed83 to e32d46b Compare September 15, 2026 18:37
@worstell
worstell marked this pull request as ready for review September 15, 2026 18:49
@worstell
worstell requested a review from a team as a code owner September 15, 2026 18:49
@worstell
worstell requested review from inez and removed request for a team September 15, 2026 18:49
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 15, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-15T22:45:40.993497Z 3756fe2 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@worstell
worstell force-pushed the worstell/fast-cold-snapshot-misses branch from e32d46b to 6c648eb Compare September 15, 2026 19:11

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6c648ebcc4

ℹ️ 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".

Comment thread internal/strategy/git/snapshot.go Outdated
Comment thread internal/strategy/git/snapshot.go Outdated
@worstell
worstell force-pushed the worstell/fast-cold-snapshot-misses branch from 6c648eb to 2368496 Compare September 15, 2026 19:28

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 236849658e

ℹ️ 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".

Comment thread internal/strategy/git/snapshot.go Outdated
Comment thread internal/strategy/git/snapshot.go Outdated
@worstell
worstell force-pushed the worstell/fast-cold-snapshot-misses branch from 2368496 to c1adb34 Compare September 15, 2026 19:48

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c1adb34197

ℹ️ 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".

Comment thread internal/strategy/git/snapshot.go Outdated
Comment thread internal/strategy/git/snapshot.go Outdated
}
case errors.Is(err, os.ErrNotExist):
if _, preparing := s.mirrorPreparations.Load(upstreamURL); preparing {
http.Error(w, "Repository unavailable", http.StatusServiceUnavailable)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I see that this was already the status used above for a similar case but maybe 404 (with Cache-Control: no-store) is a more appropriate response? That's what HEAD requests will get so GET being different is weird. Also I'm pretty sure clients of cachew will auto-retry 5xx errors, which in this case are very unlikely to succeed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ty! good call

Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a0a667-aa3c-7519-8f18-52fce84e7724
@worstell
worstell force-pushed the worstell/fast-cold-snapshot-misses branch from c1adb34 to 3756fe2 Compare September 15, 2026 22:40

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3756fe2e7b

ℹ️ 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".

Comment on lines +26 to +28
// snapshotGenRecord stores the generation state for each artifact.
// ClaimID identifies the owner for release and completion checks.
// ClaimExpiresAt gives all replicas the same expiration time.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Remove the short snapshot record commentary

This three-line comment merely restates what the fields of an unexported, seven-field struct represent; it is neither documentation for a public symbol nor an explanation of why a non-obvious 20+ line block exists. Remove it and rely on the field names, or replace it only with rationale that satisfies the repository's explicit commenting policy.

AGENTS.md reference: AGENTS.md:L19-L22

Useful? React with 👍 / 👎.

@worstell
worstell merged commit cdf2240 into main Sep 16, 2026
8 checks passed
@worstell
worstell deleted the worstell/fast-cold-snapshot-misses branch September 16, 2026 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants