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

colexecerror: catch panics from packages in sql/sem folder #62889

Merged
merged 1 commit into from
Mar 31, 2021
Merged
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
10 changes: 8 additions & 2 deletions pkg/sql/colexecerror/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,18 @@ func CatchVectorizedRuntimeError(operation func()) (retErr error) {
return retErr
}

// We use the approach of allow-listing the packages the panics from which are
// safe to catch (which is the case when the code doesn't update shared state
// and doesn't manipulate locks).
//
// Multiple actual packages can have the same prefix as a single constant string
// defined below, but all of such packages are allowed to be caught from.
const (
colPackagesPrefix = "github.com/cockroachdb/cockroach/pkg/col"
execinfraPackagePrefix = "github.com/cockroachdb/cockroach/pkg/sql/execinfra"
sqlColPackagesPrefix = "github.com/cockroachdb/cockroach/pkg/sql/col"
sqlRowPackagesPrefix = "github.com/cockroachdb/cockroach/pkg/sql/row"
treePackagePrefix = "github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
sqlSemPackagesPrefix = "github.com/cockroachdb/cockroach/pkg/sql/sem"
)

// shouldCatchPanic checks whether the panic that was emitted from
Expand Down Expand Up @@ -126,7 +132,7 @@ func shouldCatchPanic(panicEmittedFrom string) bool {
strings.HasPrefix(panicEmittedFrom, execinfraPackagePrefix) ||
strings.HasPrefix(panicEmittedFrom, sqlColPackagesPrefix) ||
strings.HasPrefix(panicEmittedFrom, sqlRowPackagesPrefix) ||
strings.HasPrefix(panicEmittedFrom, treePackagePrefix)
strings.HasPrefix(panicEmittedFrom, sqlSemPackagesPrefix)
}

// StorageError is an error that was created by a component below the sql
Expand Down