Skip to content

cache: mid-stream origin errors no longer feed retry classification (regression vs pre-streaming HttpOrigin) #519

Closed

Description

@thiras

Problem

Pre-#271, `HttpOrigin::fetch` collected the response body inside its async block, so transport-layer body errors (idle timeout, mid-body connection reset, S3 `ByteStream::collect` failures) flowed through `classify_reqwest_error` / `classify_get_object_error` and were classified `Transient` vs `Permanent`. `retry_fetch` then retried transients up to `cache.origin_retry.max_retries`.

Post-#271, body errors emerge from the streaming pipeline as `io::Error` after `fetch` returned `Ok` and `retry_fetch` already exited. They surface to the engine via the side-channel and become a generic `CacheError::OriginError` (or typed `BlobTooLarge` / `DecompressionFailed` for the relevant cap/decoder cases) — but never participate in transient/permanent retry classification.

The `OriginByteStream` doc at `crates/cache/src/origin/mod.rs` admits this explicitly: "They do not feed `retry_fetch`'s transient/permanent classification."

Operator-visible impact

Why not fixed in #271

Restoring mid-stream retry would need engine-level "abort the partially-imported `TempTag`, drop the incoming stream, replay `origin.fetch` from scratch" logic. The first attempt already pushed bytes into iroh-blobs, so the second attempt has to either:

a) Tolerate the half-committed blob and not re-commit (requires de-dupe at the store layer), or
b) Drop the half-committed blob explicitly (no public iroh-blobs API to delete pre-named blobs; depends on #518's GC).

Either way: out of scope for the streaming memory-fix that #271 was filed for.

Acceptance

  • Decide policy: retry-on-mid-stream-transient is an opt-in feature with a documented disk-amplification cost (each attempt strands its partial bytes until GC runs).
  • Implement a retry wrapper that bypasses `add_stream` on the first attempt, collects the body, and only commits to iroh-blobs once the whole body is verified — bringing back pre-cache: FilesystemOrigin.fetch reads the entire blob into memory before returning Bytes, preventing streaming delivery to the client for large blobs #271 retry semantics for small blobs at the cost of memory.
  • Or: implement mid-stream abort + restart with a counter-bounded budget that's smaller than the regular retry budget.
  • Tests: HTTP body mid-stream reset now retries up to `max_retries`; assertion on dispatch count.

Related

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind:bugprio:medium

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions