Skip to content

dht: RepublishScheduler swallows mutex poison at every lock site #1808

Closed

Description

@thiras

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

Every lock site in RepublishScheduler (crates/node/src/dht/publish.rs) swallows a poisoned Mutex:

Line Site On poison
160 len() reports 0
166 is_empty() reports true
217, 220 schedule_with_offset no-op
240 schedule_if_absent returns false (logs error! since #1806)
264 drain_due returns empty
291 unschedule no-op

Mutex poison is sticky, so one panic inside any guarded region converts the scheduler into a black hole for the process lifetime: nothing is ever scheduled, nothing is ever drained, and the node silently stops advertising every hash it holds. It keeps serving, probing and settling payments normally, so all liveness signals stay green while it falls out of content discovery and its earnings decay.

Why this is worth fixing rather than leaving

The crate already has the right convention one module over. crates/node/src/dht/chain_projection.rs provides with_read/with_write, which warn! and recover via PoisonError::into_inner, with a test at accessors_recover_a_poisoned_lock. capacity_bond_registry.rs routes every lock through it, and the workspace Cargo.toml names dht::chain_projection as the canonical poison-recovery layer. publish.rs is the outlier.

Recovery is safe here. The invariant is "scheduled mirrors the heap"; drain_due already tolerates a heap entry absent from scheduled, and schedule_with_offset already tolerates the converse. A torn state degrades to a spurious or a skipped republish, not corruption.

Suggested fix

Add Mutex analogues of with_read/with_write (or extend chain_projection to cover Mutex) and route all seven sites through them, recovering with into_inner plus a warn!.

#1806 added an error! to schedule_if_absent only, because that site's false return newly flows into an operator-visible count — a poisoned lock there is indistinguishable from a healthy no-op sweep. The other six are still silent.

Activity

  1. added
    prio:medium
    rust
    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:mediumrust

Type

No type

Fields

Priority

None yet

Projects

  • Status
    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions