release-21.2: rpc: avoid network IO in Dialer.ConnHealth
#70489
Merged
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.
Backport 1/1 commits from #70017 on behalf of @erikgrinaker.
/cc @cockroachdb/release
Dialer.ConnHealth
is used to check whether a healthy RPC connectionexists to a given node, in order to avoid interacting with unavailable
nodes. However, this actually attempted to dial the node if no
connection was found, which can block for tens of seconds in the case of
an unresponsive node. This is problematic since it is used in
performance-critical code paths, including Raft command application.
This patch changes
Dialer.ConnHealth
to avoid dialing the node, andadds a
Context.ConnHealth
helper with access to the RPC connectionregistry. Because
DistSQLPlanner
relied onConnHealth
to dial theremote node, it also adds
Dialer.ConnHealthTryDial
which retainsthe old behavior for use in DistSQL until a better solution can be
implemented.
Resolves #69888.
Release note (bug fix): Avoid dialing nodes in performance-critical code
paths, which could cause substantial latency when encountering
unresponsive nodes (e.g. when a VM or server is shut down).
Release justification: