Skip to content

cache: an HTTP origin's 5xx is an authoritative absence, and the DHT unschedules on it #1815

Closed

Description

@thiras

Surfaced by review of #1813.

HttpOrigin::size maps every non-success status to Ok(None) (crates/cache/src/origin/http.rs), per the Origin::size contract. So for an HTTP origin a 503 is indistinguishable from a 404 at every layer above it, and probe_origin_chain returns Absent — never Fault.

#1813 made the rescan fault-aware and taught it to carry a faulted candidate forward, which closes the announce-shrink for S3/R2 and the filesystem. It does not close it for HTTP, because HTTP never produces a fault.

Why this is worse than the case #1813 fixed

The rescan is not the only consumer.

  1. Rescan runs while the origin returns 503. Every probe answers Absent, so nothing carries forward and nothing counts — probe_faults == 0, enumerate_failures == 0.
  2. origin_held_size(H) is None, and on an origin-only node cache.has(H) is false.
  3. At H's due tick cache_still_holds is false, so the republisher calls unschedule(&hash) — it stops republishing H entirely, not just for this pass. Only a later rescan that resolves H re-adds it.
  4. Every signal stays green.

The serve gate has the same problem from the other side. handlers/client/dispatch.rs distinguishes Fault from Absent precisely so a transport error never signs an authoritative NotFound — and its comment says so. For an HTTP origin a 503 reaches the Absent arm, the paying client gets a decline indistinguishable from a policy one, and origin_probe_presence memoises that wrong answer under the negative TTL.

Suggested fix

Classify in HttpOrigin::size: Err(Transient) for 5xx/408/429 and for transport failures, Ok(None) for 404 and other 4xx. That is what the OriginPullError split already means everywhere else, and it makes the HTTP adapter agree with the S3 one (classify_head_object_error already does exactly this).

The Origin::size doc contract at crates/cache/src/origin/mod.rs has to change with it, and the callers that currently rely on "any non-success degrades to absent" need checking — the range-pull degrade path in particular.

Related

cache_still_holds (crates/node/src/dht/publish.rs) also folds a store error into "no longer held" via unwrap_or(false) and unschedules on it. That is the same shape — a fault treated as eviction evidence — and worth fixing alongside: a store fault should keep the hash scheduled, not drop it. It is also strictly worse than the store-walk failure #1813 meters, since that one only fails to add.

Activity

  1. added
    rust
    on Aug 24, 2026
  2. moved this from Backlog to In progress in deCDNon Aug 25, 2026
  3. moved this from In progress to Done in deCDNon Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

rust

Type

No type

Fields

Priority

None yet

Projects

  • Status
    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions