Repository navigation
chainreg: a node shutting down or overloaded is unreachable, not on another chain - #34
Merged
Merged
Conversation
…nother chain Follow-up to #31, from a review of the release. A bitcoind that is shutting down, or whose RPC work queue is full, answers with an HTTP 5xx and a plain-text body, which rpcclient turns into "status code: 503, response: ...": neither a btcjson.RPCError nor a net.Error, so the re-check took it for a node on another chain and stopped lnd at once. That is the restart #31 is for, landing on the tick while the node stops rather than while it warms up. A reply cut off mid-read ("error reading json reply", its cause formatted away with %v) was classed the same way. Both are now waited for like any other silence; a 4xx still is not. The test for an answer from another chain now fails within 5 s instead of hanging until the test timeout if that answer were ever waited on.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #31, found in the review of 0.21.8-beta-blake2b.24.1.
Problem
A bitcoind that is shutting down, or whose RPC work queue is full, answers RPC with an HTTP 5xx and a plain-text body ("Request rejected during server shutdown", "Work queue depth exceeded"). rpcclient (
rpcclient/infrastructure.go:874in btcd-blake2b v0.25.1-blake2b.9) turns that intofmt.Errorf("status code: %d, response: %q", ...), which is neither a*btcjson.RPCErrornor anet.Error, sonodeUnreachablereturned false and the re-check reported a chain mismatch at once. That is the restart #31 is for, landing on the 5-minute tick while the node stops rather than while it warms up. A reply cut off mid-read comes back aserror reading json reply: %v, with theio.ErrUnexpectedEOFformatted away, and was classed the same way.Change
nodeUnreachablealso returns true for errors whose text starts withstatus code: 5orerror reading json reply:. A 4xx (a refused password) is still not waited for: the node answered, and lnd cannot use it. A node on another chain still answers with a wrong header or an RPC error and is reported on the first answer.The "another chain is never waited for" test now fails within 5 s if that answer were waited on, instead of hanging until the test timeout (the grace there is an hour).
Tests
go test -race ./chainreg/passes; removing the new branch failsTestNodeUnreachable.