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

Pooled Connections shouldn't be closed if they have socket timeouts #2108

Closed
mircea-pop opened this issue Nov 27, 2019 · 2 comments
Closed

Comments

@mircea-pop
Copy link

mircea-pop commented Nov 27, 2019

The following line can throw a SocketTimeoutException and in that case, the connection is marked as broken.
https://github.com/xetorthio/jedis/blob/6126d30efccb8921dcf9a03776299a504e022a3e/src/main/java/redis/clients/jedis/Connection.java#L126

Then when the close() method is called (the intention is to add the connection back to the pool), then the broken client is eventually closed:
https://github.com/xetorthio/jedis/blob/6126d30efccb8921dcf9a03776299a504e022a3e/src/main/java/redis/clients/jedis/Jedis.java#L3458

The above call will end up in the invalidateObject() method in the commons-pool2:
https://github.com/apache/commons-pool/blob/f4455dcb8afaf9ae7054589110f1082a7a8a282c/src/main/java/org/apache/commons/pool2/impl/GenericObjectPool.java#L607

which eventually will call:
https://github.com/xetorthio/jedis/blob/6126d30efccb8921dcf9a03776299a504e022a3e/src/main/java/redis/clients/jedis/JedisFactory.java#L94

This is the cause of issue #2105, where the guys see a large number of new connections. I was able to reproduce it by lowering the socket timeout.

@ganeshkumarganesan
Copy link

ganeshkumarganesan commented Jan 28, 2020

We are also facing the same problem. Any solution?

In our case, redis max memory limit is reached and the spike in connection (occupies more memory) led to the huge key eviction.

@sazzad16 sazzad16 added this to the 3.5.0 milestone Dec 15, 2020
@sazzad16 sazzad16 modified the milestones: 3.5.0, 3.6.0 Jan 19, 2021
@sazzad16 sazzad16 removed this from the 3.6.0 milestone Feb 7, 2021
yangbodong22011 added a commit to yangbodong22011/jedis that referenced this issue Apr 3, 2023
Please refer to: redis/redis#11420

This PR cancels calling the quit command when the Jedis internal
link is abnormal, but the user interface `Jedis.quit()` is not
affected. This optimizes Jedis connection pool performance and
fixes: redis#2105
redis#2108
yangbodong22011 added a commit to yangbodong22011/jedis that referenced this issue Apr 4, 2023
Please refer to: redis/redis#11420

This PR cancels calling the quit command when the Jedis internal
link is abnormal, and deprecate the user interface `Jedis.quit()`.
This optimizes Jedis connection pool performance and
fixes: redis#2105
redis#2108
@yangbodong22011
Copy link
Collaborator

closed by #3353

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

No branches or pull requests

4 participants