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 2023/03/01 08:27:11 UTC
[iotdb] branch master updated: [IOTDB-5594] Update timeout after completing logical plan and distribution plan
This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 6135831f22 [IOTDB-5594] Update timeout after completing logical plan and distribution plan
6135831f22 is described below
commit 6135831f2280e565425444099ad63fd406d198a7
Author: Liao Lanyu <14...@qq.com>
AuthorDate: Wed Mar 1 16:27:03 2023 +0800
[IOTDB-5594] Update timeout after completing logical plan and distribution plan
---
.../db/mpp/plan/execution/QueryExecution.java | 35 ++++++++++++++--------
1 file changed, 23 insertions(+), 12 deletions(-)
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 3084cdbc6d..1d0bec9209 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
@@ -199,20 +199,14 @@ public class QueryExecution implements IQueryExecution {
return;
}
- // only update query operation's timeout because we will never limit write operation's execution
- // time
- if (isQuery()) {
- long currentTime = System.currentTimeMillis();
- long remainTime = context.getTimeOut() - (currentTime - context.getStartTime());
- if (remainTime <= 0) {
- throw new QueryTimeoutRuntimeException(
- context.getStartTime(), currentTime, context.getTimeOut());
- }
- context.setTimeOut(remainTime);
- }
-
+ // check timeout for query first
+ checkTimeOutForQuery();
doLogicalPlan();
doDistributedPlan();
+ // update timeout after finishing plan stage
+ context.setTimeOut(
+ context.getTimeOut() - (System.currentTimeMillis() - context.getStartTime()));
+
stateMachine.transitionToPlanned();
if (context.getQueryType() == QueryType.READ) {
initResultHandle();
@@ -221,6 +215,18 @@ public class QueryExecution implements IQueryExecution {
schedule();
}
+ private void checkTimeOutForQuery() {
+ // only check query operation's timeout because we will never limit write operation's execution
+ // time
+ if (isQuery()) {
+ long currentTime = System.currentTimeMillis();
+ if (currentTime >= context.getTimeOut() + context.getStartTime()) {
+ throw new QueryTimeoutRuntimeException(
+ context.getStartTime(), currentTime, context.getTimeOut());
+ }
+ }
+ }
+
private ExecutionResult retry() {
if (retryCount >= MAX_RETRY_COUNT) {
logger.warn("[ReachMaxRetryCount]");
@@ -316,6 +322,8 @@ public class QueryExecution implements IQueryExecution {
logger.debug(
"logical plan is: \n {}", PlanNodeUtil.nodeToString(this.logicalPlan.getRootNode()));
}
+ // check timeout after building logical plan because it could be time-consuming in some cases.
+ checkTimeOutForQuery();
}
// Generate the distributed plan and split it into fragments
@@ -333,6 +341,9 @@ public class QueryExecution implements IQueryExecution {
distributedPlan.getInstances().size(),
printFragmentInstances(distributedPlan.getInstances()));
}
+ // check timeout after building distribution plan because it could be time-consuming in some
+ // cases.
+ checkTimeOutForQuery();
}
private String printFragmentInstances(List<FragmentInstance> instances) {