Skip to content

rs-dapi-client: burst of ordinary TCP timeouts can ban the whole address pool, surfacing a raw transport error instead of a structured exhaustion error #4141

Open

Description

@lklimek

Expected Behavior

When several DAPI addresses are briefly unreachable at once (e.g. plain TCP connect timeouts — no protocol/proof violation), the client should either avoid banning on such a mild, common failure, or — if the whole live pool empties anyway — return a single, structured "address pool exhausted" error every time, so downstream consumers can show an accurate "temporarily unreachable, will recover" message instead of guessing from message text.

Current Behavior

rs_dapi_client bans an address immediately on any transport failure, including an ordinary TCP connect timeout to a node that may simply be slow or briefly offline:

DEBUG request routine: rs_dapi_client::dapi_client: received error: grpc error: code: 'The service is currently unavailable', message: "tcp connect error", source: tonic::transport::Error(Transport, ConnectError(ConnectError("tcp connect error", 52.12.176.90:1443, Custom { kind: TimedOut, error: Elapsed(()) })))
 WARN request routine: rs_dapi_client::dapi_client: ban address https://52.12.176.90:1443/ due to error: transport error: ...
 WARN request routine: rs_dapi_client::dapi_client: retrying error with sleeping 0.01 secs ...

If enough addresses get banned in a short window, the whole configured pool empties:

ERROR rs_dapi_client::dapi_client: request failed error=ExecutionError { inner: NoAvailableAddresses, retries: 0, address: None }
 WARN platform_wallet::manager::platform_address_sync: Platform address sync failed for wallet <id>: SDK error: Dapi client error: no available addresses to use
...
DEBUG request routine: rs_dapi_client::dapi_client: no addresses available, returning last transport error

The key issue: that last line. When the pool empties, the client sometimes returns ExecutionError { inner: NoAvailableAddresses, .. } (structured, easy to detect), but at other times returns whichever raw single-node transport error happened to be last (e.g. Transport(Grpc(Status { code: Unavailable, message: "tcp connect error", ... }))), indistinguishable at the call site from an ordinary single-node hiccup. A downstream consumer (Dash Evo Tool) confirmed 8 such terminal exhaustion episodes in one real session log, all occurring after its local masternode list was already fully synced — this is a steady-state condition under real-world node flakiness, not a startup-window race.

Possible Solution

  • Reconsider banning an endpoint for every plain TCP connection timeout — use failure classification, backoff, or a circuit-breaker policy suited to a temporarily slow/offline node, rather than an immediate ban on first failure.
  • When address selection exhausts the live pool, always return the structured pool-exhaustion error (carrying the last transport error as its source) — never fall through to exposing only the raw final transport failure.
  • Expose typed timeout/refusal causes on the public error so downstream applications don't need to pattern-match gRPC status message strings to classify a failure.
  • Consider a way for long-running consumers (e.g. platform-wallet's background sync coordinators) to back off/pause while the address pool is exhausted, instead of repeatedly querying an empty pool.
  • Related prior art: feat(dapi): add background health check for DAPI nodes #3353 ("feat(dapi): add background health check for DAPI nodes") targeted a related problem (stale/dead nodes lingering in the pool) with startup + ban-expiry re-probing, but was closed unmerged. It doesn't fully cover this case (a sudden correlated burst of timeouts across still-recently-healthy nodes between health-check cycles), but may be a useful starting point to revisit.

Steps to Reproduce (for bugs)

Not a minimal isolated repro — observed from a real session log. General pattern:

  1. Run a client against mainnet/testnet with a non-trivial configured address pool.
  2. Have several of those addresses become briefly unreachable at roughly the same time (real-world network conditions; no special trigger needed — happened organically in the field).
  3. Concurrent in-flight DAPI calls each independently ban their target address on the first transport failure.
  4. If the bans collectively cover the whole live pool before any expire, subsequent calls fail with either NoAvailableAddresses or a raw single-node transport error, inconsistently.

Context

Downstream, Dash Evo Tool users saw a generic "Could not reach a Dash network server. Please retry." banner during what was actually a temporary, self-recovering condition, with no indication it would resolve on its own. DET has landed a client-side mitigation that detects pool exhaustion via get_live_addresses()/address_list().len() and reclassifies the error into a clearer message (dashpay/dash-evo-tool#904), but the underlying ban-on-any-failure policy and the inconsistent final-error shape live here in rs-dapi-client.

Your Environment

🤖 Co-authored by Claudius the Magnificent AI Agent

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