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

Add error transformer to vtgate executor #15894

Merged
merged 1 commit into from
May 13, 2024
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
27 changes: 25 additions & 2 deletions go/vt/vtgate/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ var (
queriesRoutedByTable = stats.NewCountersWithMultiLabels("QueriesRoutedByTable", "Queries routed from vtgate to vttablet by plan type, keyspace and table", []string{"Plan", "Keyspace", "Table"})

exceedMemoryRowsLogger = logutil.NewThrottledLogger("ExceedMemoryRows", 1*time.Minute)

errorTransform errorTransformer = nullErrorTransformer{}
)

const (
Expand Down Expand Up @@ -246,7 +248,10 @@ func (e *Executor) Execute(ctx context.Context, mysqlCtx vtgateservice.MySQLConn

logStats.SaveEndTime()
e.queryLogger.Send(logStats)

err = errorTransform.TransformError(err)
systay marked this conversation as resolved.
Show resolved Hide resolved
err = vterrors.TruncateError(err, truncateErrorLen)

return result, err
}

Expand Down Expand Up @@ -385,8 +390,11 @@ func (e *Executor) StreamExecute(

logStats.SaveEndTime()
e.queryLogger.Send(logStats)
return vterrors.TruncateError(err, truncateErrorLen)

err = errorTransform.TransformError(err)
err = vterrors.TruncateError(err, truncateErrorLen)

return err
}

func canReturnRows(stmtType sqlparser.StatementType) bool {
Expand Down Expand Up @@ -1352,7 +1360,11 @@ func (e *Executor) Prepare(ctx context.Context, method string, safeSession *Safe
logStats.SaveEndTime()
e.queryLogger.Send(logStats)
}
return fld, vterrors.TruncateError(err, truncateErrorLen)

err = errorTransform.TransformError(err)
err = vterrors.TruncateError(err, truncateErrorLen)

return fld, err
}

func (e *Executor) prepare(ctx context.Context, safeSession *SafeSession, sql string, bindVars map[string]*querypb.BindVariable, logStats *logstats.LogStats) ([]*querypb.Field, error) {
Expand Down Expand Up @@ -1606,3 +1618,14 @@ func (e *Executor) Close() {
func (e *Executor) environment() *vtenv.Environment {
return e.env
}

type (
errorTransformer interface {
TransformError(err error) error
}
nullErrorTransformer struct{}
)

func (nullErrorTransformer) TransformError(err error) error {
return err
}
Loading