Skip to content

fix(daemon): retry when bitcoind's RPC work queue is full - #271

Open
shanurwan wants to merge 1 commit into
Blockstream:new-indexfrom
shanurwan:fix/retry-busy-daemon
Open

shanurwan wants to merge 1 commit into
Blockstream:new-indexfrom
shanurwan:fix/retry-busy-daemon

Conversation

@shanurwan

Copy link
Copy Markdown

When bitcoind's RPC work queue (-rpcworkqueue) is full, it answers HTTP 503 with the body Work queue depth exceeded. into_jsonrpc_body only accepts 200 and 500, so the 503 became a plain error, retry_request returned it instead of retrying, and electrs exited:

ERROR server failed: Error: request failed "HTTP/1.1 503 Service Unavailable": ... = "Work queue depth exceeded"

I hit this on testnet4 with bitcoind started with -rpcworkqueue=2 -rpcthreads=1 while other clients called getblock. It happened on both runs.

A busy bitcoind recovers once its queue drains, so this maps 503 to ErrorKind::Connection. The singleton path then waits, reconnects and retries, as it already does during warmup (-28), and the client path reports the daemon as unavailable.

Test: recv_treats_a_full_work_queue_as_a_connection_error fails without the change and passes with it. All daemon tests pass.

Related: #245.

When -rpcworkqueue is full, bitcoind answers HTTP 503 with the body
"Work queue depth exceeded". into_jsonrpc_body turned every status other
than 200 and 500 into a plain error, so retry_request returned it instead
of retrying, and electrs exited:

  ERROR server failed: Error: request failed "HTTP/1.1 503 Service
  Unavailable": ... = "Work queue depth exceeded"

Seen on testnet4 with bitcoind started with -rpcworkqueue=2 -rpcthreads=1
while other clients called getblock. A busy bitcoind recovers once its
queue drains, so treat 503 like a dropped connection: the singleton path
waits, reconnects and retries, as it does during warmup (-28), and the
client path reports the daemon as unavailable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant