Skip to content

dash-spv: one route() call keeps picking a peer whose write just stalled #1237

Open

Description

@xdustinface

All paths are under dash-spv/src/ at 8dde9d0c (dev after #902).

Broker::route (network/broker.rs:258-273) picks peers from a fixed snapshot and only checks in_flight_bytes() < cap(). PeerHandle::send (network/peer.rs:179-195) never checks token.is_cancelled(). On a write timeout it cancels the token, which only stops the reader, and the failed send keeps its charge. So a peer that stopped reading stays selectable for the rest of the call until failed charges fill its cap, and each pick costs WRITE_TIMEOUT (5s). The router is a single loop, so nothing else is sent meanwhile. hedge plans its sends before making any (network/broker.rs:332-345) and can aim several at the same dead peer.

Evidence. A throwaway test with a fake TCP peer that completes the handshake and then never reads, 16 queued block getdatas and a full send buffer:

single peer: route() took 40.02s sent=0 requeued=16 stalled_picks=8
stalled + healthy peer: route() took 40.02s sent=8 requeued=8 stalled_picks=8 healthy_picks=8

With a healthy second peer, the dead one still takes every other pick and half the batch is re-queued instead of sent.

Fix. Return an error from send at once when the token is cancelled, or drop a peer from the candidate set for the rest of route and hedge after its first failed send.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions