From 8ff9f6ad2601cdb0d8ed80911ed5b0e791a74efd Mon Sep 17 00:00:00 2001 From: Byron Seto Date: Tue, 9 Dec 2025 17:37:11 -0500 Subject: [PATCH] ReportResult should be given the result if it is a success according to the interface, successes will be given to ReportResult as err == nil. In releaseConn it's given the err regardless of nil or non nil. But with getConn, it is only given err if err != nil. I don't think this should be the behaviour because right before getConn is called, there's an Allow() call. I can't speak for everyone's use-case, but I'm setting Allow() to return true, and looking for a success call next - and this usually works - but sometimes I get stuck, and I think it's because in the case where Allow() returns true for a _getConn, if this succeeds, ReportResult is not given a success. --- redis.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/redis.go b/redis.go index a6a710677..7f142cde8 100644 --- a/redis.go +++ b/redis.go @@ -270,10 +270,10 @@ func (c *baseClient) getConn(ctx context.Context) (*pool.Conn, error) { } cn, err := c._getConn(ctx) + if c.opt.Limiter != nil { + c.opt.Limiter.ReportResult(err) + } if err != nil { - if c.opt.Limiter != nil { - c.opt.Limiter.ReportResult(err) - } return nil, err } @@ -329,6 +329,7 @@ func (c *baseClient) reAuthConnection() func(poolCn *pool.Conn, credentials auth return err } } + func (c *baseClient) onAuthenticationErr() func(poolCn *pool.Conn, err error) { return func(poolCn *pool.Conn, err error) { if err != nil {