From 5033bb4aadace5f649b6e87a7581f11bfd7aeaf8 Mon Sep 17 00:00:00 2001 From: Aditya Maru Date: Thu, 28 Apr 2022 20:10:06 -0400 Subject: [PATCH] joberror: add ConnectionReset/ConnectionRefused to retryable err allow list Bulk jobs will no longer treat `sysutil.IsErrConnectionReset` and `sysutil.IsErrConnectionRefused` as permanent errors. IMPORT, RESTORE and BACKUP will treat this error as transient and retry. Release note: None --- pkg/jobs/joberror/BUILD.bazel | 1 + pkg/jobs/joberror/errors.go | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pkg/jobs/joberror/BUILD.bazel b/pkg/jobs/joberror/BUILD.bazel index 2b6cac7e92bd..5774616a65ae 100644 --- a/pkg/jobs/joberror/BUILD.bazel +++ b/pkg/jobs/joberror/BUILD.bazel @@ -10,6 +10,7 @@ go_library( "//pkg/sql/flowinfra", "//pkg/util/circuit", "//pkg/util/grpcutil", + "//pkg/util/sysutil", "@com_github_cockroachdb_errors//:errors", ], ) diff --git a/pkg/jobs/joberror/errors.go b/pkg/jobs/joberror/errors.go index 40f3b36ce3f4..7d2d7a76d0a9 100644 --- a/pkg/jobs/joberror/errors.go +++ b/pkg/jobs/joberror/errors.go @@ -17,6 +17,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/flowinfra" "github.com/cockroachdb/cockroach/pkg/util/circuit" "github.com/cockroachdb/cockroach/pkg/util/grpcutil" + "github.com/cockroachdb/cockroach/pkg/util/sysutil" "github.com/cockroachdb/errors" ) @@ -45,9 +46,9 @@ func isBreakerOpenError(err error) bool { } // IsPermanentBulkJobError returns true if the error results in a permanent -// failure of a bulk job (IMPORT, BACKUP, RESTORE). This function is a allowlist -// instead of a blocklist: only known safe errors are confirmed to not be -// permanent errors. Anything unknown is assumed to be permanent. +// failure of a bulk job (IMPORT, BACKUP, RESTORE). This function is an +// allowlist instead of a blocklist: only known safe errors are confirmed to not +// be permanent errors. Anything unknown is assumed to be permanent. func IsPermanentBulkJobError(err error) bool { if err == nil { return false @@ -57,5 +58,7 @@ func IsPermanentBulkJobError(err error) bool { !grpcutil.IsClosedConnection(err) && !flowinfra.IsNoInboundStreamConnectionError(err) && !kvcoord.IsSendError(err) && - !isBreakerOpenError(err) + !isBreakerOpenError(err) && + !sysutil.IsErrConnectionReset(err) && + !sysutil.IsErrConnectionRefused(err) }