Skip to content

Commit

Permalink
"merged" #2126 Added Support For beginRequest and endRequest (new ver…
Browse files Browse the repository at this point in the history
…sion)
  • Loading branch information
brettwooldridge committed Sep 23, 2024
1 parent 8053e39 commit 7bf6d55
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/main/java/com/zaxxer/hikari/pool/HikariPool.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public final class HikariPool extends PoolBase implements HikariPoolMXBean, IBag

private final long aliveBypassWindowMs = Long.getLong("com.zaxxer.hikari.aliveBypassWindowMs", MILLISECONDS.toMillis(500));
private final long housekeepingPeriodMs = Long.getLong("com.zaxxer.hikari.housekeeping.periodMs", SECONDS.toMillis(30));
private final boolean isRequestBoundariesEnabled = Boolean.getBoolean("com.zaxxer.hikari.enableRequestBoundaries");

private static final String EVICTED_CONNECTION_MESSAGE = "(connection was evicted)";
private static final String DEAD_CONNECTION_MESSAGE = "(connection is dead)";
Expand Down Expand Up @@ -171,6 +172,13 @@ public Connection getConnection(final long hardTimeout) throws SQLException
}
else {
metricsTracker.recordBorrowStats(poolEntry, startTime);
if (isRequestBoundariesEnabled) {
try {
poolEntry.connection.beginRequest();
} catch (SQLException e) {
logger.warn("beginRequest Failed for: {}, ({})", poolEntry.connection, e.getMessage());
}
}
return poolEntry.createProxyConnection(leakTaskFactory.schedule(poolEntry));
}
} while (timeout > 0L);
Expand Down Expand Up @@ -420,6 +428,13 @@ void recycle(final PoolEntry poolEntry)
if (poolEntry.isMarkedEvicted()) {
closeConnection(poolEntry, EVICTED_CONNECTION_MESSAGE);
} else {
if (isRequestBoundariesEnabled) {
try {
poolEntry.connection.endRequest();
} catch (SQLException e) {
logger.warn("endRequest Failed for: {},({})", poolEntry.connection, e.getMessage());
}
}
connectionBag.requite(poolEntry);
}
}
Expand Down

0 comments on commit 7bf6d55

Please sign in to comment.