Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public class HostMonitorImpl extends AbstractMonitor implements HostMonitor {
private static final long THREAD_SLEEP_NANO = TimeUnit.MILLISECONDS.toNanos(100);
private static final long TERMINATION_TIMEOUT_SEC = 30;
private static final String MONITORING_PROPERTY_PREFIX = "monitoring-";
private static final int MIN_VALIDITY_CHECK_TIMEOUT_SEC = 1;

protected static final Executor ABORT_EXECUTOR =
ExecutorFactory.newSingleThreadExecutor("abort");
Expand Down Expand Up @@ -323,7 +324,8 @@ boolean checkConnectionStatus() {
// Some drivers, like MySQL Connector/J, execute isValid() in a double of specified timeout time.
final int validTimeout = (int) TimeUnit.NANOSECONDS.toSeconds(
this.failureDetectionIntervalNano - THREAD_SLEEP_NANO) / 2;
return this.monitoringConn.isValid(validTimeout);
// validTimeout could get rounded down to 0.
return this.monitoringConn.isValid(Math.max(MIN_VALIDITY_CHECK_TIMEOUT_SEC, validTimeout));
} catch (final SQLException sqlEx) {
return false;
} finally {
Expand Down
Loading