sleep reasonably, fix possible negative lifetime

pull/502/head
Nitin 9 years ago
parent cfd5e4d054
commit 8eaaa7fdcd

@ -438,7 +438,7 @@ public class HikariPool extends PoolBase implements HikariPoolMXBean, IBagStateL
final long maxLifetime = config.getMaxLifetime();
if (maxLifetime > 0) {
// variance up to 2.5% of the maxlifetime
final long variance = maxLifetime > 10_000 ? ThreadLocalRandom.current().nextLong( Math.max(10_000, maxLifetime / 40) ) : 0;
final long variance = maxLifetime > 10_000 ? ThreadLocalRandom.current().nextLong( maxLifetime / 40 ) : 0;
final long lifetime = maxLifetime - variance;
poolEntry.setFutureEol(houseKeepingExecutorService.schedule(new Runnable() {
@Override
@ -573,7 +573,7 @@ public class HikariPool extends PoolBase implements HikariPoolMXBean, IBagStateL
// failed to get connection from db, sleep and retry
quietlySleep(sleepBackoff);
sleepBackoff = Math.min(connectionTimeout / 2, (long) (sleepBackoff * 1.3));
sleepBackoff = Math.min(connectionTimeout / 4, (long) (sleepBackoff * 1.3));
}
// Pool is suspended or shutdown or at max size
return Boolean.FALSE;

Loading…
Cancel
Save