Skip to content

Commit

Permalink
Add error transformer to vtgate executor (#15894)
Browse files Browse the repository at this point in the history
  • Loading branch information
rafer authored May 13, 2024
1 parent 042e73e commit 70f4249
Showing 1 changed file with 25 additions and 2 deletions.
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)
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
}

0 comments on commit 70f4249

Please sign in to comment.