From 3b342df4954b2528ab808b3b824118df2713d3b3 Mon Sep 17 00:00:00 2001 From: Manan Gupta Date: Mon, 2 Sep 2024 11:44:58 +0530 Subject: [PATCH] feat: address review comments Signed-off-by: Manan Gupta --- go/vt/vttablet/tabletserver/connpool/dbconn.go | 4 ++-- go/vt/vttablet/tabletserver/connpool/dbconn_test.go | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/go/vt/vttablet/tabletserver/connpool/dbconn.go b/go/vt/vttablet/tabletserver/connpool/dbconn.go index 2ee514eb2de..4f3d5fe893d 100644 --- a/go/vt/vttablet/tabletserver/connpool/dbconn.go +++ b/go/vt/vttablet/tabletserver/connpool/dbconn.go @@ -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() @@ -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 { diff --git a/go/vt/vttablet/tabletserver/connpool/dbconn_test.go b/go/vt/vttablet/tabletserver/connpool/dbconn_test.go index f8b761f088e..1d9104c4354 100644 --- a/go/vt/vttablet/tabletserver/connpool/dbconn_test.go +++ b/go/vt/vttablet/tabletserver/connpool/dbconn_test.go @@ -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()) @@ -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