Repository navigation
feat(cache): live http/s3 probe-HEAD discovery for non-pinned origin content (#1130) - #1523
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Free Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughAdds bounded, TTL-based positive and negative origin probe memoization, exposes cache engine probe APIs, wires three configuration fields through runtime setup and reload handling, and adds a live-origin fallback in probe handling with timeout and refused-hash behavior. ChangesLive origin probe flow
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant ProbeHandler
participant CacheEngine
participant OriginProbeMemo
participant ConfiguredOrigin
ProbeHandler->>CacheEngine: origin_probe_size(hash)
CacheEngine->>OriginProbeMemo: get(hash)
alt cached presence
OriginProbeMemo-->>CacheEngine: Present(size) or Absent
else cache miss
CacheEngine->>ConfiguredOrigin: bounded origin_size probe
ConfiguredOrigin-->>CacheEngine: size or no result
CacheEngine->>OriginProbeMemo: insert presence with TTL
end
CacheEngine-->>ProbeHandler: optional origin size
Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. Comment |
Coverage reportTotal: 80.23% (was 80.15%, ▲ +0.08%) — 54155/67496 lines
History
|
… gate The `pull_through_require_authorized_origin` gate refused to initiate a backend pull/warm for a request whose `namespaceId` had no on-chain authorized origin. But ADR 002 is explicit that the request namespace is a **routing hint, not a trust anchor** — so using it as a serve-authorization decision was residual: a husk left after the per-hash on-chain claim layer was removed. ADR 037 already documented that the gate was namespace-scoped, not operator-scoped (#1368), and authorized nothing per-content (it admitted a serve for any hash in any namespace that had *any* registered origin, even one assigned to a different operator). Remove the gate and everything specific to it: `pull_origin_gate` / `pull_origin_gate_blocks`, `OriginDirectory::has_origin` (its only consumer), `ServeRejectReason::UnauthorizedOrigin` and its wire mapping + metric, the `cache.pull_through_require_authorized_origin` config across all three layers, the `launch_authorized_origin` e2e fixture, and the three `g_node_08_*` tests that existed only to exercise the gate. KEEP the origin directory and `lookup_origins`: that is the legitimate node→node *routing* mechanism (find which upstream origins to pull from for a namespace), which ADR 002/022 sanction. Namespace stays routing-only. Safe by construction: the gate was opt-in and default-off, and the real protections are untouched — `pull_authorized` (channel ownership, the actual unpaid-egress guard), the seed-leech caps, `ContentBlacklist`, and BLAKE3 verification. ADRs 037/022/019/011 updated to match. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…content (#1130) The #1130 `origin_held` index is built from `enumerate()` ∪ pins, and neither http nor s3 enumerates — so for remote origins the index holds *pinned* hashes only. A non-pinned object sitting in the configured bucket therefore probes `false` everywhere and `decdn fetch` auto-discovery fails outright, even though the node could serve it reactively. Close that gap with a per-probe fallback: when the store and the zero-I/O `origin_held` index both miss, consult the origin directly with a live `HEAD`/`HeadObject` (`Origin::size`, no body fetched) and advertise `has_blob: true` + `total_bytes`. Answers — positive `Present(size)` AND negative `Absent` — are memoised under one TTL, so a random-hash probe flood costs at most one origin round-trip per hash per window rather than one per probe. A slow origin is bounded by a per-probe timeout; on overrun the probe answers `has_blob: false`, which post-#1512 is never slashable (an unservable advertisement, or a later `NotFound` on the serve, costs only local reputation). - `crates/cache/src/origin_probe.rs`: bounded, lazily-expiring TTL memo with an injected clock (deterministic unit tests, no new dep, no background sweeper). - `CacheEngine::origin_probe_size`: refused-guard -> memo -> timeout-bounded live `size()` -> memoise; `set_origin_probe_config` installs the knobs once at bring-up (restart-required, like `max_probe_holds`). - probe seam: consulted only when `has_blob` is still false after the index fold. - config: `cache.origin_probe_ttl_sec` (15), `origin_probe_timeout_ms` (2000), `origin_probe_memo_capacity` (4096) across raw + resolved layers, with the reload restart-required classification. Serve-side stream-while-store (the whole-blob TTFB win via a publisher `.obao4`) is the larger follow-up; this PR is discovery only. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…ache literal The settlement/journeys CI jobs build `decdn-node --features anvil-e2e`, which compiles `tests/anvil_bringup_shutdown_e2e.rs` — a full `ResolvedCache` literal the default `cargo nextest` never builds. It was missing the three new `origin_probe_*` fields (E0063). No logic change. Co-Authored-By: Claude Opus 4.8 <[email protected]>
104f755 to
975cac9
Compare
Summary
Closes the http/s3 half of the #1130 origin-discovery gap. #1130's
origin_heldindex isenumerate()∪ pins, and neither http nor s3 enumerates, so for a remote origin the index only ever holds pinned hashes. A non-pinned object sitting in the configured bucket therefore probesfalseeverywhere, anddecdn fetchauto-discovery fails outright ("none of the probed node(s) hold the requested blob") — even though the node could serve it reactively.This adds a per-probe live-HEAD fallback: when the store and the zero-I/O
origin_heldindex both miss, the probe consults the origin directly with aHEAD/HeadObject(Origin::size, no body fetched) and advertiseshas_blob: true+total_bytes. So a non-pinned bucket object is discoverable on the first probe.How the hot path stays cheap
Answers are memoised under one TTL — both positive (
Present(size)) and negative (Absent). Caching the negative is deliberate: it's what turns a random-hash probe flood into at most oneHeadObjectper hash per TTL window instead of one per probe. A slow origin is bounded by a per-probe timeout; on overrun the probe answershas_blob: false.Slash safety
Post-#1512 (phantom-announcement retired, rate-manipulation gated on
s.ok == true), ahas_blob:false— or a laterNotFoundif the object vanished between HEAD and serve — is never slashable; the only cost of a stale positive is a local reputation ding, self-limited by the short TTL. No drop-not-sign gymnastics required.Changes
crates/cache/src/origin_probe.rs(new): bounded, lazily-expiring TTL memo with an injected clock — deterministic unit tests, no new dependency, no background sweeper.CacheEngine::origin_probe_size: refused-guard → memo → timeout-bounded livesize()→ memoise.set_origin_probe_configinstalls the knobs once at bring-up (restart-required, mirroringmax_probe_holds).handlers/probe.rs): the live-HEAD fallback runs only whenhas_blobis still false after the existing index fold — no HEAD is paid when the store or index already answered.cache.origin_probe_ttl_sec(15),origin_probe_timeout_ms(2000),origin_probe_memo_capacity(4096) across the raw + resolved layers, with the reload restart-required classification.Scope
This is discovery only. The serve-side stream-while-store half — the whole-blob TTFB win that streams from the origin to the client while teeing into the store using a publisher-supplied
{H}.obao4outboard — is a larger follow-up (it generalizes the #856 window/voucher loop to a local outboard-backed bao source) and lands as a separate PR.Testing
cargo fmt,cargo clippy --workspace --all-targets, andcargo nextest(cache + common + node, 897 node tests) all green; anvil-e2e compiles. Over-the-wire first-probe discovery is a noted anvil-e2e follow-up.🤖 Generated with Claude Code
Summary by CodeRabbit
HEADfallback during probe handling, skipping further probing when already found.