Repository navigation
fix(node,cache,dht): close the three #1813 review follow-ups - #1819
Merged
Merged
Conversation
Three fixes surfaced by review of #1813: - dht: run the lag-sweep walk in its own task and await the join, so a panic inside the store walk surfaces as JoinError::is_panic instead of unwinding through the worker. The worker then takes its normal release path, which consumes a queued sweep request rather than discarding it, and meters the panic on decdn_dht_republish_lag_sweep_panics_total (#1814). - cache: classify HttpOrigin::size statuses instead of degrading every non-success to Ok(None): 404 stays an authoritative absence, 5xx/408/429 surface as Transient faults, and other non-success statuses as Permanent — mirroring the S3 adapter's classify_head_object_error. An HTTP origin mid-outage now reads as Fault at every layer above, so the serve gate no longer signs an authoritative NotFound for it, the probe memo no longer caches it as an absence, and the DHT republisher no longer unschedules the hash. The due-time gate likewise treats a store query fault as unknown — the hash stays scheduled — instead of folding it into "no longer held" and unscheduling (#1815). - dht: route every acquisition of the routing-table mutex through the poison-recovering with_lock — the FindNode/FindValue closest_to answer, the handler's note_peer_seen refresh, the bucket-refresh walk, and both bootstrap inserts — so a single panic no longer leaves the query path answering every lookup from an empty table while the republisher keeps working (#1816). Closes #1814. Closes #1815. Closes #1816. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vftbs9Ckm4hHbZrDW4ksgD
There was a problem hiding this comment.
Pull request overview
This PR closes the three follow-ups from review of #1813 by hardening DHT republish sweep behavior against panics, correcting HTTP-origin HEAD/size semantics so outages are not treated as authoritative absence, and unifying routing-table poison recovery across republisher and request paths.
Changes:
- Prevent lag-sweep panics from discarding queued sweep passes by running each sweep walk in an inner task and branching on
JoinError::is_panic, plus adding a new panic counter. - Reclassify HTTP origin
sizeresponses so only 404 yieldsOk(None)while outages (5xx/408/429) and other non-success statuses becomeOriginPullError(transient vs permanent), and update theOrigin::sizecontract/docs accordingly. - Route all remaining routing-table
Mutexacquisitions throughchain_projection::with_lockto consistently recover from poison and avoid “split-brain” behavior.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| crates/node/src/metrics.rs | Adds a new counter for lag-sweep walk panics and wires a recorder for it. |
| crates/node/src/handlers/dht.rs | Uses poison-tolerant with_lock for routing-table access in handler hot paths. |
| crates/node/src/dht/publish.rs | Refactors lag-sweep worker loop to isolate panics via join handling; fixes due-time gate to treat store faults as unknown; adds tests for both behaviors. |
| crates/node/src/dht/mod.rs | Widens chain_projection module visibility to allow handler reuse of the recovery helper. |
| crates/node/src/dht/chain_projection.rs | Widens with_lock visibility to pub(crate) and documents why all sites should share the same recovery idiom. |
| crates/node/src/dht/bucket_refresh.rs | Replaces raw routing-table Mutex locks with with_lock in refresh flows. |
| crates/node/src/dht/bootstrap.rs | Replaces raw routing-table Mutex locks with with_lock and preserves insertion counting. |
| crates/cache/src/origin/mod.rs | Updates the Origin::size contract to make Ok(None) authoritative absence and require faults to be surfaced as OriginPullError. |
| crates/cache/src/origin/http.rs | Reclassifies HEAD status handling for size (404 → Ok(None), outage statuses → transient error, other non-success → permanent error) and adds focused tests. |
| crates/cache/src/engine.rs | Updates documentation to reflect the new Origin::size semantics (no longer treating outages as absence). |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Coverage reportTotal: 82.01% (was 80.30%, ▲ +1.71%) — 67350/82126 lines
History
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
One PR for the three follow-ups surfaced by review of #1813.
Closes #1814. Closes #1815. Closes #1816.
#1814 — a panic inside a lag sweep no longer discards a queued pass
The sweep worker now runs each walk in an inner
tokio::spawnand awaits theJoinHandle, so a panic inside the store walk (iroh-blobs sits outside the workspace anti-panic lints) surfaces asJoinError::is_panicinstead of unwinding through the worker. The worker then takes its normal release path: the release compare-exchange fails if a request was queued mid-walk, and the worker consumes it with a further pass rather than dropping it throughSweepSlotGuard. This is the same join-and-branch pattern the runtime, admin, and buyer-channel layers already use.spawn_lag_sweepandSweepSlotGuardupdated to match.decdn_dht_republish_lag_sweep_panics_total— a sweep that panics every pass would otherwise only show up as a flatsweep_reseeded_total.run_sweep_workerto keep the slot-claim protocol and the worker loop separately readable.sizeblocks on a semaphore and then panics lets the test queue a second pass behind a running walk, then open the gate — both passes run (two metered panics) and the slot ends idle.#1815 — an HTTP origin's 5xx is no longer an authoritative absence
HttpOrigin::sizenow classifies statuses the wayfetchand the S3 adapter'sclassify_head_object_erroralready do, instead of degrading every non-success toOk(None):Ok(None)(authoritative absence, as before);Err(Transient);Err(Permanent).The issue's suggested-fix sketch had non-404 4xx degrading to
Ok(None); this PR instead matchesclassify_head_object_errorexactly (which the same issue names as the model), because a 403 folded into an absence has the same failure shape as the 503 — the serve gate would sign an authoritativeNotFoundfor it. AsPermanent, it reaches the probe chain as a non-carry-forwardFault, so the rescan still drops it from the announce set after one pass, matching S3.Consequences at the layers above, with no changes needed there:
probe_origin_chainnow answersFault(transient-flagged for the outage statuses) instead ofAbsent, so the origin-only serve gate answersInternalErrorinstead of signingNotFound, the probe memo no longer caches an outage under the negative TTL, the fault-aware rescan carries the candidate forward, and the republisher no longer callsunschedulefor it. The best-effort range-scope caller (CacheEngine::origin_size) already swallows per-origin errors and degrades to a whole-blob fetch, so the range-pull degrade path is unchanged. TheOrigin::sizedoc contract and the two doc comments that described the old HTTP quirk (origin_probe_presence,rescan_origins) are updated.The related
cache_still_holdsshape from the issue is fixed too: it now returnsOption<bool>, and the tick path treats a store fault as unknown — the hash is re-scheduled with a fresh steady-state draw and skipped for this cycle's publish — instead ofunwrap_or(false)unscheduling it for the process lifetime.New tests pin
size's 404/503/403/200 classification (wiremock) and the store-fault-is-unknown gate.#1816 — routing-table poison recovery is one idiom again
All four remaining raw acquisitions of the routing-table
Mutexnow go throughchain_projection::with_lock(which clears poison as it recovers, so the warn is one line per panic, not one per request):handlers/dht.rsclosest_to— no longer answers every inboundFindNode/FindValuefrom an empty table after a panic; the "honest at this moment" comment is replaced, since an empty answer from a poisoned guard is an assertion about the table's contents the code cannot make;handlers/dht.rsnote_peer_seen— no longer silently drops every learned peer;dht/bucket_refresh.rs— both the pick snapshot and the response-learned inserts;dht/bootstrap.rs— both the seed step and the closer-nodes inserts.with_lockwidens frompub(super)topub(crate)(and thechain_projectionmodule topub(crate)) so the handler can share the one recovery idiom; the record-store lock sites in the handler are untouched, as the issue scopes this to the routing table.Validation
cargo build,cargo clippy --all-targets(no warnings),cargo fmt -- --check, fulldecdn-cachetest suite,decdn-nodelib tests (750 passed), and theorigin_range_pullintegration suite all pass locally.🤖 Generated with Claude Code
https://claude.ai/code/session_01Vftbs9Ckm4hHbZrDW4ksgD
Generated by Claude Code