mirror of
https://github.com/hibiken/asynq.git
synced 2026-04-26 07:25:56 +03:00
[GH-ISSUE #1022] Failed to close redis client connection: redis connection is shared so the Client can't be closed through asynq #487
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#487
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 @MadanaGopalD on GitHub (Feb 13, 2025).
Original GitHub issue: https://github.com/hibiken/asynq/issues/1022
Originally assigned to: @hibiken, @kamikazechaser on GitHub.
Describe the bug
A clear and concise description of what the bug is.
Environment (please complete the following information):
asynqpackage version [e.g. v0.25.1]To Reproduce
Steps to reproduce the behavior (Code snippets if applicable):
func NewRedisClient(dataCfg *conf.Data, logger log.Logger) (redis.UniversalClient, func()) {
// log := log.NewHelper(logger)
var addrs = []string{dataCfg.Redis.Addr}
rdb := redis.NewUniversalClient(&redis.UniversalOptions{Addrs: addrs,
Password: dataCfg.Redis.Password,
WriteTimeout: dataCfg.Redis.WriteTimeout.AsDuration(),
ReadTimeout: dataCfg.Redis.ReadTimeout.AsDuration()})
return rdb, func() {
log.Info("closing redis connection")
if err := rdb.Close(); err != nil {
log.Error("error in closing redis client ", err)
}
}
}
func NewAsynqClientConn(redis redis.UniversalClient) *asynq.Client {
asynqClient := asynq.NewClientFromRedisClient(redis)
return asynqClient
}
I have created AsynqClient, AsynqServer and PeriodicTaskManager in my application, but while closing the application I am getting the following error
asynq: pid=53613 2025/02/13 10:14:23.071065 ERROR: Failed to close redis client connection: redis connection is shared so the Client can't be closed through asynq
Can someone explain me what's causing this error.
@Harvi-C commented on GitHub (Mar 27, 2025):
你应该看一下它的源码实现,当你基于 redis 实例初始化 asynq 时,sharedConnection 会被设置为 True,如果你试图关闭它,它就会报错,这是设计如此,你可以忽略,因为 client 本身就只是被 redis 委托做了一些入队的操作而已
@kamikazechaser commented on GitHub (May 15, 2025):
Call Close on your redis client instead of through asynq. The screenshots describe it above.