From 6570c5c3cfda46215774673c8f87f8fffc1f0395 Mon Sep 17 00:00:00 2001 From: Rueian Date: Mon, 17 Jun 2024 21:02:04 +0800 Subject: [PATCH] perf: set 1s limit for graceful shutdown to avoid waiting for a stuck redis Signed-off-by: Rueian --- pipe.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pipe.go b/pipe.go index b0eb02e9..2aa7677c 100644 --- a/pipe.go +++ b/pipe.go @@ -1480,7 +1480,10 @@ func (p *pipe) Close() { p.background() } if block == 1 && (stopping1 || stopping2) { // make sure there is no block cmd - <-p.queue.PutOne(cmds.PingCmd) + select { + case <-p.queue.PutOne(cmds.PingCmd): + case <-time.After(time.Second): + } } } atomic.AddInt32(&p.waits, -1)