Skip to content

Commit

Permalink
server: Set default drainClientWait as 15s (pingcap#42134) (pingcap#4…
Browse files Browse the repository at this point in the history
…8944) (pingcap#48990) (pingcap#32)

close pingcap#32110

Co-authored-by: crazycs <[email protected]>
Co-authored-by: Ti Chi Robot <[email protected]>
  • Loading branch information
3 people authored and GitHub Enterprise committed Dec 18, 2023
1 parent 9cd6711 commit 9f7b51f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 2 additions & 0 deletions server/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -1111,6 +1111,8 @@ 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
Expand Down
12 changes: 5 additions & 7 deletions tidb-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -835,17 +835,15 @@ 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, graceful bool) {
func cleanup(svr *server.Server, storage kv.Storage, dom *domain.Domain, _ bool) {
dom.StopAutoAnalyze()

var drainClientWait time.Duration
if graceful {
drainClientWait = 1<<63 - 1
} else {
drainClientWait = gracefulCloseConnectionsTimeout
}
drainClientWait := gracefulCloseConnectionsTimeout

cancelClientWait := time.Second * 1
svr.DrainClients(drainClientWait, cancelClientWait)

Expand Down

0 comments on commit 9f7b51f

Please sign in to comment.