You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2023/04/24 05:29:38 UTC
[doris] branch master updated: [fix](Nereids) should not fallback to legacy planner when execution failed (#18847)
This is an automated email from the ASF dual-hosted git repository.
morrysnow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new d368326cc2 [fix](Nereids) should not fallback to legacy planner when execution failed (#18847)
d368326cc2 is described below
commit d368326cc205c9aaa8190ee7915faa0264c9f3f8
Author: morrySnow <10...@users.noreply.github.com>
AuthorDate: Mon Apr 24 13:29:29 2023 +0800
[fix](Nereids) should not fallback to legacy planner when execution failed (#18847)
---
.../java/org/apache/doris/qe/StmtExecutor.java | 120 +++++++++++----------
1 file changed, 64 insertions(+), 56 deletions(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java b/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java
index 39300235b5..78907a2081 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java
@@ -436,11 +436,13 @@ public class StmtExecutor implements ProfileWriter {
executeByNereids(queryId);
} catch (NereidsException e) {
// try to fall back to legacy planner
+ LOG.warn("nereids cannot process statement\n" + originStmt.originStmt
+ + "\n because of " + e.getMessage(), e);
if (!context.getSessionVariable().enableFallbackToOriginalPlanner) {
LOG.warn("Analyze failed. {}", context.getQueryIdentifier(), e);
throw e.getException();
}
- LOG.warn("fall back to legacy planner, because: {}", e.getMessage(), e);
+ LOG.info("fall back to legacy planner");
parsedStmt = null;
context.getState().setNereids(false);
executeByLegacy(queryId);
@@ -483,77 +485,83 @@ public class StmtExecutor implements ProfileWriter {
return false;
}
- private void executeByNereids(TUniqueId queryId) {
+ private void executeByNereids(TUniqueId queryId) throws Exception {
+ LOG.info("Nereids start to execute query:\n {}", originStmt.originStmt);
context.setQueryId(queryId);
context.setStartTime();
plannerProfile.setQueryBeginTime();
context.setStmtId(STMT_ID_GENERATOR.incrementAndGet());
- try {
- parseByNereids();
- Preconditions.checkState(parsedStmt instanceof LogicalPlanAdapter,
- "Nereids only process LogicalPlanAdapter, but parsedStmt is " + parsedStmt.getClass().getName());
- context.getState().setNereids(true);
- LogicalPlan logicalPlan = ((LogicalPlanAdapter) parsedStmt).getLogicalPlan();
- if (logicalPlan instanceof Command) {
- if (logicalPlan instanceof Forward) {
- redirectStatus = ((Forward) logicalPlan).toRedirectStatus();
- if (isForwardToMaster()) {
- if (isProxy) {
- // This is already a stmt forwarded from other FE.
- // If goes here, which means we can't find a valid Master FE(some error happens).
- // To avoid endless forward, throw exception here.
- throw new UserException("The statement has been forwarded to master FE("
- + Env.getCurrentEnv().getSelfNode().getIp() + ") and failed to execute"
- + " because Master FE is not ready. You may need to check FE's status");
- }
- forwardToMaster();
- if (masterOpExecutor != null && masterOpExecutor.getQueryId() != null) {
- context.setQueryId(masterOpExecutor.getQueryId());
- }
- return;
+ parseByNereids();
+ Preconditions.checkState(parsedStmt instanceof LogicalPlanAdapter,
+ "Nereids only process LogicalPlanAdapter, but parsedStmt is " + parsedStmt.getClass().getName());
+ context.getState().setNereids(true);
+ LogicalPlan logicalPlan = ((LogicalPlanAdapter) parsedStmt).getLogicalPlan();
+ if (logicalPlan instanceof Command) {
+ if (logicalPlan instanceof Forward) {
+ redirectStatus = ((Forward) logicalPlan).toRedirectStatus();
+ if (isForwardToMaster()) {
+ if (isProxy) {
+ // This is already a stmt forwarded from other FE.
+ // If goes here, which means we can't find a valid Master FE(some error happens).
+ // To avoid endless forward, throw exception here.
+ throw new NereidsException(new UserException("The statement has been forwarded to master FE("
+ + Env.getCurrentEnv().getSelfNode().getIp() + ") and failed to execute"
+ + " because Master FE is not ready. You may need to check FE's status"));
+ }
+ forwardToMaster();
+ if (masterOpExecutor != null && masterOpExecutor.getQueryId() != null) {
+ context.setQueryId(masterOpExecutor.getQueryId());
}
- }
- try {
- ((Command) logicalPlan).run(context, this);
- } catch (QueryStateException e) {
- LOG.warn("", e);
- context.setState(e.getQueryState());
- } catch (UserException e) {
- // Return message to info client what happened.
- LOG.warn("DDL statement({}) process failed.", originStmt.originStmt, e);
- context.getState().setError(e.getMysqlErrorCode(), e.getMessage());
- } catch (Exception e) {
- // Maybe our bug
- LOG.warn("DDL statement(" + originStmt.originStmt + ") process failed.", e);
- context.getState().setError(ErrorCode.ERR_UNKNOWN_ERROR, "Unexpected exception: " + e.getMessage());
- }
- } else {
- context.getState().setIsQuery(true);
- if (context.getSessionVariable().enableProfile) {
- ConnectContext.get().setStatsErrorEstimator(new StatsErrorEstimator());
- }
- // create plan
- planner = new NereidsPlanner(statementContext);
- planner.plan(parsedStmt, context.getSessionVariable().toThrift());
- if (checkBlockRules()) {
return;
}
- plannerProfile.setQueryPlanFinishTime();
- handleQueryWithRetry(queryId);
}
- } catch (Exception e) {
- throw new NereidsException(new AnalysisException("Unexpected exception: " + e.getMessage(), e));
+ try {
+ ((Command) logicalPlan).run(context, this);
+ } catch (QueryStateException e) {
+ LOG.warn("", e);
+ context.setState(e.getQueryState());
+ throw new NereidsException(e);
+ } catch (UserException e) {
+ // Return message to info client what happened.
+ LOG.warn("DDL statement({}) process failed.", originStmt.originStmt, e);
+ context.getState().setError(e.getMysqlErrorCode(), e.getMessage());
+ throw new NereidsException("DDL statement(" + originStmt.originStmt + ") process failed", e);
+ } catch (Exception e) {
+ // Maybe our bug
+ LOG.warn("DDL statement(" + originStmt.originStmt + ") process failed.", e);
+ context.getState().setError(ErrorCode.ERR_UNKNOWN_ERROR, "Unexpected exception: " + e.getMessage());
+ throw new NereidsException("DDL statement(" + originStmt.originStmt + ") process failed.", e);
+ }
+ } else {
+ context.getState().setIsQuery(true);
+ if (context.getSessionVariable().enableProfile) {
+ ConnectContext.get().setStatsErrorEstimator(new StatsErrorEstimator());
+ }
+ // create plan
+ planner = new NereidsPlanner(statementContext);
+ try {
+ planner.plan(parsedStmt, context.getSessionVariable().toThrift());
+ } catch (Exception e) {
+ LOG.warn("Nereids plan query failed:\n{}", originStmt.originStmt);
+ throw new NereidsException(new AnalysisException("Unexpected exception: " + e.getMessage(), e));
+ }
+ if (checkBlockRules()) {
+ return;
+ }
+ plannerProfile.setQueryPlanFinishTime();
+ handleQueryWithRetry(queryId);
}
}
- private void parseByNereids() throws AnalysisException {
+ private void parseByNereids() {
if (parsedStmt != null) {
return;
}
List<StatementBase> statements = new NereidsParser().parseSQL(originStmt.originStmt);
if (statements.size() <= originStmt.idx) {
- throw new AnalysisException("Nereids parse failed. Parser get " + statements.size() + " statements,"
- + " but we need at least " + originStmt.idx + " statements.");
+ throw new NereidsException(
+ new AnalysisException("Nereids parse failed. Parser get " + statements.size() + " statements,"
+ + " but we need at least " + originStmt.idx + " statements."));
}
parsedStmt = statements.get(originStmt.idx);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org