This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-4.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-4.1 by this push:
new 2677763d018 branch-4.1: [fix](fe) Skip local callbacks after failed
master forwarding #70348 (#70732)
2677763d018 is described below
commit 2677763d0189eac5025c8de9cf783378486e55f4
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Mon Nov 23 08:19:22 2026 +0800
branch-4.1: [fix](fe) Skip local callbacks after failed master forwarding
#70348 (#70732)
Cherry-picked from #70348
Co-authored-by: Calvin Kirs <[email protected]>
---
.../java/org/apache/doris/qe/StmtExecutor.java | 4 +
.../doris/qe/StmtExecutorForwardFailureTest.java | 87 ++++++++++++++++++++++
2 files changed, 91 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 ccb79973361..74f1c44789c 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
@@ -1207,6 +1207,10 @@ public class StmtExecutor {
}
masterOpExecutor.setMoreStmtExists(moreStmtExists);
masterOpExecutor.execute();
+ // A successful RPC can still carry a failed statement. Do not apply
its local changes.
+ if
(MysqlStateType.ERR.name().equalsIgnoreCase(masterOpExecutor.getProxyStatus()))
{
+ return;
+ }
if (parsedStmt instanceof LogicalPlanAdapter) {
// for nereids command
if (((LogicalPlanAdapter) parsedStmt).getLogicalPlan() instanceof
Forward) {
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/qe/StmtExecutorForwardFailureTest.java
b/fe/fe-core/src/test/java/org/apache/doris/qe/StmtExecutorForwardFailureTest.java
new file mode 100644
index 00000000000..0e2e70eb9cf
--- /dev/null
+++
b/fe/fe-core/src/test/java/org/apache/doris/qe/StmtExecutorForwardFailureTest.java
@@ -0,0 +1,87 @@
+// 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.qe;
+
+import org.apache.doris.analysis.StatementBase;
+import org.apache.doris.common.DdlException;
+import org.apache.doris.common.jmockit.Deencapsulation;
+import org.apache.doris.nereids.glue.LogicalPlanAdapter;
+import org.apache.doris.nereids.parser.NereidsParser;
+import org.apache.doris.nereids.trees.plans.commands.SetOptionsCommand;
+import org.apache.doris.utframe.TestWithFeService;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.mockito.MockedConstruction;
+import org.mockito.Mockito;
+
+import java.nio.ByteBuffer;
+
+public class StmtExecutorForwardFailureTest extends TestWithFeService {
+ @Test
+ public void testFailedForwardDoesNotModifyReadOnlyVariable() throws
Exception {
+ String originalVersionComment = GlobalVariable.versionComment;
+ String sql = "set global version_comment = 'rejected_forward'";
+ StatementBase statement = new NereidsParser().parseSQL(sql).get(0);
+ statement.setOrigStmt(new OriginStatement(sql, 0));
+ StmtExecutor executor = new StmtExecutor(connectContext, statement);
+ SetOptionsCommand command = (SetOptionsCommand) ((LogicalPlanAdapter)
statement).getLogicalPlan();
+ DdlException rejected = Assertions.assertThrows(DdlException.class,
+ () -> command.run(connectContext, executor));
+ Assertions.assertTrue(rejected.getMessage().contains("read only"));
+ ByteBuffer errorPacket = ByteBuffer.wrap(new byte[] {(byte) 0xff, 1,
2});
+
+ try (MockedConstruction<MasterOpExecutor> masters =
Mockito.mockConstruction(MasterOpExecutor.class,
+ (master, construction) -> {
+
Mockito.when(master.getProxyStatus()).thenReturn(QueryState.MysqlStateType.ERR.name());
+
Mockito.when(master.getErrMsg()).thenReturn(rejected.getMessage());
+
Mockito.when(master.getOutputPacket()).thenReturn(errorPacket);
+ })) {
+ Deencapsulation.invoke(executor, "forwardToMaster");
+
+ Assertions.assertEquals(1, masters.constructed().size());
+ Assertions.assertEquals(originalVersionComment,
GlobalVariable.versionComment);
+ Assertions.assertEquals(QueryState.MysqlStateType.ERR.name(),
executor.getProxyStatus());
+ Assertions.assertEquals(rejected.getMessage(),
executor.getProxyErrMsg());
+ Assertions.assertSame(errorPacket, executor.getOutputPacket());
+ } finally {
+ GlobalVariable.versionComment = originalVersionComment;
+ }
+ }
+
+ @Test
+ public void testSuccessfulForwardUpdatesSessionVariable() throws Exception
{
+ int originalTimeout =
connectContext.getSessionVariable().getQueryTimeoutS();
+ String sql = "set global query_timeout = 123";
+ StatementBase statement = new NereidsParser().parseSQL(sql).get(0);
+ statement.setOrigStmt(new OriginStatement(sql, 0));
+ StmtExecutor executor = new StmtExecutor(connectContext, statement);
+
+ try (MockedConstruction<MasterOpExecutor> masters =
Mockito.mockConstruction(MasterOpExecutor.class,
+ (master, construction) -> Mockito.when(master.getProxyStatus())
+ .thenReturn(QueryState.MysqlStateType.OK.name()))) {
+ Deencapsulation.invoke(executor, "forwardToMaster");
+
+ Assertions.assertEquals(1, masters.constructed().size());
+ Assertions.assertEquals(123,
connectContext.getSessionVariable().getQueryTimeoutS());
+ Assertions.assertEquals(QueryState.MysqlStateType.OK.name(),
executor.getProxyStatus());
+ } finally {
+
connectContext.getSessionVariable().setQueryTimeoutS(originalTimeout);
+ }
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]