Skip to content

test(cache): pin single-pull coalescing of concurrent misses (#530) - #553

Merged
alpergundogdu merged 1 commit into
mainfrom
claude/fix-small-bugs-jzFfP
May 14, 2026
Merged

alpergundogdu merged 1 commit into
mainfrom
claude/fix-small-bugs-jzFfP

Conversation

@alpergundogdu

Copy link
Copy Markdown
Contributor

Summary

Adds coalesced_concurrent_misses_fire_origin_exactly_once in crates/cache/tests/pull_through.rs. Spawns 10 concurrent engine.get(hash) tasks for an uncached blob against a new SlowOnceOrigin test helper (sleeps 25ms before serving) and asserts the origin saw exactly one fetch. The existing coalesced_owner_retry_unblocks_waiters_on_success already pins coalescing under retry (origin.fetches() == 3); this is the missing happy-path companion that pins == 1 on the no-failure path, so a regression breaking coalescing — duplicate origin charges, duplicate iroh-blobs inserts — shows up without retry noise muddying the count.

SlowOnceOrigin mirrors the shape of the existing FailingThenSucceedingOrigin (atomic fetch counter, OriginFetch::found_one_shot) but takes a Duration delay instead of a failure count. The delay is load-bearing: an instantaneous fetch can complete before any waiter is scheduled, making a coalescing assertion trivially pass for the wrong reason.

Also backfills the buffered_max_bytes field in the three pre-#519 RetryPolicy struct literals introduced by #538 — they no longer compile because #519 added the field after #538 landed.

Closes #530.

Test plan

  • cargo test -p decdn-cache --test pull_through coalesced — 3/3 pass (2 existing + 1 new)
  • cargo test -p decdn-cache --lib retry:: — 9/9 pass (buffered_max_bytes backfill verified)
  • cargo clippy -p decdn-cache --tests -- -D warnings — clean
  • cargo fmt -- --check — clean

https://claude.ai/code/session_01WimP9WEV6zXWiVNJRBnCNo


Generated by Claude Code

Adds `coalesced_concurrent_misses_fire_origin_exactly_once` in
`crates/cache/tests/pull_through.rs`. Spawns 10 concurrent
`engine.get(hash)` tasks for an uncached blob against a `SlowOnceOrigin`
helper (sleeps 25ms before serving) and asserts the origin saw exactly
one fetch. The existing `coalesced_owner_retry_unblocks_waiters_on_success`
already pins coalescing under retry (`origin.fetches() == 3`); this is
the missing happy-path companion that pins `== 1` on the no-failure
path so a regression breaking coalescing — duplicate origin charges,
duplicate iroh-blobs inserts — shows up without retry noise muddying
the count.

`SlowOnceOrigin` mirrors the shape of `FailingThenSucceedingOrigin`
(atomic fetch counter, `OriginFetch::found_one_shot`) but takes a
`Duration` delay instead of a failure count. The delay is load-bearing:
an instantaneous fetch can complete before any waiter is scheduled,
making a coalescing assertion trivially pass for the wrong reason.

Also: backfill `buffered_max_bytes` in the three pre-#519 `RetryPolicy`
struct literals introduced by #538, which now don't compile because
#519 added the field after #538 landed.

Closes #530.

https://claude.ai/code/session_01WimP9WEV6zXWiVNJRBnCNo

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request introduces a new test case to verify that concurrent misses for the same hash are correctly coalesced into a single origin fetch. To support this, a SlowOnceOrigin helper was added to simulate delayed fetches, and existing retry policy tests were updated to include the buffered_max_bytes field. I have no further feedback to provide.

@github-actions

Copy link
Copy Markdown

Coverage report

Total: 89.01% (was 89.16%, ▼ 0.15%) — 13770/15470 lines

File Coverage Lines Δ
crates/cache/src/retry.rs 86.11% 217/252 ▼ 10.35%
History
Commit Total Δ vs base
a3c5c6c (HEAD) 89.01% ▼ 0.15%

@alpergundogdu
alpergundogdu merged commit 5bccc41 into main May 14, 2026
11 checks passed
@alpergundogdu
alpergundogdu deleted the claude/fix-small-bugs-jzFfP branch May 14, 2026 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants