From 265313616adea0cd81b080175cf2dccabd053b08 Mon Sep 17 00:00:00 2001 From: djshow832 <873581766@qq.com> Date: Fri, 1 Dec 2023 18:44:02 +0800 Subject: [PATCH] Revert "server: Set default drainClientWait as 15s (#42134) (#48944)" This reverts commit 877198dde22010e428be26aa0d7bdc5aab75d629. --- server/conn.go | 2 -- tidb-server/main.go | 12 +++++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/server/conn.go b/server/conn.go index 44f43920a8b37..41133a9bec358 100644 --- a/server/conn.go +++ b/server/conn.go @@ -1111,8 +1111,6 @@ func (cc *clientConn) Run(ctx context.Context) { // by CAS operation, it would then take some actions accordingly. for { // Close connection between txn when we are going to shutdown server. - // Note the current implementation when shutting down, for an idle connection, the connection may block at readPacket() - // consider provider a way to close the connection directly after sometime if we can not read any data. if cc.server.inShutdownMode.Load() { if !cc.ctx.GetSessionVars().InTxn() { return diff --git a/tidb-server/main.go b/tidb-server/main.go index c816e5254508b..e5ead347a1841 100644 --- a/tidb-server/main.go +++ b/tidb-server/main.go @@ -836,15 +836,17 @@ func closeDomainAndStorage(storage kv.Storage, dom *domain.Domain) { terror.Log(errors.Trace(err)) } -// The amount of time we wait for the ongoing txt to finished. -// We should better provider a dynamic way to set this value. var gracefulCloseConnectionsTimeout = 15 * time.Second -func cleanup(svr *server.Server, storage kv.Storage, dom *domain.Domain, _ bool) { +func cleanup(svr *server.Server, storage kv.Storage, dom *domain.Domain, graceful bool) { dom.StopAutoAnalyze() - drainClientWait := gracefulCloseConnectionsTimeout - + var drainClientWait time.Duration + if graceful { + drainClientWait = 1<<63 - 1 + } else { + drainClientWait = gracefulCloseConnectionsTimeout + } cancelClientWait := time.Second * 1 svr.DrainClients(drainClientWait, cancelClientWait)