From d4c2dbbaba968c8b37232fe7bf2f4fa6c634d914 Mon Sep 17 00:00:00 2001 From: kiran malsetty Date: Wed, 5 Aug 2026 11:32:41 -0400 Subject: [PATCH] redis: log recovery when a connection succeeds after a prior dial error Operators currently only see repeated dial-error logs and have no explicit signal when the pool starts succeeding again. Track whether the last dial attempt failed and log once when a subsequent connection succeeds. Signed-off-by: kiran malsetty --- src/redis/driver_impl.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/redis/driver_impl.go b/src/redis/driver_impl.go index 145701a4..2b0f731f 100644 --- a/src/redis/driver_impl.go +++ b/src/redis/driver_impl.go @@ -6,6 +6,7 @@ import ( "fmt" "net" "strings" + "sync/atomic" "time" "github.com/jpillora/backoff" @@ -23,6 +24,7 @@ type poolStats struct { connectionActive stats.Gauge connectionTotal stats.Counter connectionClose stats.Counter + hadConnError *atomic.Bool } func newPoolStats(scope stats.Scope) poolStats { @@ -30,6 +32,7 @@ func newPoolStats(scope stats.Scope) poolStats { ret.connectionActive = scope.NewGauge("cx_active") ret.connectionTotal = scope.NewCounter("cx_total") ret.connectionClose = scope.NewCounter("cx_local_close") + ret.hadConnError = new(atomic.Bool) return ret } @@ -39,6 +42,9 @@ func poolTrace(ps *poolStats, healthCheckActiveConnection bool, srv server.Serve if newConn.Err == nil { ps.connectionTotal.Add(1) ps.connectionActive.Add(1) + if ps.hadConnError.CompareAndSwap(true, false) { + logger.Infof("redis connection re-established after previous error") + } if healthCheckActiveConnection && srv != nil { err := srv.HealthChecker().Ok(server.RedisHealthComponentName) if err != nil { @@ -46,6 +52,7 @@ func poolTrace(ps *poolStats, healthCheckActiveConnection bool, srv server.Serve } } } else { + ps.hadConnError.Store(true) logger.Errorf("creating redis connection error : %v", newConn.Err) } },