← All tasks
javaredis/jedis #4014Not a task: already works

The maximum wait time for acquiring a resource from the Jedis Pool may exceed expectations.

envgap__redis__jedis-4014

01 / FAILURE SIGNATURE

As reported upstream

No identifying execution failure has been captured.
Not a benchmark task.
  • The project already builds and runs before the fix, so there is nothing to repair.

02 / ENVIRONMENT RECIPE

Base commit
0d4b0dba6e2e6f951f35ea5552f3a7b0e8a1a43d
Manifest
pom.xml
Reproduce
Awaiting issue-specific recipe
Run under trace
Awaiting a meaningful runtime command

03 / ORIGINAL ISSUE TEXT

redis/jedis #4014 · read the original issue
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:



1. Reduce the maximum number of connections

2. Using Linux TC mechanism to cause TCP communication timeout

3. Observe the maximum waiting time





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



![image](https://github.com/user-attachments/assets/e2f3b0da-5bd1-4540-ad18-2db7dbb725f1)



![image](https://github.com/user-attachments/assets/83afbe17-2707-4c8d-b093-ff0b24e5ea31)



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 











Continue on GitHub ↗

04 / LABELS

Labels from the report text only; not yet run

No supported category has been assigned.

Label rules and the text that matched
[]