Dear Apache Commons Development Team,

I found an issue when using jedis to operate Redis database, Here is the issue 
link -> https://github.com/redis/jedis/issues/4014. we feel that it's a problem 
with the Commons pool.


In situations where the connection is tight, the waiting time can be up to 
twice the maxWaitMillis consumption.



code: org.apache.commons.pool2.impl.GenericObjectPool#borrowObject(long)
-> org.apache.commons.pool2.impl.GenericObjectPool#create

The image has been added to the attachment.




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.
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. such as :


Duration remainingWait = 
localMaxWaitDuration.minus(Duration.between(localStartInstant, Instant.now()));
if (remainingWait.isNegative()) {
    create = Boolean.FALSE;
} else {
wait(makeObjectCountLock, remainingWait);
}




We are not sure if this issue has been addressed and look forward to your 
reply. 











Reply via email to