Skip to content

Commit

Permalink
Merge pull request #89883 from cockroachdb/blathers/backport-release-…
Browse files Browse the repository at this point in the history
…22.2-89858

release-22.2: workload/schemachanger: correctly filter out unknown schema change errors
  • Loading branch information
fqazi authored Oct 13, 2022
2 parents 5ee77a8 + d603550 commit a75ea81
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
1 change: 0 additions & 1 deletion pkg/sql/sqlerrors/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
)
Expand Down
5 changes: 0 additions & 5 deletions pkg/sql/sqlerrors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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)
}

Expand Down
6 changes: 4 additions & 2 deletions pkg/workload/schemachange/error_screening.go
Original file line number Diff line number Diff line change
Expand Up @@ -1122,7 +1122,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
Expand All @@ -1135,7 +1137,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)
}
}
Expand Down

0 comments on commit a75ea81

Please sign in to comment.