mirror of
https://github.com/hibiken/asynq.git
synced 2026-04-25 23:15:51 +03:00
[GH-ISSUE #1095] [BUG] Memory leak: subscriber goroutine retries SUBSCRIBE infinitely without closing PubSub on failure #2549
Labels
No labels
CLI
bug
designing
documentation
duplicate
enhancement
good first issue
good first issue
help wanted
idea
invalid
investigate
needs-more-info
performance
pr-welcome
pull-request
question
wontfix
work in progress
work in progress
work-around-available
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/asynq#2549
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @chaojidage on GitHub (Feb 24, 2026).
Original GitHub issue: https://github.com/hibiken/asynq/issues/1095
Originally assigned to: @hibiken, @kamikazechaser on GitHub.
Bug Description
When the Redis server does not support the
SUBSCRIBEcommand (e.g., certainmanaged Redis services or Redis proxies with PUB/SUB disabled), the
subscribergoroutine 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.goIn
CancelationPubSub(), whenpubsub.Receive()fails, thepubsubobject isreturned as
nilbut 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
}
@MengyuanWu1996 commented on GitHub (Feb 27, 2026):
We've also found this problem and are waiting for it to be fixed
@chaojidage commented on GitHub (Feb 27, 2026):
中国人就尽量都说汉语哈哈哈,我们公司的 redis 不能使用 pub,sub 命令,我就发现被坑了