From d2c1cddd552c4c8fb0137727961e8aa99449971a Mon Sep 17 00:00:00 2001 From: EmmyMiao87 <522274284@qq.com> Date: Wed, 16 Jun 2021 09:40:53 +0800 Subject: [PATCH] [Bug-fix] Avoid using 'QueryDetail' in planning stage (#6018) QueryDetail is used to statistic the current query details. This property will only be set when the query starts to execute. So in the query planning stage, using this attribute in the first query will cause 'NullPointerException'. After that, this attribute retains the value of the previous query until it is updated by the subsequent process. Because code of 'colocateagg' uses this attribute incorrectly in its planning, it causes 'NullPointerException' when clients like pymysql connect to doris and send the first query. Fixed #6017 --- .../main/java/org/apache/doris/planner/DistributedPlanner.java | 2 +- .../src/main/java/org/apache/doris/qe/ConnectContext.java | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/planner/DistributedPlanner.java b/fe/fe-core/src/main/java/org/apache/doris/planner/DistributedPlanner.java index b0126bc53d..f03a5e2c94 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/planner/DistributedPlanner.java +++ b/fe/fe-core/src/main/java/org/apache/doris/planner/DistributedPlanner.java @@ -988,7 +988,7 @@ public class DistributedPlanner { private boolean canColocateAgg(AggregateInfo aggregateInfo, List childFragmentDataPartition) { // Condition1 if (ConnectContext.get().getSessionVariable().isDisableColocatePlan()) { - LOG.debug("Agg node is not colocate in:" + ConnectContext.get().getQueryDetail().getQueryId() + LOG.debug("Agg node is not colocate in:" + ConnectContext.get().queryId() + ", reason:" + DistributedPlanColocateRule.SESSION_DISABLED); return false; } diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectContext.java b/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectContext.java index 98c104e142..727e333ce9 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectContext.java +++ b/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectContext.java @@ -98,6 +98,9 @@ public class ConnectContext { protected String remoteIP; + // This is used to statistic the current query details. + // This property will only be set when the query starts to execute. + // So in the query planning stage, do not use any value in this attribute. protected QueryDetail queryDetail; public static ConnectContext get() {