Skip to content
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

"Implementing Reconnect on Error" example in README causes a connection leak #255

Open
koby08 opened this issue Oct 13, 2020 · 1 comment
Labels

Comments

@koby08
Copy link

koby08 commented Oct 13, 2020

Hi,

It seems that the "Implementing Reconnect on Error" section in the official docs for this client contains a bad example. If someone runs this example, each time it reconnects, the old connection will remain open. This will cause a connection leak to redis server.

The reason for this leak is that in each reconnect attempt Redis.createClient() is called, but without closing the old one. Please notice that calling client.close() won't help as well, because it is an instance of a connection from the connection pool.

In order to fix this, you need to call close() on the instance returned from Redis.createClient() - which will close the connection pool.

@koby08 koby08 added the bug label Oct 13, 2020
@koby08
Copy link
Author

koby08 commented Oct 13, 2020

Actually another issue with the current implementation is if there are several in-flight requests to Redis, and all fire an exception due to some failure, there will be multiple connection attempts that will create dangling clients

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

1 participant