Skip to content

chainreg: a node shutting down or overloaded is unreachable, not on another chain - #34

Merged
paulscode merged 1 commit into
blake2bfrom
chain-check-5xx
Nov 20, 2026
Merged

paulscode merged 1 commit into
blake2bfrom
chain-check-5xx

Conversation

@paulscode

Copy link
Copy Markdown
Owner

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:874 in btcd-blake2b v0.25.1-blake2b.9) turns that into fmt.Errorf("status code: %d, response: %q", ...), which is neither a *btcjson.RPCError nor a net.Error, so nodeUnreachable returned 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 as error reading json reply: %v, with the io.ErrUnexpectedEOF formatted away, and was classed the same way.

Change

nodeUnreachable also returns true for errors whose text starts with status code: 5 or error 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 fails TestNodeUnreachable.

…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.
@paulscode
paulscode merged commit 1055c33 into blake2b Nov 20, 2026
4 of 5 checks passed
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