2424 // ErrPoolTimeout timed out waiting to get a connection from the connection pool.
2525 ErrPoolTimeout = errors .New ("redis: connection pool timeout" )
2626
27- << << << < HEAD
27+ // ErrConnUnusableTimeout is returned when a connection is not usable and we timed out trying to mark it as unusable.
28+ ErrConnUnusableTimeout = errors .New ("redis: timed out trying to mark connection as unusable" )
29+
30+ // errHookRequestedRemoval is returned when a hook requests connection removal.
31+ errHookRequestedRemoval = errors .New ("hook requested removal" )
32+
33+ // errConnNotPooled is returned when trying to return a non-pooled connection to the pool.
34+ errConnNotPooled = errors .New ("connection not pooled" )
2835 // Global callback for connection state changes (set by otel package)
2936 connectionStateChangeCallback func (ctx context.Context , cn * Conn , fromState , toState string )
3037
4653 // Global callback for maintenance notifications (set by otel package)
4754 // Parameters: ctx, cn, notificationType
4855 maintenanceNotificationCallback func (ctx context.Context , cn * Conn , notificationType string )
49- == == == =
50- // ErrConnUnusableTimeout is returned when a connection is not usable and we timed out trying to mark it as unusable.
51- ErrConnUnusableTimeout = errors .New ("redis: timed out trying to mark connection as unusable" )
52-
53- // errHookRequestedRemoval is returned when a hook requests connection removal.
54- errHookRequestedRemoval = errors .New ("hook requested removal" )
55-
56- // errConnNotPooled is returned when trying to return a non-pooled connection to the pool.
57- errConnNotPooled = errors .New ("connection not pooled" )
58- >> >> >> > upstream / master
5956
6057 // popAttempts is the maximum number of attempts to find a usable connection
6158 // when popping from the idle connection pool. This handles cases where connections
7572 noExpiration = maxTime
7673)
7774
78- << << << < HEAD
7975// SetConnectionStateChangeCallback sets the global callback for connection state changes.
8076// This is called by the otel package to register metrics recording.
8177func SetConnectionStateChangeCallback (fn func (ctx context.Context , cn * Conn , fromState , toState string )) {
@@ -144,8 +140,6 @@ var timers = sync.Pool{
144140 },
145141}
146142
147- == == == =
148- >> >> >> > upstream / master
149143// Stats contains pool state information and accumulated stats.
150144type Stats struct {
151145 Hits uint32 // number of times free connection was found in the pool
@@ -961,26 +955,20 @@ func (p *ConnPool) putConn(ctx context.Context, cn *Conn, freeTurn bool) {
961955 p .connsMu .Unlock ()
962956 p .idleConnsLen .Add (1 )
963957 }
964- << << << < HEAD
965958 p .idleConnsLen .Add (1 )
966959
967960 // Notify metrics: connection moved from used to idle
968961 if connectionStateChangeCallback != nil {
969962 connectionStateChangeCallback (ctx , cn , "used" , "idle" )
970963 }
971- == == == =
972- >> >> >> > upstream / master
973964 } else {
974965 shouldCloseConn = true
975- << << << < HEAD
966+ p . removeConnWithLock ( cn )
976967
977968 // Notify metrics: connection removed (used -> nothing)
978969 if connectionStateChangeCallback != nil {
979970 connectionStateChangeCallback (ctx , cn , "used" , "" )
980971 }
981- == == == =
982- p .removeConnWithLock (cn )
983- >> >> >> > upstream / master
984972 }
985973
986974 if freeTurn {
@@ -995,8 +983,6 @@ func (p *ConnPool) putConn(ctx context.Context, cn *Conn, freeTurn bool) {
995983}
996984
997985func (p * ConnPool ) Remove (ctx context.Context , cn * Conn , reason error ) {
998- << << << < HEAD
999- == == == =
1000986 p .removeConnInternal (ctx , cn , reason , true )
1001987}
1002988
@@ -1017,7 +1003,6 @@ func (p *ConnPool) removeConnInternal(ctx context.Context, cn *Conn, reason erro
10171003 hookManager .ProcessOnRemove (ctx , cn , reason )
10181004 }
10191005
1020- >> >> >> > upstream / master
10211006 p .removeConnWithLock (cn )
10221007
10231008 if freeTurn {
0 commit comments