Skip to content

Commit

Permalink
executor: Fix coroutine leak after kill remote connection (#46035) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot authored Aug 17, 2023
1 parent d4aa159 commit eaabea6
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions executor/simple.go
Original file line number Diff line number Diff line change
Expand Up @@ -2593,6 +2593,7 @@ func killRemoteConn(ctx context.Context, sctx sessionctx.Context, connID *util.G
SetFromInfoSchema(sctx.GetInfoSchema()).
SetStoreType(kv.TiDB).
SetTiDBServerID(connID.ServerID).
SetStartTS(math.MaxUint64). // To make check visibility success.
Build()
if err != nil {
return err
Expand All @@ -2603,6 +2604,14 @@ func killRemoteConn(ctx context.Context, sctx sessionctx.Context, connID *util.G
return err
}

// Must consume & close the response, otherwise coprocessor task will leak.
defer func() {
_ = resp.Close()
}()
if _, err := resp.Next(ctx); err != nil {
return errors.Trace(err)
}

logutil.BgLogger().Info("Killed remote connection", zap.Uint64("serverID", connID.ServerID),
zap.Uint64("connID", connID.ID()), zap.Bool("query", query))
return err
Expand Down

0 comments on commit eaabea6

Please sign in to comment.