Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/redis/driver_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"net"
"strings"
"sync/atomic"
"time"

"github.com/jpillora/backoff"
Expand All @@ -23,13 +24,15 @@ type poolStats struct {
connectionActive stats.Gauge
connectionTotal stats.Counter
connectionClose stats.Counter
hadConnError *atomic.Bool
}

func newPoolStats(scope stats.Scope) poolStats {
ret := 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
}

Expand All @@ -39,13 +42,17 @@ 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 {
logger.Errorf("Unable to update health status: %s", err)
}
}
} else {
ps.hadConnError.Store(true)
logger.Errorf("creating redis connection error : %v", newConn.Err)
}
},
Expand Down
Loading