You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ja...@apache.org on 2022/07/21 07:04:54 UTC

[iotdb] 01/01: fix timeout problem while using cli

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

jackietien pushed a commit to branch FixTimeout
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 0229d97dc9c47bfffa8330758c7a38479d9ce10a
Author: JackieTien97 <ja...@gmail.com>
AuthorDate: Thu Jul 21 15:04:33 2022 +0800

    fix timeout problem while using cli
---
 .../org/apache/iotdb/db/mpp/plan/Coordinator.java  | 47 +++++++---------------
 1 file changed, 14 insertions(+), 33 deletions(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/plan/Coordinator.java b/server/src/main/java/org/apache/iotdb/db/mpp/plan/Coordinator.java
index 3a4b0aaf44..70ab26f83b 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/plan/Coordinator.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/plan/Coordinator.java
@@ -122,21 +122,26 @@ public class Coordinator {
       if (sql != null && sql.length() > 0) {
         LOGGER.info("start executing sql: {}", sql);
       }
+      MPPQueryContext queryContext =
+          new MPPQueryContext(
+              sql,
+              globalQueryId,
+              session,
+              DataNodeEndPoints.LOCAL_HOST_DATA_BLOCK_ENDPOINT,
+              DataNodeEndPoints.LOCAL_HOST_INTERNAL_ENDPOINT);
       IQueryExecution execution =
           createQueryExecution(
               statement,
-              new MPPQueryContext(
-                  sql,
-                  globalQueryId,
-                  session,
-                  DataNodeEndPoints.LOCAL_HOST_DATA_BLOCK_ENDPOINT,
-                  DataNodeEndPoints.LOCAL_HOST_INTERNAL_ENDPOINT),
+              queryContext,
               partitionFetcher,
               schemaFetcher,
-              timeOut,
+              timeOut > 0 ? timeOut : config.getQueryTimeoutThreshold(),
               startTime);
       if (execution.isQuery()) {
         queryExecutionMap.put(queryId, execution);
+      } else {
+        // we won't limit write operation's execution time
+        queryContext.setTimeOut(Long.MAX_VALUE);
       }
       execution.start();
 
@@ -152,32 +157,8 @@ public class Coordinator {
       String sql,
       IPartitionFetcher partitionFetcher,
       ISchemaFetcher schemaFetcher) {
-    long startTime = System.currentTimeMillis();
-    QueryId globalQueryId = queryIdGenerator.createNextQueryId();
-    try (SetThreadName queryName = new SetThreadName(globalQueryId.getId())) {
-      if (sql != null && sql.length() > 0) {
-        LOGGER.info("start executing sql: {}", sql);
-      }
-      IQueryExecution execution =
-          createQueryExecution(
-              statement,
-              new MPPQueryContext(
-                  sql,
-                  globalQueryId,
-                  session,
-                  DataNodeEndPoints.LOCAL_HOST_DATA_BLOCK_ENDPOINT,
-                  DataNodeEndPoints.LOCAL_HOST_INTERNAL_ENDPOINT),
-              partitionFetcher,
-              schemaFetcher,
-              Long.MAX_VALUE,
-              startTime);
-      if (execution.isQuery()) {
-        queryExecutionMap.put(queryId, execution);
-      }
-      execution.start();
-
-      return execution.getStatus();
-    }
+    return execute(
+        statement, queryId, session, sql, partitionFetcher, schemaFetcher, Long.MAX_VALUE);
   }
 
   public IQueryExecution getQueryExecution(Long queryId) {