From 2ed995e200cc92b31a1e14d698812d86882dafd1 Mon Sep 17 00:00:00 2001 From: Ping Yu Date: Mon, 14 Aug 2023 17:27:35 +0800 Subject: [PATCH 1/2] This is an automated cherry-pick of #46035 Signed-off-by: ti-chi-bot --- executor/simple.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/executor/simple.go b/executor/simple.go index 5c0abab2e1282..7ae900d4b0356 100644 --- a/executor/simple.go +++ b/executor/simple.go @@ -2592,7 +2592,12 @@ func killRemoteConn(ctx context.Context, sctx sessionctx.Context, connID *util.G SetFromSessionVars(sctx.GetSessionVars()). SetFromInfoSchema(sctx.GetInfoSchema()). SetStoreType(kv.TiDB). +<<<<<<< HEAD SetTiDBServerID(connID.ServerID). +======= + SetTiDBServerID(gcid.ServerID). + SetStartTS(math.MaxUint64). // To make check visibility success. +>>>>>>> 9232aac873b (executor: Fix coroutine leak after kill remote connection (#46035)) Build() if err != nil { return err @@ -2603,8 +2608,21 @@ func killRemoteConn(ctx context.Context, sctx sessionctx.Context, connID *util.G return err } +<<<<<<< HEAD logutil.BgLogger().Info("Killed remote connection", zap.Uint64("serverID", connID.ServerID), zap.Uint64("connID", connID.ID()), zap.Bool("query", query)) +======= + // 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", gcid.ServerID), + zap.Uint64("conn", gcid.ToConnID()), zap.Bool("query", query)) +>>>>>>> 9232aac873b (executor: Fix coroutine leak after kill remote connection (#46035)) return err } From e56348bf7cab63fca589948febc3f25b368a84e3 Mon Sep 17 00:00:00 2001 From: Ping Yu Date: Wed, 16 Aug 2023 21:27:14 +0800 Subject: [PATCH 2/2] resolve conflict Signed-off-by: Ping Yu --- executor/simple.go | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/executor/simple.go b/executor/simple.go index 7ae900d4b0356..6236222d064fb 100644 --- a/executor/simple.go +++ b/executor/simple.go @@ -2592,12 +2592,8 @@ func killRemoteConn(ctx context.Context, sctx sessionctx.Context, connID *util.G SetFromSessionVars(sctx.GetSessionVars()). SetFromInfoSchema(sctx.GetInfoSchema()). SetStoreType(kv.TiDB). -<<<<<<< HEAD SetTiDBServerID(connID.ServerID). -======= - SetTiDBServerID(gcid.ServerID). SetStartTS(math.MaxUint64). // To make check visibility success. ->>>>>>> 9232aac873b (executor: Fix coroutine leak after kill remote connection (#46035)) Build() if err != nil { return err @@ -2608,10 +2604,6 @@ func killRemoteConn(ctx context.Context, sctx sessionctx.Context, connID *util.G return err } -<<<<<<< HEAD - logutil.BgLogger().Info("Killed remote connection", zap.Uint64("serverID", connID.ServerID), - zap.Uint64("connID", connID.ID()), zap.Bool("query", query)) -======= // Must consume & close the response, otherwise coprocessor task will leak. defer func() { _ = resp.Close() @@ -2620,9 +2612,8 @@ func killRemoteConn(ctx context.Context, sctx sessionctx.Context, connID *util.G return errors.Trace(err) } - logutil.BgLogger().Info("Killed remote connection", zap.Uint64("serverID", gcid.ServerID), - zap.Uint64("conn", gcid.ToConnID()), zap.Bool("query", query)) ->>>>>>> 9232aac873b (executor: Fix coroutine leak after kill remote connection (#46035)) + logutil.BgLogger().Info("Killed remote connection", zap.Uint64("serverID", connID.ServerID), + zap.Uint64("connID", connID.ID()), zap.Bool("query", query)) return err }