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 3bd9af74e99 [log](s3) print detailed error message when failed to 
access object storage (#38585)
3bd9af74e99 is described below

commit 3bd9af74e996fd59b83e6089d8efa9e7f58437e9
Author: Kaijie Chen <c...@apache.org>
AuthorDate: Sun Aug 4 10:21:50 2024 +0800

    [log](s3) print detailed error message when failed to access object storage 
(#38585)
    
    ## Proposed changes
    
    Print detailed error message when failed to access object storage.
---
 .../java/org/apache/doris/analysis/CreateStageStmt.java | 12 +++---------
 .../main/java/org/apache/doris/analysis/LoadStmt.java   | 17 +++++------------
 .../java/org/apache/doris/common/UserException.java     |  5 +++++
 .../test_domain_connection_and_ak_sk_correction.groovy  |  8 ++++----
 4 files changed, 17 insertions(+), 25 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateStageStmt.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateStageStmt.java
index f777dd995f6..4054584805a 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateStageStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateStageStmt.java
@@ -112,16 +112,10 @@ public class CreateStageStmt extends DdlStmt {
             remote.headObject("1");
             remote.listObjects(null);
         } catch (Exception e) {
-            LOG.warn("Failed check object storage info={}", 
stageProperties.getObjectStoreInfoPB(), e);
-            String message = e.getMessage();
-            if (message != null) {
-                int index = message.indexOf("Error message=");
-                if (index != -1) {
-                    message = message.substring(index);
-                }
-            }
+            LOG.warn("Failed to access object storage, proto={}, err={}",
+                    stageProperties.getObjectStoreInfoPB(), e.toString());
             throw new UserException(InternalErrorCode.GET_REMOTE_DATA_ERROR,
-                    "Incorrect object storage info, " + message);
+                    "Failed to access object storage", e);
         } finally {
             if (remote != null) {
                 remote.close();
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/LoadStmt.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/LoadStmt.java
index a24d1ae72fe..b879bcc7c9a 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/LoadStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/LoadStmt.java
@@ -607,14 +607,14 @@ public class LoadStmt extends DdlStmt {
             connection.setConnectTimeout(10000);
             connection.connect();
         } catch (Exception e) {
-            LOG.warn("Failed to connect endpoint={}", endpoint, e);
-            throw new UserException("Incorrect object storage info: " + 
e.getMessage());
+            LOG.warn("Failed to connect endpoint={}, err={}", endpoint, e);
+            throw new UserException("Failed to access object storage", e);
         } finally {
             if (connection != null) {
                 try {
                     connection.disconnect();
                 } catch (Exception e) {
-                    LOG.warn("Failed to disconnect connection, endpoint={}", 
endpoint, e);
+                    LOG.warn("Failed to disconnect connection, endpoint={}, 
err={}", endpoint, e);
                 }
             }
             SecurityChecker.getInstance().stopSSRFChecking();
@@ -671,16 +671,9 @@ public class LoadStmt extends DdlStmt {
                 }
             }
         } catch (Exception e) {
-            LOG.warn("Failed check object info={}", objectInfo, e);
-            String message = e.getMessage();
-            if (message != null) {
-                int index = message.indexOf("Error message=");
-                if (index != -1) {
-                    message = message.substring(index);
-                }
-            }
+            LOG.warn("Failed to access object storage, proto={}, err={}", 
objectInfo, e.toString());
             throw new UserException(InternalErrorCode.GET_REMOTE_DATA_ERROR,
-                    "Incorrect object storage info, " + message);
+                    "Failed to access object storage", e);
         } finally {
             if (remote != null) {
                 remote.close();
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/common/UserException.java 
b/fe/fe-core/src/main/java/org/apache/doris/common/UserException.java
index 09421e10853..5a2dfb82576 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/common/UserException.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/common/UserException.java
@@ -54,7 +54,12 @@ public class UserException extends Exception {
         super(Strings.nullToEmpty(msg));
         this.errorCode = errCode;
         mysqlErrorCode = ErrorCode.ERR_UNKNOWN_ERROR;
+    }
 
+    public UserException(InternalErrorCode errCode, String msg, Throwable 
cause) {
+        super(Strings.nullToEmpty(msg), cause);
+        this.errorCode = errCode;
+        mysqlErrorCode = ErrorCode.ERR_UNKNOWN_ERROR;
     }
 
     public InternalErrorCode getErrorCode() {
diff --git 
a/regression-test/suites/load_p0/broker_load/test_domain_connection_and_ak_sk_correction.groovy
 
b/regression-test/suites/load_p0/broker_load/test_domain_connection_and_ak_sk_correction.groovy
index 889da246d3b..50f51086db1 100644
--- 
a/regression-test/suites/load_p0/broker_load/test_domain_connection_and_ak_sk_correction.groovy
+++ 
b/regression-test/suites/load_p0/broker_load/test_domain_connection_and_ak_sk_correction.groovy
@@ -100,7 +100,7 @@ suite("test_domain_connection_and_ak_sk_correction",  
"load_p0") {
         assertTrue(false. "The endpoint is wrong, so the connection test 
should fale")
     } catch (Exception e) {
         logger.info("the second sql exception result is {}", e.getMessage())
-        assertTrue(e.getMessage().contains("Incorrect object storage info"), 
e.getMessage())
+        assertTrue(e.getMessage().contains("Failed to access object storage"), 
e.getMessage())
     }
 
     label = UUID.randomUUID().toString().replace("-", "")
@@ -125,7 +125,7 @@ suite("test_domain_connection_and_ak_sk_correction",  
"load_p0") {
         assertTrue(false. "AK is wrong, so the correction of AKSK test should 
fale")
     } catch (Exception e) {
         logger.info("the third sql exception result is {}", e.getMessage())
-        assertTrue(e.getMessage().contains("Incorrect object storage info"), 
e.getMessage())
+        assertTrue(e.getMessage().contains("Failed to access object storage"), 
e.getMessage())
     }
 
     label = UUID.randomUUID().toString().replace("-", "")
@@ -154,8 +154,8 @@ suite("test_domain_connection_and_ak_sk_correction",  
"load_p0") {
         assertTrue(false. "in the second DATA INFILE, the first bucket is 
wrong, so the sql should fail")
     } catch (Exception e) {
         logger.info("the fourth sql exception result is {}", e.getMessage())
-        assertTrue(e.getMessage().contains("Incorrect object storage info"), 
e.getMessage())
+        assertTrue(e.getMessage().contains("Failed to access object storage"), 
e.getMessage())
     }
     sql """ DROP TABLE IF EXISTS ${tableName} FORCE"""
     sql """ DROP TABLE IF EXISTS ${tableNameOrders} FORCE"""
-}
\ No newline at end of file
+}


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

Reply via email to