MCPcopy Create free account
hub / github.com/cockroachdb/cockroachdb-parser / shouldCatchPanic

Function shouldCatchPanic

pkg/sql/colexecerror/error.go:193–221  ·  view source on GitHub ↗

shouldCatchPanic checks whether the panic that was emitted from panicEmittedFrom line of code (which contains the full path to the function where the panic originated) should be caught by the vectorized engine. The vectorized engine uses the panic-catch mechanism of error propagation, so we need to

(panicEmittedFrom string)

Source from the content-addressed store, hash-verified

191//
192// panicEmittedFrom must be trimmed to not have any white spaces in the prefix.
193func shouldCatchPanic(panicEmittedFrom string) bool {
194 // In crdb_test builds we do not catch runtime panics even if they originate
195 // from within the vectorized execution engine. These panics probably
196 // represent bugs in vectorized execution, and we want them to fail loudly in
197 // tests (but not in production clusters).
198 if buildutil.CrdbTestBuild && !testingKnobShouldCatchPanic {
199 return false
200 }
201
202 const panicFromTheCatcherItselfPrefix = "github.com/cockroachdb/cockroachdb-parser/pkg/sql/colexecerror.CatchVectorizedRuntimeError"
203 if strings.HasPrefix(panicEmittedFrom, panicFromTheCatcherItselfPrefix) {
204 // This panic came from the catcher itself, so we will propagate it
205 // unchanged by the higher-level catchers.
206 return false
207 }
208 const nonCatchablePanicPrefix = "github.com/cockroachdb/cockroachdb-parser/pkg/sql/colexecerror.NonCatchablePanic"
209 if strings.HasPrefix(panicEmittedFrom, nonCatchablePanicPrefix) {
210 // This panic came from NonCatchablePanic() method and should not be
211 // caught.
212 return false
213 }
214 return strings.HasPrefix(panicEmittedFrom, colPackagesPrefix) ||
215 strings.HasPrefix(panicEmittedFrom, encodingPackagePrefix) ||
216 strings.HasPrefix(panicEmittedFrom, execinfraPackagePrefix) ||
217 strings.HasPrefix(panicEmittedFrom, sqlColPackagesPrefix) ||
218 strings.HasPrefix(panicEmittedFrom, sqlRowPackagesPrefix) ||
219 strings.HasPrefix(panicEmittedFrom, sqlSemPackagesPrefix) ||
220 strings.HasPrefix(panicEmittedFrom, testSqlColPackagesPrefix)
221}
222
223// StorageError is an error that was created by a component below the sql
224// stack, such as the network or storage layers. A StorageError will be bubbled

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…