Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix](nereids)let query be able to forwarded to master #40797

Merged
merged 2 commits into from
Sep 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,27 @@ private void executeByNereids(TUniqueId queryId) throws Exception {
}
} else {
context.getState().setIsQuery(true);
if (isForwardToMaster()) {
// some times the follower's meta data is out of date.
// so we need forward the query to master until the meta data is sync with master
if (context.getCommand() == MysqlCommand.COM_STMT_PREPARE) {
throw new UserException("Forward master command is not supported for prepare statement");
}
if (isProxy) {
// This is already a stmt forwarded from other FE.
// If we goes here, 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().getHost() + ") and failed to execute"
+ " because Master FE is not ready. You may need to check FE's status"));
}
redirectStatus = RedirectStatus.NO_FORWARD;
forwardToMaster();
if (masterOpExecutor != null && masterOpExecutor.getQueryId() != null) {
context.setQueryId(masterOpExecutor.getQueryId());
}
return;
}
if (context.getSessionVariable().enableProfile) {
ConnectContext.get().setStatsErrorEstimator(new StatsErrorEstimator());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ public ConnectContext get() {
return ctx;
}
};
new MockUp<Env>() {
@Mock
public boolean isMaster() {
return true;
}
};
}

@Test
Expand Down
Loading