You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2023/04/30 11:44:17 UTC

[doris] 06/15: [refactor](jdbc) close datasource if no need to maintain the cache (#18724)

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

morningman pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git

commit c3244c5fa5f3739c0965aa5b24c7fab335335e3f
Author: zhangstar333 <87...@users.noreply.github.com>
AuthorDate: Sat Apr 22 22:07:34 2023 +0800

    [refactor](jdbc) close datasource if no need to maintain the cache (#18724)
    
    after pr #18670
    could use jvm parameters to init jdbc datasource,
    but when set JDBC_MIN_POOL=0, it can be immediately closed.
    There is no need to wait for the recycling timer.
---
 fe/java-udf/src/main/java/org/apache/doris/udf/JdbcExecutor.java | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/fe/java-udf/src/main/java/org/apache/doris/udf/JdbcExecutor.java b/fe/java-udf/src/main/java/org/apache/doris/udf/JdbcExecutor.java
index 5cff9a3534..9a6a2b9535 100644
--- a/fe/java-udf/src/main/java/org/apache/doris/udf/JdbcExecutor.java
+++ b/fe/java-udf/src/main/java/org/apache/doris/udf/JdbcExecutor.java
@@ -103,6 +103,12 @@ public class JdbcExecutor {
         if (conn != null) {
             conn.close();
         }
+        if (minIdleSize == 0) {
+            // it can be immediately closed if there is no need to maintain the cache of datasource
+            druidDataSource.close();
+            JdbcDataSource.getDataSource().getSourcesMap().clear();
+            druidDataSource = null;
+        }
         resultSet = null;
         stmt = null;
         conn = null;


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