-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
The maximum wait time for acquiring a resource from the Jedis Pool may exceed expectations. #4014
Comments
@gududesundapao First of all, thank you for using Jedis. Jedis is dependent on Apache Commons Pool. This is also evident from the source code you have provided because those are from that library. You may try their user mailing list. You may even try their developer mailing list if you have some idea about solving the issue. Thank for understanding. |
@sazzad16 hello |
@gududesundapao The fix is not released yet. If you really need it, you may consider building the commons-pool library from their source code. @garydgregory Do you have any tentative date for commons-pool 2.12.1 ? |
I have 2 other releases in Commons in progress. I'd like to clear the decks before I do another. |
I will get to this later today. |
FYI, the Apache Commons Pool 2.12.1 release candidate is open for review and voting here: |
Hello !
Expected behavior
If the number of connections currently being created has reached the maxTotal, subsequent threads waiting to create connections will wait for a maxWaitMillis time, as the connections currently being created might fail.
We expect the waiting time not to exceed maxWaitMillis time, as this parameter affects our estimation of the overall time taken by the interface.
Actual behavior
But in situations where the connection is tight, the waiting time can be up to twice the maxWaitMillis consumption.
Steps to reproduce:
We have found that in some special cases, when creating connections from a connection pool, there may be excessively long waiting times
code:
redis.clients.jedis.JedisPool#getResource
-> redis.clients.jedis.util.Pool#getResource
-> org.apache.commons.pool2.impl.GenericObjectPool#borrowObject(long)
-> org.apache.commons.pool2.impl.GenericObjectPool#create
The thread that failed to create the connection will wake up the thread that is waiting to be created.
Threads that do not compete for resources will wait again, and the waiting time will still be the maxWaitMillis.
unbelievable!
If the first waiting time is ( maxWaitMillis - 1ms ), plus the second full waiting time, then the full waiting time will be twice the expected time.
The waiting time we hope for this time is the total waiting time minus the time already waited
We are not sure if this issue has been addressed and look forward to your reply
Redis / Jedis Configuration
redis-client.timeout=100
redis-client.pool.maxTotal=1
redis-client.pool.maxIdle=1
redis-client.pool.minIdle=1
redis-client.pool.testOnBorrow=false
redis-client.pool.testWhileIdle=true
redis-client.pool.timeBetweenEvictionRunsMillis=30000
redis-client.pool.minEvictableIdleTimeMillis=1800000
redis-client.pool.numTestsPerEvictionRun=3
redis-client.pool.softMinEvictableIdleTimeMillis=-1
redis-client.pool.blockWhenExhausted=true
redis-client.pool.maxWaitMillis=80
Jedis version:
3.6.3
apache commons-pool2 version:
2.9.0
Redis version:
Java version:
1.8
The text was updated successfully, but these errors were encountered: