2
0
mirror of https://github.com/hibiken/asynq.git synced 2026-05-07 08:25:56 +08:00

fix: close pubsub connection on Subscribe error in CancelationPubSub

When redis.Subscribe succeeds but Receive() fails, the pubsub
connection was not being closed before returning the error. This caused
the subscriber goroutine to leak a Redis connection on each retry
iteration, eventually exhausting the connection pool.

Fixes #1095
This commit is contained in:
bahtya
2026-04-09 18:15:48 +08:00
parent f81c78e68d
commit dd3c923f44

View File

@@ -1488,6 +1488,7 @@ func (r *RDB) CancelationPubSub() (*redis.PubSub, error) {
pubsub := r.client.Subscribe(ctx, base.CancelChannel)
_, err := pubsub.Receive(ctx)
if err != nil {
pubsub.Close()
return nil, errors.E(op, errors.Unknown, fmt.Sprintf("redis pubsub receive error: %v", err))
}
return pubsub, nil