From 47ade42db98ceb6311e243f141682f859f38baa7 Mon Sep 17 00:00:00 2001 From: Yongqiang YANG Date: Wed, 10 Jul 2024 15:18:07 +0800 Subject: [PATCH 1/4] [fix](readconsistency) avoid table not exist error Query following createting table would throw table not exist error. --- .../src/main/java/org/apache/doris/qe/StmtExecutor.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 6eaeb559b7343c..b9c003eff93b03 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 @@ -725,6 +725,7 @@ private void executeByNereids(TUniqueId queryId) throws Exception { return; } } + syncJournalIfNeeded(); try { ((Command) logicalPlan).run(context, this); } catch (MustFallbackException e) { @@ -759,6 +760,7 @@ private void executeByNereids(TUniqueId queryId) throws Exception { } else { context.getState().setIsQuery(true); // create plan + syncJournalIfNeeded(); planner = new NereidsPlanner(statementContext); if (context.getSessionVariable().isEnableMaterializedViewRewrite()) { planner.addHook(InitMaterializationContextHook.INSTANCE); @@ -805,7 +807,6 @@ public void finalizeQuery() { private void handleQueryWithRetry(TUniqueId queryId) throws Exception { // queue query here - syncJournalIfNeeded(); int retryTime = Config.max_query_retry_time; for (int i = 0; i <= retryTime; i++) { try { @@ -955,6 +956,7 @@ public void executeByLegacy(TUniqueId queryId) throws Exception { } } } else { + syncJournalIfNeeded(); analyzer = new Analyzer(context.getEnv(), context); parsedStmt.analyze(analyzer); parsedStmt.checkPriv(); From d63d942f8a8cf5eb54fec1be3acadd522aa9aa85 Mon Sep 17 00:00:00 2001 From: Yongqiang YANG <98214048+dataroaring@users.noreply.github.com> Date: Wed, 10 Jul 2024 22:15:24 +0800 Subject: [PATCH 2/4] add comment --- .../java/org/apache/doris/qe/StmtExecutor.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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 b9c003eff93b03..d92077093fd892 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 @@ -725,6 +725,12 @@ private void executeByNereids(TUniqueId queryId) throws Exception { return; } } + + // Query following createting table would throw table not exist error. + // For example. + // t1: client issues create table to master fe + // t2: client issues query sql to observer fe, the query would fail due to not exist table in plan phase. + // t3: observer fe receive editlog creating the table from the master fe syncJournalIfNeeded(); try { ((Command) logicalPlan).run(context, this); @@ -760,6 +766,11 @@ private void executeByNereids(TUniqueId queryId) throws Exception { } else { context.getState().setIsQuery(true); // create plan + // Query following createting table would throw table not exist error. + // For example. + // t1: client issues create table to master fe + // t2: client issues query sql to observer fe, the query would fail due to not exist table in plan phase. + // t3: observer fe receive editlog creating the table from the master fe syncJournalIfNeeded(); planner = new NereidsPlanner(statementContext); if (context.getSessionVariable().isEnableMaterializedViewRewrite()) { @@ -956,6 +967,11 @@ public void executeByLegacy(TUniqueId queryId) throws Exception { } } } else { + // Query following createting table would throw table not exist error. + // For example. + // t1: client issues create table to master fe + // t2: client issues query sql to observer fe, the query would fail due to not exist table in plan phase. + // t3: observer fe receive editlog creating the table from the master fe syncJournalIfNeeded(); analyzer = new Analyzer(context.getEnv(), context); parsedStmt.analyze(analyzer); From 2c058055a055b74a284e0907cfd460b512621888 Mon Sep 17 00:00:00 2001 From: Yongqiang YANG <98214048+dataroaring@users.noreply.github.com> Date: Wed, 10 Jul 2024 22:25:22 +0800 Subject: [PATCH 3/4] format --- .../src/main/java/org/apache/doris/qe/StmtExecutor.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 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 d92077093fd892..b9a5351cb98c5c 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 @@ -769,7 +769,8 @@ private void executeByNereids(TUniqueId queryId) throws Exception { // Query following createting table would throw table not exist error. // For example. // t1: client issues create table to master fe - // t2: client issues query sql to observer fe, the query would fail due to not exist table in plan phase. + // t2: client issues query sql to observer fe, the query would fail due to not exist table in + // plan phase. // t3: observer fe receive editlog creating the table from the master fe syncJournalIfNeeded(); planner = new NereidsPlanner(statementContext); @@ -970,7 +971,8 @@ public void executeByLegacy(TUniqueId queryId) throws Exception { // Query following createting table would throw table not exist error. // For example. // t1: client issues create table to master fe - // t2: client issues query sql to observer fe, the query would fail due to not exist table in plan phase. + // t2: client issues query sql to observer fe, the query would fail due to not exist table + // in plan phase. // t3: observer fe receive editlog creating the table from the master fe syncJournalIfNeeded(); analyzer = new Analyzer(context.getEnv(), context); From 95ead5941907bdd1d14a4d5d7f93c13dae9ece49 Mon Sep 17 00:00:00 2001 From: Yongqiang YANG <98214048+dataroaring@users.noreply.github.com> Date: Wed, 10 Jul 2024 22:29:28 +0800 Subject: [PATCH 4/4] Update StmtExecutor.java --- fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 b9a5351cb98c5c..fcd0d25a130320 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 @@ -725,7 +725,7 @@ private void executeByNereids(TUniqueId queryId) throws Exception { return; } } - + // Query following createting table would throw table not exist error. // For example. // t1: client issues create table to master fe