Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix](jdbc catalog) Fix Memory Leak by Enabling Weak References in HikariCP #39582

Merged
merged 1 commit into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
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 @@ -94,6 +94,7 @@ public BaseJdbcExecutor(byte[] thriftParams) throws Exception {
.setConnectionPoolMaxLifeTime(request.connection_pool_max_life_time)
.setConnectionPoolKeepAlive(request.connection_pool_keep_alive);
JdbcDataSource.getDataSource().setCleanupInterval(request.connection_pool_cache_clear_time);
System.setProperty("com.zaxxer.hikari.useWeakReferences", "true");
init(config, request.statement);
this.jdbcDriverVersion = getJdbcDriverVersion();
}
Expand Down Expand Up @@ -309,7 +310,7 @@ private void init(JdbcDataSourceConfig config, String sql) throws JdbcExecutorEx
ds.setKeepaliveTime(config.getConnectionPoolMaxLifeTime() / 5L); // default 6 min
}
hikariDataSource = ds;
JdbcDataSource.getDataSource().putSource(hikariDataSourceKey, ds);
JdbcDataSource.getDataSource().putSource(hikariDataSourceKey, hikariDataSource);
LOG.info("JdbcClient set"
+ " ConnectionPoolMinSize = " + config.getConnectionPoolMinSize()
+ ", ConnectionPoolMaxSize = " + config.getConnectionPoolMaxSize()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ public Map<String, HikariDataSource> getSourcesMap() {
}

public void setCleanupInterval(long interval) {
this.cleanupInterval = interval * 1000L;
restartCleanupTask();
if (this.cleanupInterval != interval * 1000L) {
this.cleanupInterval = interval * 1000L;
restartCleanupTask();
}
}

private synchronized void restartCleanupTask() {
Expand Down
Loading