-
Notifications
You must be signed in to change notification settings - Fork 411
Increase the timeout for RPC responses from Bitcoin Core #915
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Increase the timeout for RPC responses from Bitcoin Core #915
Conversation
Codecov Report
@@ Coverage Diff @@
## main #915 +/- ##
==========================================
- Coverage 90.51% 90.47% -0.04%
==========================================
Files 59 59
Lines 29771 29769 -2
==========================================
- Hits 26946 26934 -12
- Misses 2825 2835 +10
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty much LGTM! Nice
8da44a9
to
d0a738e
Compare
Fixed the comments and also added a new commit I'd missed to enable retrying if we actually hit a TCP socket timeout. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One question but either way this looks like an improvement!
let read_res = reader.read_line(&mut line); | ||
match read_res { | ||
Ok(bytes_read) => break bytes_read, | ||
Err(e) if e.kind() == std::io::ErrorKind::WouldBlock => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any other errors we would want to retry on? Like Interrupted
docs https://doc.rust-lang.org/std/io/enum.ErrorKind.html#variant.Interrupted seems to indicate that it can probably be retried
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I don't think you can get an Interrupted in a read on Linux and probably OSX. I'm not really sure what it would even mean in practice - usually it would imply another thread someone sent some signal to interrupt, but in a read not so much.
All that said, maybe it makes sense to just retry everything. Another potential error we could see is a Bitcoin Core RPC queue full error, which would present as just a generic HTTP error.
d0a738e
to
3d3379d
Compare
Redid the first commit to always retry requests instead of checking the error source. |
Early sample testing showed multiple users hitting EWOULDBLOCK/EAGAIN waiting for an initial response from Bitcoin Core while it was doing some long operation (eg UTXO cache flushing). Instead of only waiting 5 seconds for each attempt, we now wait a full two minutes, but only for the first header response, not each byte.
3d3379d
to
4ade6bc
Compare
Squashed fixup commits with no change:
|
Early sample testing showed multiple users hitting
EWOULDBLOCK/EAGAIN waiting for an initial response from Bitcoin
Core while it was doing some long operation (eg UTXO cache
flushing). Instead of only waiting 5 seconds for each attempt, we
now wait a full two minutes, but only for the first header
response, not each byte.