You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cache: CacheEngine has no circuit-breaker for origin pull-through when the origin returns repeated errors, causing every cache-miss to incur full retry backoff even during a sustained origin outage #963
When an origin is fully unavailable, every cache miss goes through the full retry cycle (up to 3 retries with exponential backoff up to 10s), serializing the backoff cost across all concurrent misses with no way to fast-fail until the origin recovers. A per-origin half-open circuit-breaker would let the cache fail fast and shed load during outages.
The CacheEngine in crates/cache has no circuit-breaker for origin pull-through. During a sustained origin outage, every concurrent cache-miss waiter can run its own full retry budget sequentially (up to N budgets × 3 retries × 10 s backoff), amplifying latency and load rather than failing fast. The fix is a per-origin half-open circuit-breaker that short-circuits new pull attempts while the circuit is open.
Notably, crates/cache/src/retry.rs already documents this exact amplification as a known trade-off: "a sustained outage can produce up to N sequential retry budgets across N concurrent waiters. Accepted as a known trade-off: bounding the amplification would require a shared retry-budget across waiters, which is not implemented." This issue is the natural next step.
📊 Assessment
Dimension
Value
Reasoning
Type
unchanged
Could not query org issue types (403)
Labels
unchanged
Existing bug, enhancement, technical, high are all accurate
Coding agent
Suitable
Scope is self-contained to crates/cache; requirements and success criteria are well-defined; no cross-crate design decisions needed
🔗 Similar issues
ADR 005: Define error handling and retry semantics #29 (related, closed) — "ADR 005: Define error handling and retry semantics" — covered retry policy semantics at the wire level; this issue addresses a missing resilience primitive at the origin pull layer
crates/cache/src/retry.rs already acknowledges the problem in a doc comment but defers it. The amplification bound is N * (1 + max_retries) * max_backoff_per_attempt in the worst case across N concurrent waiters for the same hash, after coalescing breaks down post-exhaustion.
CacheEngine::Inner.origins is Vec<Arc<dyn Origin>> with no per-origin state. The circuit-breaker state would live alongside this.
Suggested implementation approach
State struct — Add a OriginCircuitBreaker struct per-origin (keyed by index or Arc identity in a parallel Vec or HashMap<usize, ...>):
State: Closed | Open { until: Instant } | HalfOpen
Integration point — In CacheEngine::pull_through (or wherever run_with_retry is called per-origin), check the breaker before issuing any attempt:
Closed → proceed normally; on OriginPullError::Transient increment counter; on success reset counter.
Open and Instant::now() < until → immediately return OriginPullError::Permanent (or a new CircuitOpen variant) so the fallback-to-next-origin logic can proceed.
Open and cooldown elapsed → transition to HalfOpen, allow one probe attempt; success → Closed; failure → re-Open with reset timer.
Config — Extend RetryPolicy in crates/config-types with optional circuit-breaker fields (circuit_breaker_threshold, circuit_breaker_probe_interval_secs). Default to off or conservative values.
Metrics — Expose circuit_open_total and circuit_probe_success_total / circuit_probe_failure_total counters via CacheMetrics in crates/cache/src/metrics.rs.
Tests — Add a unit test in crates/cache/tests/ that configures a mock origin that always fails, fires N concurrent get calls, and asserts that origin is contacted at most threshold + 1 probe times rather than N * max_retries times.
Sub-tasks checklist
Add OriginCircuitBreaker state machine (Closed / Open / HalfOpen) to crates/cache
Thread per-origin breaker state through CacheEngine::Inner
Gate run_with_retry calls on breaker check in the pull-through path
Add circuit_breaker_threshold + circuit_breaker_probe_interval_secs to RetryPolicy in crates/config-types
Expose circuit state metrics in CacheMetrics
Unit/integration tests covering open→half-open→closed transitions under concurrent load
Activity
github-actions commentedon Jun 22, 2026
🎯 Triage report
The
CacheEngineincrates/cachehas no circuit-breaker for origin pull-through. During a sustained origin outage, every concurrent cache-miss waiter can run its own full retry budget sequentially (up toNbudgets × 3 retries × 10 s backoff), amplifying latency and load rather than failing fast. The fix is a per-origin half-open circuit-breaker that short-circuits new pull attempts while the circuit is open.Notably,
crates/cache/src/retry.rsalready documents this exact amplification as a known trade-off: "a sustained outage can produce up to N sequential retry budgets across N concurrent waiters. Accepted as a known trade-off: bounding the amplification would require a shared retry-budget across waiters, which is not implemented." This issue is the natural next step.📊 Assessment
bug,enhancement,technical,highare all accuratecrates/cache; requirements and success criteria are well-defined; no cross-crate design decisions needed🔗 Similar issues
💡 Notes and suggestions
Current state (from code)
crates/cache/src/retry.rsalready acknowledges the problem in a doc comment but defers it. The amplification bound isN * (1 + max_retries) * max_backoff_per_attemptin the worst case acrossNconcurrent waiters for the same hash, after coalescing breaks down post-exhaustion.CacheEngine::Inner.originsisVec<Arc<dyn Origin>>with no per-origin state. The circuit-breaker state would live alongside this.Suggested implementation approach
State struct — Add a
OriginCircuitBreakerstruct per-origin (keyed by index or Arc identity in a parallelVecorHashMap<usize, ...>):Closed | Open { until: Instant } | HalfOpenconsecutive_failures: u32failure_threshold(e.g. 5),probe_interval(e.g. 30 s)Integration point — In
CacheEngine::pull_through(or whereverrun_with_retryis called per-origin), check the breaker before issuing any attempt:Closed→ proceed normally; onOriginPullError::Transientincrement counter; on success reset counter.OpenandInstant::now() < until→ immediately returnOriginPullError::Permanent(or a newCircuitOpenvariant) so the fallback-to-next-origin logic can proceed.Openand cooldown elapsed → transition toHalfOpen, allow one probe attempt; success →Closed; failure → re-Openwith reset timer.Config — Extend
RetryPolicyincrates/config-typeswith optional circuit-breaker fields (circuit_breaker_threshold,circuit_breaker_probe_interval_secs). Default to off or conservative values.Metrics — Expose
circuit_open_totalandcircuit_probe_success_total/circuit_probe_failure_totalcounters viaCacheMetricsincrates/cache/src/metrics.rs.Tests — Add a unit test in
crates/cache/tests/that configures a mock origin that always fails, fires N concurrentgetcalls, and asserts that origin is contacted at mostthreshold + 1 probetimes rather thanN * max_retriestimes.Sub-tasks checklist
OriginCircuitBreakerstate machine (Closed / Open / HalfOpen) tocrates/cacheCacheEngine::Innerrun_with_retrycalls on breaker check in the pull-through pathcircuit_breaker_threshold+circuit_breaker_probe_interval_secstoRetryPolicyincrates/config-typesCacheMetricsAdd this agentic workflows to your repo
To install this agentic workflow, run
fix(cache): make circuit-breaker half-open slot release cancellation-…
feat(cache): add per-origin half-open circuit-breaker for pull-through (
docs(cache): correct stale retry-amplification note and pin the circu…