Skip to content

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

@mircea-pop

Description

@mircea-pop

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions