go-redis/redis · error

redis: StickyConnPool.Get: infinite loop

Error message

redis: StickyConnPool.Get: infinite loop

What it means

Error "redis: StickyConnPool.Get: infinite loop" thrown in go-redis/redis.

Source

Thrown at internal/pool/pool_sticky.go:104

				return cn, nil
			}
			p.pool.Remove(ctx, cn, ErrClosed)
		case stateInited:
			if err := p.badConnError(); err != nil {
				return nil, err
			}
			cn, ok := <-p.ch
			if !ok {
				return nil, ErrClosed
			}
			return cn, nil
		case stateClosed:
			return nil, ErrClosed
		default:
			panic("not reached")
		}
	}
	return nil, fmt.Errorf("redis: StickyConnPool.Get: infinite loop")
}

// SetOnFirstConn configures a callback that runs when the sticky pool first
// claims a parent connection. It must be called before the pool is used.
func (p *StickyConnPool) SetOnFirstConn(fn func(*Conn)) {
	p.onFirstConn = fn
}

func (p *StickyConnPool) Put(ctx context.Context, cn *Conn) {
	defer func() {
		if recover() != nil {
			p.freeConn(ctx, cn)
		}
	}()
	// A connection marked for removal on release (it may hold unread
	// replies) must not be served to the next Get: record it as a bad
	// connection — exactly like Remove — so Get refuses and the underlying
	// connection is removed from the parent pool when the sticky pool

View on GitHub (pinned to 36d97525cd)

Solutions

  1. Report/upgrade: this indicates a pool bug; as a workaround recreate the StickyConnPool
  2. Avoid concurrent Get/Close on the sticky pool

When it happens

Trigger: Thrown at internal/pool/pool_sticky.go:104 when the library encounters an invalid state.

Common situations: Guard sticky pool access with clear ownership (one goroutine or serialized use).


AI-assisted analysis of go-redis/redis@36d97525cd (2026-08-06). Data as JSON: /data/errors/b44a8cbb3ccc4e45.json. Report an issue: GitHub.