Skip to content

Commit

Permalink
kill query on query timeout
Browse files Browse the repository at this point in the history
Signed-off-by: Harshit Gangal <[email protected]>
  • Loading branch information
harshit-gangal committed Apr 15, 2024
1 parent d91bb0e commit 909df33
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion go/vt/vttablet/endtoend/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ func TestQueryTimeout(t *testing.T) {
assert.Equal(t, vtrpcpb.Code_ABORTED, vterrors.Code(err))
vend := framework.DebugVars()
verifyIntValue(t, vend, "QueryTimeout", int(100*time.Millisecond))
compareIntDiff(t, vend, "Kills/Connections", vstart, 1)
compareIntDiff(t, vend, "Kills/Queries", vstart, 1)
}

func changeVar(t *testing.T, name, value string) (revert func()) {
Expand Down
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 @@ -184,7 +184,7 @@ func (dbc *Conn) execOnce(ctx context.Context, query string, maxrows int, wantfi

select {
case <-ctx.Done():
_ = dbc.Kill(ctx.Err().Error(), time.Since(now))
_ = dbc.KillQuery(ctx.Err().Error(), time.Since(now))
return nil, dbc.Err()
case r := <-ch:
if dbcErr := dbc.Err(); dbcErr != nil {
Expand Down Expand Up @@ -280,7 +280,7 @@ func (dbc *Conn) streamOnce(ctx context.Context, query string, callback func(*sq

select {
case <-ctx.Done():
_ = dbc.Kill(ctx.Err().Error(), time.Since(now))
_ = dbc.KillQuery(ctx.Err().Error(), time.Since(now))
return dbc.Err()
case err := <-ch:
if dbcErr := dbc.Err(); dbcErr != nil {
Expand Down
2 changes: 1 addition & 1 deletion go/vt/vttablet/tabletserver/connpool/dbconn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ func TestDBExecOnceKillTimeout(t *testing.T) {
// It should also run into a timeout.
var timestampKill atomic.Int64
dbConn.killTimeout = 100 * time.Millisecond
db.AddQueryPatternWithCallback(`kill \d+`, &sqltypes.Result{}, func(string) {
db.AddQueryPatternWithCallback(`kill query \d+`, &sqltypes.Result{}, func(string) {
timestampKill.Store(time.Now().UnixMicro())
// should take longer than the configured kill timeout above.
time.Sleep(200 * time.Millisecond)
Expand Down

0 comments on commit 909df33

Please sign in to comment.