Skip to content

Commit

Permalink
startup: retry pgerror.Code == RangeUnavailable
Browse files Browse the repository at this point in the history
Closes #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›
  • Loading branch information
tbg committed May 31, 2023
1 parent 562f083 commit df97a99
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions pkg/util/startup/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 6 additions & 1 deletion pkg/util/startup/retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}

0 comments on commit df97a99

Please sign in to comment.