Skip to content

Commit b0f589e

Browse files
authored
executor: Fix coroutine leak after kill remote connection (#46035) (#46067)
close #46034
1 parent 79a02af commit b0f589e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

executor/simple.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2629,6 +2629,7 @@ func killRemoteConn(ctx context.Context, sctx sessionctx.Context, connID *util.G
26292629
SetFromInfoSchema(sctx.GetInfoSchema()).
26302630
SetStoreType(kv.TiDB).
26312631
SetTiDBServerID(connID.ServerID).
2632+
SetStartTS(math.MaxUint64). // To make check visibility success.
26322633
Build()
26332634
if err != nil {
26342635
return err
@@ -2639,6 +2640,14 @@ func killRemoteConn(ctx context.Context, sctx sessionctx.Context, connID *util.G
26392640
return err
26402641
}
26412642

2643+
// Must consume & close the response, otherwise coprocessor task will leak.
2644+
defer func() {
2645+
_ = resp.Close()
2646+
}()
2647+
if _, err := resp.Next(ctx); err != nil {
2648+
return errors.Trace(err)
2649+
}
2650+
26422651
logutil.BgLogger().Info("Killed remote connection", zap.Uint64("serverID", connID.ServerID),
26432652
zap.Uint64("conn", connID.ID()), zap.Bool("query", query))
26442653
return err

0 commit comments

Comments
 (0)