Skip to content

node: deliver loop busy-spins after a partial proof credit and wedges the tokio runtime #2132

Closed

Description

@thiras

Component

node (decdn-node daemon)

Version

Testnet binary decdn-node 0.0.0 (BuildID 257f6a5c06c8…). The source analysis below is against main at 2b3d8e47.

Operating system

Ubuntu 26.04 x86_64, DigitalOcean droplets with 2 vCPUs (fra1, lon1)

Steps to reproduce

Observed on the Arbitrum Sepolia testnet. There is no deterministic repro yet. Here is the mechanism, read from the source:

  1. A client opens a paid cdn/client/v1 stream that the node serves from cache, so it goes through ClientHandler::deliver (crates/node/src/handlers/client/delivery.rs:195).
  2. The client answers a completed interval with a proof whose watermark advance is smaller than the interval's delta. credit_advance (crates/node/src/handlers/client/voucher.rs:119) caps the credit at the watermark: credited_bytes = min(paid_credited + delta, watermark) − paid_credited, so 0 < credited_bytes < delta.
  3. The recoup phase takes the credited_bytes > 0 arm (delivery.rs:410). It adds only credited_bytes to paid, but it pops the whole delta from pending (delivery.rs:412). The shortfall delta − credited_bytes stays in delivered − paid, but pending no longer tracks it.
  4. The shortfalls add up. Once delivered − paid ≥ window while pending is empty and next_chunk is still Some, the outer loop at delivery.rs:310 does this on every pass:
    • The deliver phase breaks on the window check before any .await.
    • The recoup phase has nothing to collect, because pending is empty.
    • It calls release_if_repaid(min_payment(paid, rate_per_mb)), and then done is false.
    • The pool/signer re-checks are gated on collected_any (false), and so is the takedown check.
    • The loop goes around again.

No branch awaits, so the task never yields. It spins forever on a tokio worker thread. Every stream that hits this takes one worker. With worker_threads == nproc, two such streams on a 2-vCPU node stall the whole runtime: serving, watchers, logging, and the /metrics endpoint all stop.

The miss path, serve_leg (crates/node/src/handlers/client/serve_leg.rs), has the same pop-the-whole-delta accounting (serve_leg.rs:327). There, the no-progress guard (serve_leg.rs:492) turns the same state into a clean ClientAbandoned stop. deliver has no equivalent guard.

A paying client decides how far each voucher moves the lane watermark. So this state can probably be triggered on purpose: a client can wedge one worker per stream it opens, which is a remote liveness DoS against any node that serves it from cache. Concurrent streams on one lane may also reach it by accident, because they share the watermark.

Expected behavior

  • A proof that credits less than the outstanding interval leaves the unpaid remainder owed. The loop keeps collecting proofs for it, up to MAX_PROOFS_PER_CHUNK, instead of dropping it from pending.
  • No iteration of the serve loop can go around without either making delivery/payment progress or awaiting. An iteration that does neither ends the stream, as serve_leg already does.

Actual behavior

On 2026-09-23, two testnet nodes wedged in this state about 20 minutes apart:

node last log line (UTC) CPU up
fra1 19:47:50 57% at ~19:30 → 100% by ~19:50 0
lon1 20:05:12 56% at ~20:00 → 100% by ~20:15 0
  • CPU rose in steps: one worker at a time locked up, until no worker was left for logging or metrics.
  • systemd still reports decdn-node.service as active/running on both nodes, with NRestarts=0. There was no panic, OOM kill, or exit. Memory was flat.
  • On lon1, top -H shows both tokio-runtime-worker threads at ~100% CPU, with ~2.5 h of CPU time each. perf record -g -t <worker tids> for 10 s gives:
28.65%  ruint::mul::<impl ruint::Uint<_,_>>::overflowing_mul
25.22%  ruint::div::<impl ruint::Uint<_,_>>::div_rem_by_ref
21.96%  decdn_incentive::rate::min_payment
14.42%  decdn_node::handlers::client::dispatch::<impl ClientHandler>::serve_stream::{{closure}}
 7.65%  decdn_node::handlers::client::FloorReservation::release_live_repaid

That is exactly the body of the empty loop: min_payment (U256 mul/div) plus release_if_repaid → release_live_repaid, whose repaid.swap short-circuits and returns at once. Nothing else runs.

The fleet overview dashboard's "Nodes up" (sum(up)) dropped from 7 to 5. That is the only signal, because both nodes look healthy to systemd.

Logs

# fra1 — last decdn-node line before the silence (DEBUG)
2026-09-23T19:47:50.440410Z DEBUG decdn_node::handlers::client::dispatch: client stream ended with error
  error="proof stream read failed: connection lost: peer-side fault"
  span=serve_stream{direction=inbound outcome=failed hash=4e302437…1014 pool_id=0xdb5db181…447d}

# lon1 — last lines (INFO/WARN)
2026-09-23T20:03:26.935876Z INFO  decdn_node::fee_shares_watcher: operator fee share updated from chain bps=6000
2026-09-23T20:05:12.771084Z WARN  decdn_node::payment_settlement: pre-redeem watermark reconciliation failed; submitting on the contract's own no-op guard error="429 Too Many Requests"
# ...then nothing, while the process keeps running at 100% CPU

Proposed fix

  1. Accounting (delivery.rs and serve_leg.rs): on 0 < credited_bytes < delta, subtract credited_bytes from the front pending entry instead of popping it, and pop only once the entry reaches zero. Keep the MAX_PROOFS_PER_CHUNK budget per entry so a payer that keeps crediting slivers still hits the bound.
  2. Liveness (delivery.rs): add the serve_leg no-progress guard to deliver, so an iteration that delivers nothing and credits nothing stops the stream instead of spinning.
  3. Regression test: a deliver stream whose proofs credit partial deltas, capped at the watermark, must either finish fully paid or stop. It must never loop without yielding, which you can check with a tokio::time::timeout on a current_thread runtime.

Operational note: a wedged node looks active to systemd, so nothing restarts it. fra1 and lon1 stay down until someone restarts them by hand.

Activity

  1. added
    kind:bug
    prio:high
    area:node
    area:payments
    on Sep 23, 2026
  2. self-assigned this
    on Sep 23, 2026
  3. moved this from Backlog to In progress in deCDNon Sep 23, 2026
  4. moved this from In progress to Done in deCDNon Sep 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:nodearea:paymentskind:bugprio:high

Type

No type

Fields

Priority

None yet

Projects

  • Status
    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions