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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user