-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Queue close does not close redis connection when using custom createClient function #1747
Comments
I have this same issue, any updates with this issue? |
I think this is correct. Existing Redis connections may be used by others, so it's not safe for Bull to close them on queue close. Using this behavior to pool connections between Bull and other clients is very common.
The blocking client cannot be used by others, since it blocks. In other words, Bull completely owns it. So it's safe for Bull to close. So I'm not sure there's much of a bug here. |
Maybe the documentation just needs to be updated to make this clearer. Maybe with |
It mentions some of this in PATTERNS.md, but it could be clearer:
I don't think |
The documentation should mention that the connections created by In practice, that means the provider needs to maintain a collection of clients per queue, and disconnect them after the queue is closed. |
Help avoid pitfalls with closing reused connections and keyPrefix. Fix for OptimalBits#1747
Help avoid pitfalls with closing reused connections and keyPrefix. Fix for OptimalBits#1747
I've created a couple of PRs to the documentation to help people avoid this problem. |
@dobesv just to be clear, bull will not close client and subscriber connections, but what about bclients? will they be auto closed? |
|
@dobesv I was writing some integration tests for my code, and I noticed something. Previously, I was manually storing and closing all connections (client, subscriber and bClients), and my test would execute and finish (I'm using Jest, by the way). Then, after going through this thread, I did some cleanup in my code and stopped storing/closing |
@Tinadim Maybe there are still bugs with that approach. I think we stopped trying to supply our own clients and just let bull manage those connections. |
@reisandbeans Did you manage to find a solution? |
Description
When creating queues using the
createClient
function to connect to redis, the queues are not closed when the queue is closed.Minimal, Working Test code to reproduce the issue.
Output:
It seems like it may have been intentional to not disconnect these redis clients, based on this little bit of logic:
However, when you look at the output, it actually does close one of the redis clients (
bclient
) when you close the queue, but immediately reconnects it afterwards.Bull version
3.14.0
Additional information
See also #1414
The text was updated successfully, but these errors were encountered: