RPC level Timeout feature #19708

issue NicolasDorier opened this issue on August 13, 2020
  1. NicolasDorier commented at 11:55 AM on August 13, 2020: contributor

    We had an instance of a single RPC request blocking for a while. I suspect it was because the RPC client socket got closed ungracefully and the RPC request's reply was just blocking there until the server eventually dropped the socket. (probably a network related problem)

    The problem is that while the request was blocking, other requests got queued in the RPC queue for processing. But those requests failed to be processed before the other clients timeout, because of the first RPC request blocking all processing until the socket timeout.

    Some of those requests were not idempotent (like sendtoaddress). The caller of this request, not seeing any response from in a certain timeout, assumed the request failed, however this request got eventually processed once the RPC queue started getting processed again. The caller, assuming sendtoaddress failed, made another request, essentially sending twice.

    rpcservertimeout is only referring to the timeout it takes to read the HTTP request, but HTTP requests get read immediately and queued in the RPC queue. Once queued, bitcoin core makes no check after dequeuing the request that it got timed out.

    I was thinking, the best way to solve this is to have a timeout at RPC protocol level, that clients can specify in the RPC request. When bitcoin core unqueue the request from the rpc queue, it can check if the request expired and not running it if that's the case.

    What do you think about such solution? I agree this is to solve a corner case issue, but nevertheless this issue could have resulted in loss of funds, and I need to find a way so it does not happen again.

  2. NicolasDorier added the label Feature on Aug 13, 2020
  3. fanquake added the label RPC/REST/ZMQ on Aug 13, 2020
  4. NicolasDorier commented at 12:05 PM on August 13, 2020: contributor

    Another way to have solved the problem is to make sure the next RPC request can be dequeued as soon as the previous has been executed, and before the reply got sent back to the client.

    We were running 0.17.0

  5. tryphe commented at 7:31 AM on September 16, 2020: contributor

    Light concept ACK, in favor of getting rid of weird behavior, though unsure about the best implementation and implications. Slight concerns: other programs and scripts might now rely on blocking behavior(maybe?), perhaps allow a timeout=0 to keep the current behavior, but warn/document against using it.


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-13 15:14 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me