This is an automated email from the ASF dual-hosted git repository.

zykkk pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
     new aedde4777ff [branch-2.0][improvement](mysql catalog) disable mysql 
AbandonedConnectionCleanup Thread (#36942)
aedde4777ff is described below

commit aedde4777ffbbdcf16049697daef5995b1a2190e
Author: zy-kkk <zhongy...@gmail.com>
AuthorDate: Tue Jul 2 16:36:46 2024 +0800

    [branch-2.0][improvement](mysql catalog) disable mysql 
AbandonedConnectionCleanup Thread (#36942)
    
    pick (#36655)
    
    When using mysql catalog, mysql jdbc driver will generate an
    `AbandonedConnectionCleanupThread` for each database connection. This is
    a virtual reference, which will accumulate over time as database
    connections are constantly created, eventually causing OOM. Therefore,
    in our usage scenario, we need to turn off this thread because our
    database connection recycling depends on the connection pool. But please
    note that this switch is only for MySQL JDBC Driver versions greater
    than 8.0.22
---
 .../jdbc-scanner/src/main/java/org/apache/doris/jdbc/JdbcExecutor.java | 3 +++
 .../java/org/apache/doris/datasource/jdbc/client/JdbcMySQLClient.java  | 2 ++
 2 files changed, 5 insertions(+)

diff --git 
a/fe/be-java-extensions/jdbc-scanner/src/main/java/org/apache/doris/jdbc/JdbcExecutor.java
 
b/fe/be-java-extensions/jdbc-scanner/src/main/java/org/apache/doris/jdbc/JdbcExecutor.java
index 0517786f398..a2ef1936e8f 100644
--- 
a/fe/be-java-extensions/jdbc-scanner/src/main/java/org/apache/doris/jdbc/JdbcExecutor.java
+++ 
b/fe/be-java-extensions/jdbc-scanner/src/main/java/org/apache/doris/jdbc/JdbcExecutor.java
@@ -98,6 +98,9 @@ public class JdbcExecutor {
             throw new InternalException(e.getMessage());
         }
         tableType = request.table_type;
+        if (tableType == TOdbcTableType.MYSQL) {
+            
System.setProperty("com.mysql.cj.disableAbandonedConnectionCleanup", "true");
+        }
         this.config = new JdbcDataSourceConfig()
                 .setCatalogId(request.catalog_id)
                 .setJdbcUser(request.jdbc_user)
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 cd7f7aece3d..ed39c890f7a 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
@@ -44,6 +44,8 @@ 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;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to