This is an automated email from the ASF dual-hosted git repository.
morrysnow pushed a commit to branch branch-3.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.1 by this push:
new 6eba42446b5 branch-3.1: [opt](Nereids) optimize error message if
nerieds plan timeout #53375 (#53545)
6eba42446b5 is described below
commit 6eba42446b5c74b93add2d42d4a4129d7ecb397c
Author: morrySnow <[email protected]>
AuthorDate: Fri Jul 18 20:09:02 2025 +0800
branch-3.1: [opt](Nereids) optimize error message if nerieds plan timeout
#53375 (#53545)
cherry picked from #53375
---
.../doris/common/profile/SummaryProfile.java | 41 ++++++++++++++++++
.../doris/nereids/errors/QueryPlanningErrors.java | 50 ++++++++++++++++++++++
.../nereids/jobs/scheduler/SimpleJobScheduler.java | 6 +--
.../java/org/apache/doris/qe/AuditLogHelper.java | 40 ++---------------
4 files changed, 98 insertions(+), 39 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/common/profile/SummaryProfile.java
b/fe/fe-core/src/main/java/org/apache/doris/common/profile/SummaryProfile.java
index 2ba5cbc727a..697cdca65bd 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/common/profile/SummaryProfile.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/common/profile/SummaryProfile.java
@@ -1106,4 +1106,45 @@ public class SummaryProfile {
}
return null;
}
+
+ public String getPlanTime() {
+ String planTimesMs = "{"
+ + "\"plan\"" + ":" + this.getPlanTimeMs() + ","
+ + "\"garbage_collect\"" + ":" +
this.getNereidsGarbageCollectionTimeMs() + ","
+ + "\"lock_tables\"" + ":" + this.getNereidsLockTableTimeMs() +
","
+ + "\"analyze\"" + ":" + this.getNereidsAnalysisTimeMs() + ","
+ + "\"rewrite\"" + ":" + this.getNereidsRewriteTimeMs() + ","
+ + "\"fold_const_by_be\"" + ":" +
this.getNereidsBeFoldConstTimeMs() + ","
+ + "\"collect_partitions\"" + ":" +
this.getNereidsCollectTablePartitionTimeMs() + ","
+ + "\"optimize\"" + ":" + this.getNereidsOptimizeTimeMs() + ","
+ + "\"translate\"" + ":" + this.getNereidsTranslateTimeMs() +
","
+ + "\"init_scan_node\"" + ":" + this.getInitScanNodeTimeMs() +
","
+ + "\"finalize_scan_node\"" + ":" +
this.getFinalizeScanNodeTimeMs() + ","
+ + "\"create_scan_range\"" + ":" +
this.getCreateScanRangeTimeMs() + ","
+ + "\"distribute\"" + ":" + this.getNereidsDistributeTimeMs()
+ + "}";
+ return planTimesMs;
+ }
+
+ public String getMetaTime() {
+ return "{"
+ + "\"get_partition_version_time_ms\"" + ":" +
this.getGetPartitionVersionTime() + ","
+ + "\"get_partition_version_count_has_data\"" + ":" +
this.getGetPartitionVersionByHasDataCount() + ","
+ + "\"get_partition_version_count\"" + ":" +
this.getGetPartitionVersionCount() + ","
+ + "\"get_table_version_time_ms\"" + ":" +
this.getGetTableVersionTime() + ","
+ + "\"get_table_version_count\"" + ":" +
this.getGetTableVersionCount()
+ + "}";
+ }
+
+ public String getScheduleTime() {
+ return "{"
+ + "\"schedule_time_ms\"" + ":" + this.getScheduleTimeMs() + ","
+ + "\"fragment_assign_time_ms\"" + ":" +
this.getFragmentAssignTimsMs() + ","
+ + "\"fragment_serialize_time_ms\"" + ":" +
this.getFragmentSerializeTimeMs() + ","
+ + "\"fragment_rpc_phase_1_time_ms\"" + ":" +
this.getFragmentRPCPhase1TimeMs() + ","
+ + "\"fragment_rpc_phase_2_time_ms\"" + ":" +
this.getFragmentRPCPhase2TimeMs() + ","
+ + "\"fragment_compressed_size_byte\"" + ":" +
this.getFragmentCompressedSizeByte() + ","
+ + "\"fragment_rpc_count\"" + ":" + this.getFragmentRPCCount()
+ + "}";
+ }
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/errors/QueryPlanningErrors.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/errors/QueryPlanningErrors.java
new file mode 100644
index 00000000000..9647df55bd9
--- /dev/null
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/errors/QueryPlanningErrors.java
@@ -0,0 +1,50 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.nereids.errors;
+
+import org.apache.doris.common.profile.SummaryProfile;
+import org.apache.doris.nereids.exceptions.AnalysisException;
+import org.apache.doris.qe.SessionVariable;
+
+/**
+ * Exception packaging to improve code readability.
+ */
+public class QueryPlanningErrors {
+
+ /**
+ * plan timeout error message.
+ *
+ * @param elapsedS plan use time, unit is second
+ * @param timeoutS timeout, unit is second
+ * @param profile summary profile used to get time consumption details
+ *
+ * @return exception with timeout message
+ */
+ public static AnalysisException planTimeoutError(long elapsedS, long
timeoutS, SummaryProfile profile) {
+ long parseTime = profile.getParseSqlTimeMs();
+ String planTime = profile.getPlanTime();
+ return new AnalysisException(String.format("Nereids cost too much time
(%ss > %ss)."
+ + " You should increment timeout by set '%s'"
+ + " or disable check timeout by set '%s' to false."
+ + " Time consuming details,"
+ + " parse time: %dms, plan time: %s",
+ elapsedS, timeoutS,
+ SessionVariable.NEREIDS_TIMEOUT_SECOND,
SessionVariable.ENABLE_NEREIDS_TIMEOUT,
+ parseTime, planTime));
+ }
+}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/scheduler/SimpleJobScheduler.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/scheduler/SimpleJobScheduler.java
index 1354f895a3c..82c06c4ced6 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/scheduler/SimpleJobScheduler.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/scheduler/SimpleJobScheduler.java
@@ -18,7 +18,7 @@
package org.apache.doris.nereids.jobs.scheduler;
import org.apache.doris.nereids.CascadesContext;
-import org.apache.doris.nereids.exceptions.AnalysisException;
+import org.apache.doris.nereids.errors.QueryPlanningErrors;
import org.apache.doris.nereids.jobs.Job;
import org.apache.doris.qe.SessionVariable;
@@ -37,8 +37,8 @@ public class SimpleJobScheduler implements JobScheduler {
long elapsedS =
context.getStatementContext().getStopwatch().elapsed(TimeUnit.MILLISECONDS) /
1000;
if (sessionVariable.enableNereidsTimeout
&& elapsedS > sessionVariable.nereidsTimeoutSecond) {
- throw new AnalysisException(String.format("Nereids cost too
much time ( %ds > %ds",
- elapsedS, sessionVariable.nereidsTimeoutSecond));
+ throw QueryPlanningErrors.planTimeoutError(elapsedS,
sessionVariable.nereidsTimeoutSecond,
+
context.getConnectContext().getExecutor().getSummaryProfile());
}
Job job = pool.pop();
job.execute();
diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/AuditLogHelper.java
b/fe/fe-core/src/main/java/org/apache/doris/qe/AuditLogHelper.java
index 66670f3230d..af9ef8ce511 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/AuditLogHelper.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/AuditLogHelper.java
@@ -264,43 +264,11 @@ public class AuditLogHelper {
// parse time
auditEventBuilder.setParseTimeMs(summaryProfile.getParseSqlTimeMs());
// plan time
- String planTimesMs = "{"
- + "\"plan\"" + ":" + summaryProfile.getPlanTimeMs() + ","
- + "\"garbage_collect\"" + ":" +
summaryProfile.getNereidsGarbageCollectionTimeMs() + ","
- + "\"lock_tables\"" + ":" +
summaryProfile.getNereidsLockTableTimeMs() + ","
- + "\"analyze\"" + ":" +
summaryProfile.getNereidsAnalysisTimeMs() + ","
- + "\"rewrite\"" + ":" +
summaryProfile.getNereidsRewriteTimeMs() + ","
- + "\"fold_const_by_be\"" + ":" +
summaryProfile.getNereidsBeFoldConstTimeMs() + ","
- + "\"collect_partitions\"" + ":" +
summaryProfile.getNereidsCollectTablePartitionTimeMs() + ","
- + "\"optimize\"" + ":" +
summaryProfile.getNereidsOptimizeTimeMs() + ","
- + "\"translate\"" + ":" +
summaryProfile.getNereidsTranslateTimeMs() + ","
- + "\"init_scan_node\"" + ":" +
summaryProfile.getInitScanNodeTimeMs() + ","
- + "\"finalize_scan_node\"" + ":" +
summaryProfile.getFinalizeScanNodeTimeMs() + ","
- + "\"create_scan_range\"" + ":" +
summaryProfile.getCreateScanRangeTimeMs() + ","
- + "\"distribute\"" + ":" +
summaryProfile.getNereidsDistributeTimeMs()
- + "}";
- auditEventBuilder.setPlanTimesMs(planTimesMs);
- // get meta time
- String metaTimeMs = "{"
- + "\"get_partition_version_time_ms\"" + ":" +
summaryProfile.getGetPartitionVersionTime() + ","
- + "\"get_partition_version_count_has_data\""
- + ":" +
summaryProfile.getGetPartitionVersionByHasDataCount() + ","
- + "\"get_partition_version_count\"" + ":" +
summaryProfile.getGetPartitionVersionCount() + ","
- + "\"get_table_version_time_ms\"" + ":" +
summaryProfile.getGetTableVersionTime() + ","
- + "\"get_table_version_count\"" + ":" +
summaryProfile.getGetTableVersionCount()
- + "}";
- auditEventBuilder.setGetMetaTimeMs(metaTimeMs);
+ auditEventBuilder.setPlanTimesMs(summaryProfile.getPlanTime());
+ // meta time
+ auditEventBuilder.setGetMetaTimeMs(summaryProfile.getMetaTime());
// schedule time
- String scheduleTimeMs = "{"
- + "\"schedule_time_ms\"" + ":" +
summaryProfile.getScheduleTimeMs() + ","
- + "\"fragment_assign_time_ms\"" + ":" +
summaryProfile.getFragmentAssignTimsMs() + ","
- + "\"fragment_serialize_time_ms\"" + ":" +
summaryProfile.getFragmentSerializeTimeMs() + ","
- + "\"fragment_rpc_phase_1_time_ms\"" + ":" +
summaryProfile.getFragmentRPCPhase1TimeMs() + ","
- + "\"fragment_rpc_phase_2_time_ms\"" + ":" +
summaryProfile.getFragmentRPCPhase2TimeMs() + ","
- + "\"fragment_compressed_size_byte\"" + ":" +
summaryProfile.getFragmentCompressedSizeByte() + ","
- + "\"fragment_rpc_count\"" + ":" +
summaryProfile.getFragmentRPCCount()
- + "}";
- auditEventBuilder.setScheduleTimeMs(scheduleTimeMs);
+
auditEventBuilder.setScheduleTimeMs(summaryProfile.getScheduleTime());
// changed variables
if (ctx.sessionVariable != null) {
List<List<String>> changedVars =
VariableMgr.dumpChangedVars(ctx.sessionVariable);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]