From 8eaaa7fdcddab9de44049a062f413533d2447f26 Mon Sep 17 00:00:00 2001 From: Nitin Date: Fri, 20 Nov 2015 19:18:45 +0530 Subject: [PATCH] sleep reasonably, fix possible negative lifetime --- src/main/java/com/zaxxer/hikari/pool/HikariPool.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/zaxxer/hikari/pool/HikariPool.java b/src/main/java/com/zaxxer/hikari/pool/HikariPool.java index 619ef205..3d7242f8 100644 --- a/src/main/java/com/zaxxer/hikari/pool/HikariPool.java +++ b/src/main/java/com/zaxxer/hikari/pool/HikariPool.java @@ -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;