Skip to content

Commit 9232aac

Browse files
authored
executor: Fix coroutine leak after kill remote connection (#46035)
close #46034
1 parent d5fc8bb commit 9232aac

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
@@ -2608,6 +2608,7 @@ func killRemoteConn(ctx context.Context, sctx sessionctx.Context, gcid *globalco
26082608
SetFromInfoSchema(sctx.GetInfoSchema()).
26092609
SetStoreType(kv.TiDB).
26102610
SetTiDBServerID(gcid.ServerID).
2611+
SetStartTS(math.MaxUint64). // To make check visibility success.
26112612
Build()
26122613
if err != nil {
26132614
return err
@@ -2618,6 +2619,14 @@ func killRemoteConn(ctx context.Context, sctx sessionctx.Context, gcid *globalco
26182619
return err
26192620
}
26202621

2622+
// Must consume & close the response, otherwise coprocessor task will leak.
2623+
defer func() {
2624+
_ = resp.Close()
2625+
}()
2626+
if _, err := resp.Next(ctx); err != nil {
2627+
return errors.Trace(err)
2628+
}
2629+
26212630
logutil.BgLogger().Info("Killed remote connection", zap.Uint64("serverID", gcid.ServerID),
26222631
zap.Uint64("conn", gcid.ToConnID()), zap.Bool("query", query))
26232632
return err

0 commit comments

Comments
 (0)