From 740e0cac646825c45b59205eda88c1a89eb5ae1d Mon Sep 17 00:00:00 2001 From: Faizan Qazi Date: Wed, 12 Oct 2022 19:36:45 +0000 Subject: [PATCH 1/2] sql: remove debug code for unknown schema errors Fixes: #89859 In a previous PR some debug code was accidentally introduced for unknown schema errors. These changes remove that debug code. Release note: None --- pkg/sql/sqlerrors/BUILD.bazel | 1 - pkg/sql/sqlerrors/errors.go | 5 ----- 2 files changed, 6 deletions(-) diff --git a/pkg/sql/sqlerrors/BUILD.bazel b/pkg/sql/sqlerrors/BUILD.bazel index a6e8286bfd3f..137805b78e33 100644 --- a/pkg/sql/sqlerrors/BUILD.bazel +++ b/pkg/sql/sqlerrors/BUILD.bazel @@ -13,7 +13,6 @@ go_library( "//pkg/sql/pgwire/pgerror", "//pkg/sql/sem/tree", "//pkg/sql/types", - "//pkg/util/log", "@com_github_cockroachdb_errors//:errors", ], ) diff --git a/pkg/sql/sqlerrors/errors.go b/pkg/sql/sqlerrors/errors.go index 63317a023fc5..849d2d5f601d 100644 --- a/pkg/sql/sqlerrors/errors.go +++ b/pkg/sql/sqlerrors/errors.go @@ -12,16 +12,12 @@ package sqlerrors import ( - "context" - "runtime/debug" - "github.com/cockroachdb/cockroach/pkg/roachpb" "github.com/cockroachdb/cockroach/pkg/sql/catalog/descpb" "github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgcode" "github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgerror" "github.com/cockroachdb/cockroach/pkg/sql/sem/tree" "github.com/cockroachdb/cockroach/pkg/sql/types" - "github.com/cockroachdb/cockroach/pkg/util/log" "github.com/cockroachdb/errors" ) @@ -109,7 +105,6 @@ func NewInvalidSchemaDefinitionError(err error) error { // NewUndefinedSchemaError creates an error for an undefined schema. // TODO (lucy): Have this take a database name. func NewUndefinedSchemaError(name string) error { - log.Errorf(context.Background(), "MISSING SCHEMA: %s", debug.Stack()) return pgerror.Newf(pgcode.InvalidSchemaName, "unknown schema %q", name) } From 900b38c8d2d5cfcd206774b355e96a82320c8778 Mon Sep 17 00:00:00 2001 From: Faizan Qazi Date: Wed, 12 Oct 2022 19:37:37 +0000 Subject: [PATCH 2/2] workload/scheamchanger: fix unknown schema retry detection Fixes: #89146 Previously, when we added logic to retry unknown schema errors, the regex used was unfortunately out of sync with the actual error generated. This patch fixes the regex to have the correct string, since those errors were not properly retried. Release note: None --- pkg/workload/schemachange/error_screening.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/workload/schemachange/error_screening.go b/pkg/workload/schemachange/error_screening.go index 6292014bee12..2f41fc11d4cd 100644 --- a/pkg/workload/schemachange/error_screening.go +++ b/pkg/workload/schemachange/error_screening.go @@ -1116,7 +1116,9 @@ SELECT count(*) FROM %s } var ( - regexpUnknownSchemaErr = regexp.MustCompile(`unknown schema \[\d+\]`) + // regexpUnknownSchemaErr matches unknown schema errors with + // a descriptor ID, which will have the form: unknown schema "[123]" + regexpUnknownSchemaErr = regexp.MustCompile(`unknown schema "\[\d+]"`) ) // checkAndAdjustForUnknownSchemaErrors in certain contexts we will attempt to @@ -1129,7 +1131,7 @@ func (og *operationGenerator) checkAndAdjustForUnknownSchemaErrors(err error) er if regexpUnknownSchemaErr.MatchString(pgErr.Message) { og.opGenLog.WriteString(fmt.Sprintf("Rolling back due to unknown schema error %v", err)) - // Force a rollback and log inside the oepration generator. + // Force a rollback and log inside the operation generator. return errors.Mark(err, errRunInTxnRbkSentinel) } }