Skip to content

bitreq: Client connection pool retains dead connections indefinitely on I/O error #562

@paratoxick

Description

@paratoxick

bitreq::Client caches Arc<AsyncConnection> by host+port in a HashMap and
never evicts an entry, never revalidates before reuse, and never replaces an
entry on error. Once a pooled socket is dead (e.g. closed by the peer after an
idle timeout, or reset), the pool hands out the same dead Arc to every
subsequent caller for that key, permanently — until the process restarts.

Because send_async returns the underlying error to the caller without
touching the pool, retry logic in downstream crates is defeated: each retry
calls send_async again, gets the same Arc<AsyncConnection> back, and fails
on the same dead socket.

We hit this in a bitcoin RPC client (bitcoind-async-client 0.10.x, which now
uses bitreq) talking to a local bitcoind. After ~30 seconds of idle, bitcoind
closes the RPC socket per its rpcservertimeout. The next request fails, and
then all subsequent requests fail indefinitely — even though a fresh TCP
connection to the same port succeeds instantly. Only restarting the client
process recovers.

  • bitreq 0.3.4 (latest as of writing)
  • observed via bitcoind-async-client 0.10.2 against bitcoind 29.x on Linux

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