Adding leak detection to hikari pool. Would be tracking this on logdna to ensure that we are catching any and all leaks that may be occuring with hikari. (#2374)

This commit is contained in:
Trisha Anand 2020-12-28 18:26:33 +05:30
parent 85350b2940
commit a70b95be37

View File

@ -54,6 +54,8 @@ public class PostgresPlugin extends BasePlugin {
private static final int MAXIMUM_POOL_SIZE = 5; private static final int MAXIMUM_POOL_SIZE = 5;
private static final long LEAK_DETECTION_TIME_MS = 60*1000;
public PostgresPlugin(PluginWrapper wrapper) { public PostgresPlugin(PluginWrapper wrapper) {
super(wrapper); super(wrapper);
} }
@ -540,6 +542,10 @@ public class PostgresPlugin extends BasePlugin {
} }
config.setJdbcUrl(url); config.setJdbcUrl(url);
// Configuring leak detection threshold for 60 seconds. Any connection which hasn't been released in 60 seconds
// should get tracked (may be falsely for long running queries) as leaked connection
config.setLeakDetectionThreshold(LEAK_DETECTION_TIME_MS);
// Now create the connection pool from the configuration // Now create the connection pool from the configuration
HikariDataSource datasource = new HikariDataSource(config); HikariDataSource datasource = new HikariDataSource(config);