From df97a99ccf030e609e66e44f61dd11fec93b5fdd Mon Sep 17 00:00:00 2001 From: Tobias Grieger Date: Wed, 31 May 2023 10:22:20 +0200 Subject: [PATCH] startup: retry pgerror.Code == RangeUnavailable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes https://github.com/cockroachdb/cockroach/issues/104016. Epic: None Release note (bug fix): a bug was fixed due to which nodes could terminate with the following message: server startup failed: cockroach server exited with error: ‹migration-job-find-already-completed›: key range id:X is unavailable: ‹failed to send RPC: no replica node information available via gossip for rX› --- pkg/util/startup/BUILD.bazel | 2 ++ pkg/util/startup/retry.go | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/util/startup/BUILD.bazel b/pkg/util/startup/BUILD.bazel index 2acaeccc2236..b2ea7e9b190f 100644 --- a/pkg/util/startup/BUILD.bazel +++ b/pkg/util/startup/BUILD.bazel @@ -8,6 +8,8 @@ go_library( visibility = ["//visibility:public"], deps = [ "//pkg/kv/kvpb", + "//pkg/sql/pgwire/pgcode", + "//pkg/sql/pgwire/pgerror", "//pkg/util", "//pkg/util/log", "//pkg/util/retry", diff --git a/pkg/util/startup/retry.go b/pkg/util/startup/retry.go index 45fc3b529942..d1fe9abfb945 100644 --- a/pkg/util/startup/retry.go +++ b/pkg/util/startup/retry.go @@ -60,6 +60,8 @@ import ( "time" "github.com/cockroachdb/cockroach/pkg/kv/kvpb" + "github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgcode" + "github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgerror" "github.com/cockroachdb/cockroach/pkg/util" "github.com/cockroachdb/cockroach/pkg/util/log" "github.com/cockroachdb/cockroach/pkg/util/retry" @@ -206,5 +208,8 @@ func inStartup() bool { // IsRetryableReplicaError returns true for replica availability errors. func IsRetryableReplicaError(err error) bool { - return errors.HasType(err, (*kvpb.ReplicaUnavailableError)(nil)) || errors.HasType(err, (*kvpb.AmbiguousResultError)(nil)) + return errors.HasType(err, (*kvpb.ReplicaUnavailableError)(nil)) || + errors.HasType(err, (*kvpb.AmbiguousResultError)(nil)) || + // See https://github.com/cockroachdb/cockroach/issues/104016#issuecomment-1569719273. + pgerror.GetPGCode(err) == pgcode.RangeUnavailable }