mirror of
https://github.com/redis/go-redis.git
synced 2025-12-02 06:22:31 +03:00
use correct timer for last health check
This commit is contained in:
4
redis.go
4
redis.go
@@ -1366,11 +1366,13 @@ func (c *baseClient) processPushNotifications(ctx context.Context, cn *pool.Conn
|
||||
// If the connection was health-checked within the last 5 seconds, we can skip the
|
||||
// expensive syscall since the health check already verified no unexpected data.
|
||||
// This is safe because:
|
||||
// 0. lastHealthCheckNs is set in pool/conn.go:putConn() after a successful health check
|
||||
// 1. Health check (connCheck) uses the same syscall (Recvfrom with MSG_PEEK)
|
||||
// 2. If push notifications arrived, they would have been detected by health check
|
||||
// 3. 5 seconds is short enough that connection state is still fresh
|
||||
// 4. Push notifications will be processed by the next WithReader call
|
||||
lastHealthCheckNs := cn.UsedAtNs()
|
||||
// used it is set on getConn, so we should use another timer (lastPutAt?)
|
||||
lastHealthCheckNs := cn.LastPutAtNs()
|
||||
if lastHealthCheckNs > 0 {
|
||||
// Use pool's cached time to avoid expensive time.Now() syscall
|
||||
nowNs := pool.GetCachedTimeNs()
|
||||
|
||||
Reference in New Issue
Block a user