Repository navigation
Description
Found by the multi-agent review of #1510. Pre-existing, not introduced there, but the prewarm work made it more consequential so it is worth tracking.
The gap
CacheEngine guards its #305 in-flight fill-coalescing map with a std::sync::Mutex, and both call sites discard a PoisonError:
crates/cache/src/engine.rsinget's coalescing loop —self.inner.inflight.lock().ok()crates/cache/src/engine.rsinpopulate_inner's loop — sameInflightGuard::drop— same
On poison, control falls through to a direct pull_through_fill. That fallback is the right behaviour. The problem is that nothing logs it and nothing counts it, and a std::sync::Mutex poison is sticky for the process lifetime.
Why it matters
Coalescing is what stops N concurrent requests for the same missing blob from opening N origin pulls. Once poisoned, the node permanently loses it, with zero log lines and zero metric deltas:
- On a metered
http/s3origin that is an unbounded multiplier on the egress bill. - On
populate(local_only = false) thePeerorigin is in scope, so it becomes a double-spend of USDC vouchers to upstream nodes — the hazardTeeOpen::InFlightis explicitly documented to prevent ("the caller MUST NOT open a second upstream pull (no double spend)").
The only observable is decdn_cache_pull_through_bytes_total rising faster than request volume — a ratio nobody knows to compute or alert on.
Note the contrast in the same file: a poisoned metrics-only mutex earns a tracing::warn!. The one mutex guarding a financial invariant is the one that is silent.
Suggested fix
Replace the .ok() / if let Ok with an explicit match that, on poison, emits tracing::error! once (latch it behind a Once or AtomicBool so a hot path cannot spam) and bumps a new cache_inflight_mutex_poisoned counter, then falls through to the direct pull exactly as today. The fallback behaviour is correct; only its invisibility is wrong.
The workspace anti-panic policy (unwrap_used/expect_used/panic denied) makes poison close to unreachable, which is the argument for making it loud rather than for tolerating it silently — if it ever fires, it is a genuine bug and the node will otherwise never tell anyone.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
feat(cache): opt-in remote-origin prewarm, settle two deferred decisi…
fix: make the metrics registry tell the truth (#1517, #1513) (#1527)