Bug Description
When the Redis server does not support the SUBSCRIBE command (e.g., certain
managed Redis services or Redis proxies with PUB/SUB disabled), the subscriber
goroutine enters an infinite retry loop, and each retry leaks a Redis
connection, causing memory to grow unboundedly.
Root Cause
There are two bugs working together:
Bug 1: Leaked connection in internal/rdb/rdb.go
In CancelationPubSub(), when pubsub.Receive() fails, the pubsub object is
returned as nil but is never closed, leaking the underlying Redis connection:
// internal/rdb/rdb.go
func (r *RDB) CancelationPubSub() (*redis.PubSub, error) {
pubsub := r.client.Subscribe(ctx, base.CancelChannel)
_, err := pubsub.Receive(ctx)
if err != nil {
// BUG: pubsub is never closed here, connection is leaked
return nil, errors.E(op, errors.Unknown, ...)
}
return pubsub, nil
}