This is an automated email from the ASF dual-hosted git repository. dataroaring pushed a commit to branch branch-3.0 in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.0 by this push: new 28915148227 branch-3.0: [improvement](jdbc catalog) Optimize JDBC driver property settings #42923 (#44404) 28915148227 is described below commit 28915148227980aec023bbd94bba5730859b6fde Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> AuthorDate: Fri Nov 29 19:34:32 2024 +0800 branch-3.0: [improvement](jdbc catalog) Optimize JDBC driver property settings #42923 (#44404) Cherry-picked from #42923 Co-authored-by: zy-kkk <zhongyongk...@selectdb.com> --- .../src/main/java/org/apache/doris/jdbc/BaseJdbcExecutor.java | 6 +++++- .../src/main/java/org/apache/doris/jdbc/MySQLJdbcExecutor.java | 5 +++++ .../java/org/apache/doris/datasource/jdbc/client/JdbcClient.java | 6 +++++- .../org/apache/doris/datasource/jdbc/client/JdbcMySQLClient.java | 8 ++++++-- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/fe/be-java-extensions/jdbc-scanner/src/main/java/org/apache/doris/jdbc/BaseJdbcExecutor.java b/fe/be-java-extensions/jdbc-scanner/src/main/java/org/apache/doris/jdbc/BaseJdbcExecutor.java index e05a7baa008..4a54ac2d4ce 100644 --- a/fe/be-java-extensions/jdbc-scanner/src/main/java/org/apache/doris/jdbc/BaseJdbcExecutor.java +++ b/fe/be-java-extensions/jdbc-scanner/src/main/java/org/apache/doris/jdbc/BaseJdbcExecutor.java @@ -71,6 +71,7 @@ public abstract class BaseJdbcExecutor implements JdbcExecutor { protected String jdbcDriverVersion; public BaseJdbcExecutor(byte[] thriftParams) throws Exception { + setJdbcDriverSystemProperties(); TJdbcExecutorCtorParams request = new TJdbcExecutorCtorParams(); TDeserializer deserializer = new TDeserializer(PROTOCOL_FACTORY); try { @@ -94,7 +95,6 @@ public abstract class BaseJdbcExecutor implements JdbcExecutor { .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(); } @@ -147,6 +147,10 @@ public abstract class BaseJdbcExecutor implements JdbcExecutor { throws SQLException { } + protected void setJdbcDriverSystemProperties() { + System.setProperty("com.zaxxer.hikari.useWeakReferences", "true"); + } + public void cleanDataSource() { if (hikariDataSource != null) { hikariDataSource.close(); diff --git a/fe/be-java-extensions/jdbc-scanner/src/main/java/org/apache/doris/jdbc/MySQLJdbcExecutor.java b/fe/be-java-extensions/jdbc-scanner/src/main/java/org/apache/doris/jdbc/MySQLJdbcExecutor.java index e94f2b22298..4e5af95211b 100644 --- a/fe/be-java-extensions/jdbc-scanner/src/main/java/org/apache/doris/jdbc/MySQLJdbcExecutor.java +++ b/fe/be-java-extensions/jdbc-scanner/src/main/java/org/apache/doris/jdbc/MySQLJdbcExecutor.java @@ -50,6 +50,11 @@ public class MySQLJdbcExecutor extends BaseJdbcExecutor { public MySQLJdbcExecutor(byte[] thriftParams) throws Exception { super(thriftParams); + } + + @Override + protected void setJdbcDriverSystemProperties() { + super.setJdbcDriverSystemProperties(); System.setProperty("com.mysql.cj.disableAbandonedConnectionCleanup", "true"); } diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcClient.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcClient.java index 458142ff518..1ab32efddcc 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcClient.java +++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcClient.java @@ -100,7 +100,7 @@ public abstract class JdbcClient { } protected JdbcClient(JdbcClientConfig jdbcClientConfig) { - System.setProperty("com.zaxxer.hikari.useWeakReferences", "true"); + setJdbcDriverSystemProperties(); this.catalogName = jdbcClientConfig.getCatalog(); this.jdbcUser = jdbcClientConfig.getUser(); this.isOnlySpecifiedDatabase = Boolean.parseBoolean(jdbcClientConfig.getOnlySpecifiedDatabase()); @@ -117,6 +117,10 @@ public abstract class JdbcClient { this.jdbcLowerCaseMetaMatching = new JdbcIdentifierMapping(isLowerCaseMetaNames, metaNamesMapping, this); } + protected void setJdbcDriverSystemProperties() { + System.setProperty("com.zaxxer.hikari.useWeakReferences", "true"); + } + // Initialize DataSource private void initializeDataSource(JdbcClientConfig config) { ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader(); diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcMySQLClient.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcMySQLClient.java index a8263f1621a..b78589faa77 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcMySQLClient.java +++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcMySQLClient.java @@ -46,8 +46,6 @@ public class JdbcMySQLClient extends JdbcClient { protected JdbcMySQLClient(JdbcClientConfig jdbcClientConfig) { super(jdbcClientConfig); - // Disable abandoned connection cleanup - System.setProperty("com.mysql.cj.disableAbandonedConnectionCleanup", "true"); convertDateToNull = isConvertDatetimeToNull(jdbcClientConfig); Connection conn = null; Statement stmt = null; @@ -74,6 +72,12 @@ public class JdbcMySQLClient extends JdbcClient { this.dbType = dbType; } + @Override + protected void setJdbcDriverSystemProperties() { + super.setJdbcDriverSystemProperties(); + System.setProperty("com.mysql.cj.disableAbandonedConnectionCleanup", "true"); + } + @Override public List<String> getDatabaseNameList() { Connection conn = null; --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org