forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cli: fix use of canceled connection in
init
The implementation of `./cockroach init` first dials up the node (in a retry loop) and issues a `Health` RPC, to reduce the likelihood of accidental double-init of the cluster in case of network issues. However, this was trying to be too clever: if it managed to dial the node and check its health (again, using a short-lived context), it would then return that same connection to the caller for use in the Bootstrap RPC. Unfortunately, that connection would sit on top of an `rpc.Context` whose life was tied to a context[^1] that descended from one wrapped by `RunWithTimeout`. In other words, the context would be cancelled by the time the health check method returned. This seems to not cause issues today, since the `rpc.Context` seems to ignore this context cancellation. But in cockroachdb#88625, this suddenly became a problem and now that I've looked at this code, might as wel fix it regardless of whether cockroachdb#88625 is ever going to land. No release note since today's code happens to work. [^1]: https://github.com/cockroachdb/cockroach/blob/aecc58f125ac611f5793101cbd0323df569369db/pkg/cli/rpc_client.go#L46 Release note: None
- Loading branch information
Showing
1 changed file
with
36 additions
and
48 deletions.
There are no files selected for viewing
This file contains 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