Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workload/schemachanger: correctly filter out unknown schema change errors #89858

Merged
merged 2 commits into from
Oct 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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+]"`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just want to confirm that we're trying to match something like unknown schema "[1]" ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes the errors have the form: unknown schema "[1]". I'll add a comment to make it clear

)

// checkAndAdjustForUnknownSchemaErrors in certain contexts we will attempt to
Expand All @@ -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)
}
}
Expand Down