Skip to content

Commit

Permalink
assign default keepaliveTime of 2 minutes
Browse files Browse the repository at this point in the history
  • Loading branch information
brettwooldridge committed Nov 18, 2024
1 parent 1836e3f commit be6594a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
HikariCP Changes

Changes in 6.2.1

* change default keepaliveTime to 2 minutes

* fix commons-compress dependency, make test scope

Changes in 6.2.0

* merged #2238 handle SQLTimeoutException without eviction. Users looking to preserve previous behavior
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ pool. The 'ping' is one of either: invocation of the JDBC4 `isValid()` method, o
`connectionTestQuery`. Typically, the duration out-of-the-pool should be measured in single digit milliseconds
or even sub-millisecond, and therefore should have little or no noticeable performance impact. The minimum
allowed value is 30000ms (30 seconds), but a value in the range of minutes is most desirable.
*Default: 0 (disabled)*
*Default: 120000 (2 minutes)*

&#9203;``maxLifetime``<br/>
This property controls the maximum lifetime of a connection in the pool. An in-use connection will
Expand Down Expand Up @@ -373,8 +373,8 @@ allows you to set an instance of a class, implementing the ``com.zaxxer.hikari.S
interface, that will be called before a connection is evicted from the pool due to specific exception
conditions. Typically, when a ``SQLException`` is thrown, connections are evicted from the pool when
specific *SQLStates* or *ErrorCodes* are present. The ``adjudicate()`` method will be called on the
``SQLExceptionOverride`` instance, which may return one of: ``Override.CONTINUE_EVICT``.
``Override.DO_NOT_EVICT`` or ``Override.MUST_EVICT``. Except in very specific cases
``SQLExceptionOverride`` instance, which may return one of: ``Override.CONTINUE_EVICT``.
``Override.DO_NOT_EVICT`` or ``Override.MUST_EVICT``. Except in very specific cases
``Override.CONTINUE_EVICT`` should be returned, allowing the default evict/no-evict logic to execute.
*Default: none*

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/zaxxer/hikari/HikariConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class HikariConfig implements HikariConfigMXBean
private static final long SOFT_TIMEOUT_FLOOR = Long.getLong("com.zaxxer.hikari.timeoutMs.floor", 250L);
private static final long IDLE_TIMEOUT = MINUTES.toMillis(10);
private static final long MAX_LIFETIME = MINUTES.toMillis(30);
private static final long DEFAULT_KEEPALIVE_TIME = 0L;
private static final long DEFAULT_KEEPALIVE_TIME = MINUTES.toMillis(2);
private static final int DEFAULT_POOL_SIZE = 10;

private static boolean unitTest = false;
Expand Down Expand Up @@ -1101,13 +1101,13 @@ private void validateNumerics()
// keepalive time must larger than 30 seconds
if (keepaliveTime != 0 && keepaliveTime < SECONDS.toMillis(30)) {
LOGGER.warn("{} - keepaliveTime is less than 30000ms, disabling it.", poolName);
keepaliveTime = DEFAULT_KEEPALIVE_TIME;
keepaliveTime = 0L;
}

// keepalive time must be less than maxLifetime (if maxLifetime is enabled)
if (keepaliveTime != 0 && maxLifetime != 0 && keepaliveTime >= maxLifetime) {
LOGGER.warn("{} - keepaliveTime is greater than or equal to maxLifetime, disabling it.", poolName);
keepaliveTime = DEFAULT_KEEPALIVE_TIME;
keepaliveTime = 0L;
}

if (leakDetectionThreshold > 0 && !unitTest) {
Expand Down

0 comments on commit be6594a

Please sign in to comment.