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

morningman 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 0ff645ddf0f [fix](Export) fix timeout property not work for export job 
(#26032)
0ff645ddf0f is described below

commit 0ff645ddf0fec6e9897b0584e601340f9d4ed636
Author: Tiewei Fang <43782773+bepppo...@users.noreply.github.com>
AuthorDate: Tue Oct 31 15:43:22 2023 +0800

    [fix](Export) fix timeout property not work for export job (#26032)
    
    Refer: #25913
---
 .../java/org/apache/doris/analysis/ExportStmt.java | 26 +++++++++++++++++-----
 .../main/java/org/apache/doris/load/ExportJob.java |  3 ++-
 .../main/java/org/apache/doris/qe/VariableMgr.java |  4 ++++
 3 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/ExportStmt.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/ExportStmt.java
index ee4377ee246..dd406f86617 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/ExportStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/ExportStmt.java
@@ -47,6 +47,7 @@ import org.apache.logging.log4j.Logger;
 
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 import java.util.UUID;
 
 // EXPORT statement, export data to dirs by broker.
@@ -65,6 +66,7 @@ public class ExportStmt extends StatementBase {
     private static final String DEFAULT_LINE_DELIMITER = "\n";
     private static final String DEFAULT_COLUMNS = "";
     private static final String DEFAULT_PARALLELISM = "1";
+    private static final Integer DEFAULT_TIMEOUT = 7200;
 
     private static final ImmutableSet<String> PROPERTIES_SET = new 
ImmutableSet.Builder<String>()
             .add(LABEL)
@@ -72,7 +74,6 @@ public class ExportStmt extends StatementBase {
             .add(LoadStmt.EXEC_MEM_LIMIT)
             .add(LoadStmt.TIMEOUT_PROPERTY)
             .add(LoadStmt.KEY_IN_PARAM_COLUMNS)
-            .add(LoadStmt.TIMEOUT_PROPERTY)
             .add(OutFileClause.PROP_MAX_FILE_SIZE)
             .add(OutFileClause.PROP_DELETE_EXISTING_FILES)
             .add(PropertyAnalyzer.PROPERTIES_COLUMN_SEPARATOR)
@@ -98,6 +99,8 @@ public class ExportStmt extends StatementBase {
 
     private Integer parallelism;
 
+    private Integer timeout;
+
     private String maxFileSize;
     private String deleteExistingFiles;
     private SessionVariable sessionVariables;
@@ -117,12 +120,10 @@ public class ExportStmt extends StatementBase {
         this.brokerDesc = brokerDesc;
         this.columnSeparator = DEFAULT_COLUMN_SEPARATOR;
         this.lineDelimiter = DEFAULT_LINE_DELIMITER;
+        this.timeout = DEFAULT_TIMEOUT;
         this.columns = DEFAULT_COLUMNS;
-        if (ConnectContext.get() != null) {
-            this.sessionVariables = ConnectContext.get().getSessionVariable();
-        } else {
-            this.sessionVariables = VariableMgr.getDefaultSessionVariable();
-        }
+        this.sessionVariables = 
VariableMgr.cloneSessionVariable(Optional.ofNullable(
+                
ConnectContext.get().getSessionVariable()).orElse(VariableMgr.getDefaultSessionVariable()));
     }
 
     public String getColumns() {
@@ -356,6 +357,15 @@ public class ExportStmt extends StatementBase {
         this.maxFileSize = 
properties.getOrDefault(OutFileClause.PROP_MAX_FILE_SIZE, "");
         this.deleteExistingFiles = 
properties.getOrDefault(OutFileClause.PROP_DELETE_EXISTING_FILES, "");
 
+        // timeout
+        String timeoutString = 
properties.getOrDefault(LoadStmt.TIMEOUT_PROPERTY,
+                String.valueOf(DEFAULT_TIMEOUT));
+        try {
+            this.timeout = Integer.parseInt(timeoutString);
+        } catch (NumberFormatException e) {
+            throw new UserException("The value of timeout is invalid!");
+        }
+
         if (properties.containsKey(LABEL)) {
             FeNameFormat.checkLabel(properties.get(LABEL));
         } else {
@@ -422,4 +432,8 @@ public class ExportStmt extends StatementBase {
     public Integer getParallelNum() {
         return parallelism;
     }
+
+    public Integer getTimeout() {
+        return timeout;
+    }
 }
diff --git a/fe/fe-core/src/main/java/org/apache/doris/load/ExportJob.java 
b/fe/fe-core/src/main/java/org/apache/doris/load/ExportJob.java
index 1527ba1ce4c..66b0ea919d0 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/load/ExportJob.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/load/ExportJob.java
@@ -230,7 +230,8 @@ public class ExportJob implements Writable {
         this.parallelNum = stmt.getParallelNum();
         this.exportPath = path;
         this.sessionVariables = stmt.getSessionVariables();
-        this.timeoutSecond = sessionVariables.getQueryTimeoutS();
+        this.timeoutSecond = stmt.getTimeout();
+        this.sessionVariables.setQueryTimeoutS(this.timeoutSecond);
 
         this.qualifiedUser = stmt.getQualifiedUser();
         this.userIdentity = stmt.getUserIdentity();
diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/VariableMgr.java 
b/fe/fe-core/src/main/java/org/apache/doris/qe/VariableMgr.java
index 3588692dd2f..80cf288a32a 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/VariableMgr.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/VariableMgr.java
@@ -252,6 +252,10 @@ public class VariableMgr {
         }
     }
 
+    public static SessionVariable cloneSessionVariable(SessionVariable var) {
+        return SerializationUtils.clone(var);
+    }
+
     // Check if this setVar can be set correctly
     // Do not use ErrorReport.reportDdlException to throw exeception, it will 
set the query state in connection context.
     // But in some case, we do not want to set the query state and need to 
ignore that error.


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

Reply via email to