You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by yi...@apache.org on 2024/03/12 06:12:33 UTC

(doris) 02/04: [fix](jdbc catalog) Clean up the connection pool after failure to initialize the client (#31949)

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

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

commit 1fee736ca49dcabb196abbef8e716d1be1c6638c
Author: zy-kkk <zh...@gmail.com>
AuthorDate: Sat Mar 9 20:01:56 2024 +0800

    [fix](jdbc catalog) Clean up the connection pool after failure to initialize the client (#31949)
---
 .../java/org/apache/doris/datasource/jdbc/client/JdbcClient.java   | 4 ++--
 .../org/apache/doris/datasource/jdbc/client/JdbcMySQLClient.java   | 5 +++--
 .../apache/doris/datasource/jdbc/client/JdbcOceanBaseClient.java   | 7 ++++---
 3 files changed, 9 insertions(+), 7 deletions(-)

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 6d68ced3624..769c9541ec2 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
@@ -169,8 +169,8 @@ public abstract class JdbcClient {
         try {
             conn = dataSource.getConnection();
         } catch (Exception e) {
-            String errorMessage = String.format("Can not connect to jdbc due to error: %s, Catalog name: %s", e,
-                    this.getCatalogName());
+            String errorMessage = String.format("Can not connect to jdbc due to error: %s, Catalog name: %s",
+                    e.getMessage(), this.getCatalogName());
             throw new JdbcClientException(errorMessage, e);
         }
         return conn;
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 854911e7d56..4b889510941 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
@@ -54,8 +54,9 @@ public class JdbcMySQLClient extends JdbcClient {
                 String versionComment = rs.getString("Value");
                 isDoris = versionComment.toLowerCase().contains("doris");
             }
-        } catch (SQLException e) {
-            throw new JdbcClientException("Failed to determine MySQL Version Comment", e);
+        } catch (SQLException | JdbcClientException e) {
+            closeClient();
+            throw new JdbcClientException("Failed to initialize JdbcMySQLClient: %s", e.getMessage());
         } finally {
             close(rs, stmt, conn);
         }
diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcOceanBaseClient.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcOceanBaseClient.java
index 14d5d5f1848..18cebd7bb96 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcOceanBaseClient.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcOceanBaseClient.java
@@ -47,11 +47,12 @@ public class JdbcOceanBaseClient extends JdbcClient {
                     currentClient = new JdbcOracleClient(jdbcClientConfig);
                     setOracleMode();
                 } else {
-                    throw new JdbcClientException("Unsupported compatibility mode: " + compatibilityMode);
+                    throw new JdbcClientException("Unsupported OceanBase compatibility mode: " + compatibilityMode);
                 }
             }
-        } catch (SQLException e) {
-            throw new JdbcClientException("Failed to determine OceanBase compatibility mode", e);
+        } catch (SQLException | JdbcClientException e) {
+            closeClient();
+            throw new JdbcClientException("Failed to initialize JdbcOceanBaseClient", e.getMessage());
         } finally {
             close(rs, stmt, conn);
         }


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