feat(cache): heal divergent tier 0 on ranged reads#385
Conversation
A ranged pinned read (client.ParallelGet chunk) served from a deeper tier can't backfill tier 0, since a partial body must never be stored as the whole object. A divergent/stale tier-0 replica therefore never converges under parallel downloads: every chunk pays a wasted tier-0 open plus a deeper-tier fetch, indefinitely. When Tiered.Open serves a ranged body from a deeper tier, schedule an async full-object refresh of tier 0 from that tier. It is gated on the served version being the authoritative one tracked in the etag map, so a tier 0 that is legitimately newer than a lagging deeper tier is never overwritten. Refreshes are per-key deduplicated, bounded by a concurrency semaphore, and drained on Close. Closes #368 Amp-Thread-ID: https://ampcode.com/threads/T-019f3d90-8c5a-757c-87ff-308404f3b2bd Co-authored-by: Amp <amp@ampcode.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 558d198ef9
ℹ️ 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".
| // A ranged pinned read served from a deeper tier heals a stale tier 0 | ||
| // asynchronously, since a partial body can't be backfilled (#368). | ||
| func TestTieredRangedReadHealsDivergentTier0(t *testing.T) { |
There was a problem hiding this comment.
Remove top-level test comments
/workspace/cachew/AGENTS.md explicitly says "NEVER add comments to top-level tests"; this new comment is attached directly to a top-level Test... function, and the next added test repeats the same pattern, so the commit violates the repository's documented review standard even though the test logic itself may be fine.
Useful? React with 👍 / 👎.
Ranged pinned reads (
client.ParallelGetchunks) served from a deeper tier can't backfill tier 0 — a partial body must never be stored as the whole object — so a stale/divergent tier-0 replica never converges under parallel downloads. Every chunk pays a wasted tier-0 open plus a deeper-tier fetch indefinitely.When
Tiered.Openserves a ranged body from a deeper tier, it now schedules an async full-object refresh of tier 0 from that tier. The refresh is:invalidateStaleon the next read).IfMatchon the source read) and aborted on any copy/mismatch failure.Close.Full-body reads still heal via the existing inline backfill. Closes #368.