This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch rel/1.1
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/rel/1.1 by this push:
new 1beec2730c [IOTDB-5594] Update timeout after completing logical plan
and distribution plan
1beec2730c is described below
commit 1beec2730cf82f6756843387bcaeecc80a1f1342
Author: Liao Lanyu <[email protected]>
AuthorDate: Thu Mar 2 08:56:30 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) {