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/10/17 04:04:00 UTC

[iotdb] 01/01: Add detailed error messages while query is time out

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

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

commit 8a9ebff77edd8e4d4344f5d9095cb8e7ff62e8bc
Author: JackieTien97 <ja...@gmail.com>
AuthorDate: Mon Oct 17 09:43:11 2022 +0800

    Add detailed error messages while query is time out
---
 .../iotdb/db/exception/query/QueryTimeoutRuntimeException.java   | 9 +++++++++
 .../org/apache/iotdb/db/mpp/plan/execution/QueryExecution.java   | 6 ++++--
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/exception/query/QueryTimeoutRuntimeException.java b/server/src/main/java/org/apache/iotdb/db/exception/query/QueryTimeoutRuntimeException.java
index 84072e2bdd..47829294d3 100644
--- a/server/src/main/java/org/apache/iotdb/db/exception/query/QueryTimeoutRuntimeException.java
+++ b/server/src/main/java/org/apache/iotdb/db/exception/query/QueryTimeoutRuntimeException.java
@@ -24,6 +24,9 @@ public class QueryTimeoutRuntimeException extends RuntimeException {
   public static final String TIMEOUT_EXCEPTION_MESSAGE =
       "Current query is time out, please check your statement or modify timeout parameter.";
 
+  public static final String QUERY_TIMEOUT_EXCEPTION_MESSAGE =
+      "Current query is time out, query start time is %d, ddl is %d, current time is %d, please check your statement or modify timeout parameter.";
+
   public QueryTimeoutRuntimeException(String message, Throwable cause) {
     super(message, cause);
   }
@@ -31,4 +34,10 @@ public class QueryTimeoutRuntimeException extends RuntimeException {
   public QueryTimeoutRuntimeException() {
     super(TIMEOUT_EXCEPTION_MESSAGE);
   }
+
+  public QueryTimeoutRuntimeException(long startTime, long currentTime, long timeout) {
+    super(
+        String.format(
+            QUERY_TIMEOUT_EXCEPTION_MESSAGE, startTime, startTime + timeout, currentTime));
+  }
 }
diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/QueryExecution.java b/server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/QueryExecution.java
index 788403fb58..b525f1cf8f 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/QueryExecution.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/QueryExecution.java
@@ -173,9 +173,11 @@ public class QueryExecution implements IQueryExecution {
       }
       return;
     }
-    long remainTime = context.getTimeOut() - (System.currentTimeMillis() - context.getStartTime());
+    long currentTime = System.currentTimeMillis();
+    long remainTime = context.getTimeOut() - (currentTime - context.getStartTime());
     if (remainTime <= 0) {
-      throw new QueryTimeoutRuntimeException();
+      throw new QueryTimeoutRuntimeException(
+          context.getStartTime(), currentTime, context.getTimeOut());
     }
     context.setTimeOut(remainTime);