|
|
|
@ -44,6 +44,7 @@ import java.util.concurrent.ThreadPoolExecutor;
|
|
|
|
|
import java.util.concurrent.atomic.AtomicLong;
|
|
|
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
|
|
|
|
|
|
|
import static com.zaxxer.hikari.SQLExceptionOverride.Override.DO_NOT_EVICT;
|
|
|
|
|
import static com.zaxxer.hikari.pool.ProxyConnection.*;
|
|
|
|
|
import static com.zaxxer.hikari.util.ClockSource.*;
|
|
|
|
|
import static com.zaxxer.hikari.util.UtilityElf.createInstance;
|
|
|
|
@ -149,9 +150,7 @@ abstract class PoolBase
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
boolean isConnectionDead(final Connection connection)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
private boolean doIsConnectionDead(final Connection connection) throws SQLException {
|
|
|
|
|
setNetworkTimeout(connection, validationTimeout);
|
|
|
|
|
try {
|
|
|
|
|
final var validationSeconds = (int) Math.max(1000L, validationTimeout) / 1000;
|
|
|
|
@ -175,13 +174,34 @@ abstract class PoolBase
|
|
|
|
|
connection.rollback();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e) {
|
|
|
|
|
|
|
|
|
|
private void connectionDeadException(final Connection connection, Exception e) {
|
|
|
|
|
lastConnectionFailure.set(e);
|
|
|
|
|
logger.warn("{} - Failed to validate connection {} ({}). Possibly consider using a shorter maxLifetime value.",
|
|
|
|
|
poolName, connection, e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
boolean isConnectionDead(final Connection connection)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
return doIsConnectionDead(connection);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e) {
|
|
|
|
|
if (e instanceof SQLException && exceptionOverride != null &&
|
|
|
|
|
exceptionOverride.adjudicate((SQLException) e) == DO_NOT_EVICT) {
|
|
|
|
|
// try one more time, in case of failover
|
|
|
|
|
try {
|
|
|
|
|
return doIsConnectionDead(connection);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e2) {
|
|
|
|
|
connectionDeadException(connection, e2);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
connectionDeadException(connection, e);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|