mirror of
https://github.com/hibiken/asynq.git
synced 2026-04-26 07:25:56 +03:00
[GH-ISSUE #635] [BUG] Use a custom redis client that will panic if redis close #1327
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#1327
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 @shuqingzai on GitHub (Mar 31, 2023).
Original GitHub issue: https://github.com/hibiken/asynq/issues/635
Originally assigned to: @hibiken on GitHub.
Describe the bug
If you implement the
asynq.RedisConnOptinterface and provide a custom redis client,Ctrl + Cstops theasynq.Serverandasynq.SubscriberpanicsTo Reproduce
Steps to reproduce the behavior (Code snippets if applicable):
asynq.RedisConnOptinterface and provide a custom redis clientasynq.Serverand set up a custom redis clientasynq.RedisConnOptreturn nilasynq.SubscriberpanicsExpected behavior
Can support custom providing redis client instead of panic
Because asynq will start multiple redis clients, and redis will also be used in my project, I hope that only one redis client can be instantiated for unified management and reuse clients
Screenshots
If applicable, add screenshots to help explain your problem.
stop custom redis client will return nil
asynq.SubscriberpanicsBecause
my redis clientreturns nil ??Environment (please complete the following information):
asynqpackage [e.g. v1.0.0]Additional context
Add any other context about the problem here.
@bfwbbrj commented on GitHub (Mar 31, 2023):
@shuqingzai My guess would be the msg is nil. And this is related to to the pubsub returned by your custom redis's Subscribe. Since I have no idea which lib you are using, you probably need to check your lib's implementation.
@shuqingzai commented on GitHub (Mar 31, 2023):
@bfwbbrj First of all, thank you for answering my question
@bfwbbrj commented on GitHub (Apr 1, 2023):
The redis client implementation that you are using.
It should be related to the Subscribe method of your redis client implementation. Can you share which redis client implementation you are using?
@shuqingzai commented on GitHub (Apr 1, 2023):
Observe my screenshot, using go-redis's built-in interface analysis
See: https://github.com/redis/go-redis/blob/v8/universal.go#L208
@bfwbbrj commented on GitHub (Apr 1, 2023):
所以你的
m.redisClient也是用https://github.com/redis/go-redis/这个库的客户端吗?你现在的问题是你如果在MakeRedisClient里返回一个nil,在关服务器的时候会panic?@shuqingzai commented on GitHub (Apr 2, 2023):
@bfwbbrj commented on GitHub (Apr 3, 2023):
Is it possible for you not to close the Redis client and leave the work to asynq? Currently if you closed the redis client before you shutdown the asynq, msg will be nil since the channel is already closed. I will create a pr to fix this but since rn prs are not being reviewed and merge. I suggest that you let asynq do the client closing if possible.
@kamikazechaser commented on GitHub (Nov 13, 2024):
If the new API (NewClientFromRedisClient) is used, then attempting to close the client through asynq will return an error https://github.com/hibiken/asynq/blob/master/client.go#L321.
A warning has also been added to guide users on this change. I would recommend moving to the new API and handling the closing on your own.
For now, I will close this Issue.