Skip to content

dht: the detached lag sweep races cache.shutdown() and fires a failure counter on a clean restart #1809

Closed

Description

@thiras

Surfaced by the review of #1806 (issue #1561).

The lag sweep is a bare tokio::spawn with no handle, holding a CacheEngine clone. run_republish returns as soon as republish_stop_tx fires and never joins it (crates/node/src/dht/publish.rs).

Shutdown ordering in crates/node/src/runtime/mod.rs:

  • :2414 — republish_stop_tx.send(()), so run_republish returns
  • :2554 — cache.shutdown().await

A sweep still inside iter_hashes() at that point sees the store go away, takes the Err branch, and:

  • increments decdn_dht_republish_seed_store_walk_failures_total, a live row in adr/appendix-observability.md
  • emits warn!("... could not walk the store; re-seeding the origin-held half only ...")

on an ordinary, clean restart. That is an alertable counter firing on a non-event, which is the fastest way to teach an operator to ignore it.

The window is small (it needs a lag sweep in flight at shutdown) but the store walk is one status() per blob, so on a large cache it is seconds to minutes wide.

Suggested fix

Either:

  1. Pass the stop signal into the sweep and select! against it, so a shutdown abandons the walk without classifying it as a degradation; or
  2. Suppress the failure counter and the warn once shutdown has begun.

(1) is preferable — it also stops the sweep from holding the CacheEngine alive past the drain, which is the same teardown shape as #1779.

The code comment already acknowledges the abandonment ("Abandoned on shutdown — the next lag, or the next boot, re-seeds") but not the false-signal side effect.

Activity

  1. added
    rust
    prio:low
    on Aug 24, 2026
  2. self-assigned this
    on Aug 24, 2026
  3. moved this from Backlog to In progress in deCDNon Aug 24, 2026
  4. 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

prio:lowrust

Type

No type

Fields

Priority

None yet

Projects

  • Status
    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions