Skip to content

Commit

Permalink
feat: address review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Manan Gupta <[email protected]>
  • Loading branch information
GuptaManan100 committed Sep 2, 2024
1 parent 4cfa8d3 commit 3b342df
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions go/vt/vttablet/tabletserver/connpool/dbconn.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func (dbc *Conn) execOnce(ctx context.Context, query string, maxrows int, wantfi
// Check if the context is already past its deadline before
// trying to execute the query.
if err := ctx.Err(); err != nil {
return nil, vterrors.Errorf(vtrpcpb.Code_CANCELED, "%s, before execution started", dbc.getErrorMessageFromContextError(ctx))
return nil, vterrors.Errorf(vtrpcpb.Code_CANCELED, "%s before execution started", dbc.getErrorMessageFromContextError(ctx))
}

now := time.Now()
Expand Down Expand Up @@ -235,7 +235,7 @@ func (dbc *Conn) FetchNext(ctx context.Context, maxrows int, wantfields bool) (*
// Check if the context is already past its deadline before
// trying to fetch the next result.
if err := ctx.Err(); err != nil {
return nil, vterrors.Errorf(vtrpcpb.Code_CANCELED, "%s, before reading next result set", dbc.getErrorMessageFromContextError(ctx))
return nil, vterrors.Errorf(vtrpcpb.Code_CANCELED, "%s before reading next result set", dbc.getErrorMessageFromContextError(ctx))
}
res, _, _, err := dbc.conn.ReadQueryResult(maxrows, wantfields)
if err != nil {
Expand Down
7 changes: 5 additions & 2 deletions go/vt/vttablet/tabletserver/connpool/dbconn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func TestDBConnDeadline(t *testing.T) {

_, err = dbConn.Exec(ctx, sql, 1, false)
require.Error(t, err)
require.ErrorContains(t, err, "(errno 3024) (sqlstate HY000): Query execution was interrupted, maximum statement execution time exceeded, before execution started")
require.ErrorContains(t, err, "(errno 3024) (sqlstate HY000): Query execution was interrupted, maximum statement execution time exceeded before execution started")

compareTimingCounts(t, "PoolTest.Exec", 0, startCounts, mysqlTimings.Counts())

Expand Down Expand Up @@ -455,7 +455,10 @@ func TestDBNoPoolConnKill(t *testing.T) {
db.EnableConnFail()
err = dbConn.Kill("test kill", 0)
require.Error(t, err)
require.ErrorContains(t, err, "errno 2013")
var sqlErr *sqlerror.SQLError
isSqlErr := errors.As(sqlerror.NewSQLErrorFromError(err), &sqlErr)
require.True(t, isSqlErr)
require.EqualValues(t, sqlerror.CRServerLost, sqlErr.Number())
db.DisableConnFail()

// Kill succeed
Expand Down

0 comments on commit 3b342df

Please sign in to comment.