Skip to content

fix(cache): cap remote cache uploads, retry transient errors, and use HTTP/1.1 - #1016

Merged
wan9chi merged 9 commits into
chore/bump-url-2.5.9from
t3/c52c4c9f
Nov 26, 2026
Merged

wan9chi merged 9 commits into
chore/bump-url-2.5.9from
t3/c52c4c9f

Conversation

@wan9chi

@wan9chi wan9chi commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Motivation

During remote-caching dogfooding in voidzero-dev/void (2026-11-12 – 2026-11-25), 7 of 208 read-write pushes dropped remote cache uploads and 2 Windows jobs had fetch failures:

  • 3× HTTP status 503 when up to 20 tasks launched remote cache uploads concurrently with no cap against Cloudflare Worker's per-isolate Admission limit (stores = 2, storeWaitMs = 30s).
  • 4× network error uploads and 2× fetch failures (all Windows), including 28 simultaneous fetch failures after a 31s stall alongside a failing upload, because all concurrent fetches, downloads, and uploads multiplexed over a single HTTP/2 connection.
  • No retries on transient 503/429/5xx or network errors.

Changes

  • HTTP/1.1 connection pooling & typed retry hints (crates/vt_remote_cache):
    • Removed reqwest's http2 feature (dropping h2 from Cargo.lock) and enforced .http1_only(), with pool_idle_timeout(30s), reqwest's default 15s TCP keep-alive, and a 10s per-attempt FETCH_TIMEOUT on POST /fetch.
    • Kept vt_remote_cache::Client a thin, single-attempt wire client and surfaced Error::retry_hint() -> RetryHint (Permanent, Transient, RateLimited { retry_after }, Outage) so impossible predicate combinations are unrepresentable.
  • Session-level retries, upload concurrency cap, 429-only cooldowns, and outage circuit breakers (crates/vt/src/session/cache/remote.rs, crates/vt/src/session/cache/remote/retry.rs):
    • Added a per-endpoint Semaphore (MAX_CONCURRENT_STORES = 4) in RemoteEndpoint::store held across retries, bounding burst pressure and open file handles while keeping background uploads cancellable on Ctrl-C.
    • Retries transient network errors and HTTP 408, 429, and 5xx (excluding 501/505/511) with [0.5x, 1.0x] equal jitter: up to 3 retries (60s retry budget) for store, and up to 2 retries (15s retry budget) for fetch and download.
    • Unified download_checked header and mid-stream archive retries in one retry::run loop (passing cancel_token into retry::run so download_once always joins its blocking check task and closes the .tmp handle on cancel; never retrying WriteArchive, CorruptArchive, or cancellation).
    • Separate read and store RateLimit gates honor integer Retry-After (clamped to 10s, floored at the attempt's backoff, with random wake-up spread) only on 429, intentionally ignoring Retry-After on 503.
    • Separate read and store OutageBreakers (modeled with OutagePhase::{Closed, Open, HalfOpen}, opening for 30s after 3 consecutive exhausted outage failures, probing with one single-attempt request, and preserving open state if a probe is cancelled) bound worst-case stalls when an endpoint is down without letting store failures block reads.
  • E2E resilience tests (packages/tools/src/remote-cache, crates/vt_bin/tests/e2e_snapshots/fixtures/remote_cache_resilience):
    • Extended remote-cache-server's tap proxy with per-run fault injection (--fault, --always-fail), a zero-sleep Promise gate (--hold-stores, --release-after-fetches), and --summary output, plus internal VP_RUN_INTERNAL_REMOTE_CACHE_NO_BACKOFF for zero-sleep retries in tests.
    • Added deterministic, zero-sleep e2e cases against the real Cloudflare Worker covering transient retry across fetch/store/blob download, per-kind outage circuit breaking, and the 4-upload concurrency cap.
  • Docs & Changelog: Updated crates/vt_remote_cache/README.md, packages/tools/README.md, and CHANGELOG.md.

Note

Medium Risk
Changes default remote cache networking, concurrency, and failure handling for all read-write users; behavior is heavily tested but mistakes could affect cache hit rates or upload reliability in CI.

Overview
Hardens remote cache traffic after production issues with uncapped upload bursts, HTTP/2 connection sharing, and no retries on transient failures.

The low-level vt_remote_cache client now uses pooled HTTP/1.1 only (dropping the http2 dependency), adds a 10s fetch timeout and 30s pool idle timeout, and exposes Error::retry_hint() so callers can classify failures without embedding retry logic in the wire client.

Session-level orchestration wraps each endpoint in a RemoteEndpoint with at most 4 concurrent uploads, jittered exponential backoff for reads vs stores, shared 429 cooldowns (reads and stores tracked separately), and per-kind outage circuit breakers that can short-circuit with “remote cache temporarily unavailable.” Fetch, blob download, and store paths all flow through a new retry module; downloads retry as a single loop while still joining the archive check task on cancel.

Test and dogfooding support: VP_RUN_INTERNAL_REMOTE_CACHE_NO_BACKOFF for deterministic retries, an expanded remote-cache-server tap (--fault, --always-fail, --hold-stores, --summary), and ignored e2e fixtures for retry, circuit breaking, and upload caps.

Reviewed by Cursor Bugbot for commit 2bdf5b8. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor cursor 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.

Stale Bugbot comment from a previous run.

Comment thread crates/vt/src/session/cache/remote.rs Resolved
Comment thread crates/vt_remote_cache/src/lib.rs Resolved
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

fspy benchmark

linux

dynamic/launch             change  +1.16%  [ -6.21% .. +10.80%]  overhead   +64.18%
dynamic/access             change  +1.19%  [ -6.72% .. +14.00%]  overhead   +20.00%
dynamic/access-relative    change  -1.16%  [ -6.37% ..  +7.28%]  overhead   +71.33%
dynamic/access-contended   change  +0.37%  [-10.94% .. +12.70%]  overhead    +9.43%
static/launch              change  -0.27%  [ -5.85% ..  +5.40%]  overhead  +198.11%
static/access              change  +0.97%  [ -2.23% .. +16.20%]  overhead +1438.10%
static/access-relative     change  +0.78%  [ -2.76% .. +12.67%]  overhead +1921.60%
static/access-contended    change  +0.08%  [ -3.35% ..  +2.04%]  overhead +1975.93%

macos

dynamic/launch             change  +0.47%  [ -2.63% ..  +2.97%]  overhead  +223.14%
dynamic/access             change  -0.42%  [ -3.50% ..  +2.83%]  overhead    +3.70%
dynamic/access-relative    change  -0.12%  [ -2.02% ..  +2.43%]  overhead  +255.10%
dynamic/access-contended   change  +0.59%  [ -1.71% ..  +3.29%]  overhead    +5.32%

windows

dynamic/launch             change  +0.61%  [ -8.02% .. +10.95%]  overhead   +26.89%
dynamic/access             change  -0.34%  [-16.82% .. +14.21%]  overhead    +1.20%
dynamic/access-relative    change  +0.65%  [-11.76% .. +24.12%]  overhead    +1.92%
dynamic/access-contended   change  -1.38%  [-14.92% ..  +9.00%]  overhead    +2.84%

@cursor cursor 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.

Stale Bugbot comment from a previous run.

Comment thread crates/vt_remote_cache/src/lib.rs Resolved
wan9chi and others added 2 commits November 25, 2026 20:07
… HTTP/1.1

Co-authored-by: Gemini 4 Neon <noreply@google.com>
Co-authored-by: Gemini 4 Neon <noreply@google.com>
@wan9chi
wan9chi changed the base branch from main to chore/bump-url-2.5.9 November 25, 2026 12:09
@wan9chi
wan9chi added this pull request to stack #1018 November 25, 2026 12:09
wan9chi and others added 2 commits November 25, 2026 22:04
…cap to vt

Keep vt_remote_cache a single-attempt HTTP/1.1 protocol client that
surfaces retry hints on Error, and own retry, 429 cooldowns, per-kind
outage circuit breakers, upload concurrency capping, and unified
header+stream download retries in vt::session::cache::remote.

Co-authored-by: Gemini 4 Neon <noreply@google.com>
…agePhase enums

Co-authored-by: Gemini 4 Neon <noreply@google.com>

@cursor cursor 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.

Stale Bugbot comment from a previous run.

Comment thread crates/vt/src/session/cache/remote.rs Resolved
wan9chi and others added 4 commits November 25, 2026 22:26
… tests

Co-authored-by: Gemini 4 Neon <noreply@google.com>
…rver tap

Co-authored-by: Gemini 4 Neon <noreply@google.com>
…ut to 10s

Co-authored-by: Gemini 4 Neon <noreply@google.com>
… retry bounds

Co-authored-by: Gemini 4 Neon <noreply@google.com>

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 4b5fb17. Configure here.

Comment thread crates/vt/src/session/cache/remote.rs Resolved
…aker

Co-authored-by: Gemini 4 Neon <noreply@google.com>
@wan9chi
wan9chi merged commit 11c7156 into main Nov 26, 2026
23 checks passed
@wan9chi
wan9chi deleted the t3/c52c4c9f branch November 26, 2026 01:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant