This is an automated email from the ASF dual-hosted git repository.
dataroaring pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.0 by this push:
new 92da0c586b7 branch-3.0: [fix](audit log) fix audit log return rows
incorrect when statement need forward (#54548) (#55053)
92da0c586b7 is described below
commit 92da0c586b774e4aa06aa237bea95361fff608b3
Author: hui lai <[email protected]>
AuthorDate: Wed Aug 20 21:45:19 2025 +0800
branch-3.0: [fix](audit log) fix audit log return rows incorrect when
statement need forward (#54548) (#55053)
pick #54548
If insert into request to follower, ReturnRows in audit log always 0:
```
[query] |QueryId=178cb3b149684de9-87f3c24149b1e50b|Timestamp=2025-08-11
11:53:30.132|Client=174.58.0.1:59086|User=root|FeIp=174.58.1.2|Ctl=internal|Db=test_insert_from_follower|State=OK|ErrorCode=0|ErrorMessage=|Time(ms)=145|CpuTimeMS=0|PeakMemoryBytes=1025152|ScanBytes=0|ScanRows=0|ReturnRows=0|ShuffleSendRows=0|ShuffleSendBytes=0|SpillWriteBytesToLocalStorage=0|SpillReadBytesFromLocalStorage=0|ScanBytesFromLocalStorage=0|ScanBytesFromRemoteStorage=0|ParseTimeMs=9|PlanTimesMs={"plan"
[...]
```
---
.../java/org/apache/doris/qe/ConnectProcessor.java | 1 +
.../java/org/apache/doris/qe/FEOpExecutor.java | 3 ++
gensrc/thrift/FrontendService.thrift | 1 +
.../insert/test_insert_from_follower.groovy | 62 ++++++++++++++++++++++
4 files changed, 67 insertions(+)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectProcessor.java
b/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectProcessor.java
index 168eaab9f6f..8ca722894f7 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectProcessor.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectProcessor.java
@@ -775,6 +775,7 @@ public abstract class ConnectProcessor {
result.setStatus(ctx.getState().toString());
if (ctx.getState().getStateType() == MysqlStateType.OK) {
result.setStatusCode(0);
+ result.setAffectedRows(ctx.getState().getAffectedRows());
} else {
ErrorCode errorCode = ctx.getState().getErrorCode();
if (errorCode != null) {
diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/FEOpExecutor.java
b/fe/fe-core/src/main/java/org/apache/doris/qe/FEOpExecutor.java
index 3914d7ecdab..b1b519b15be 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/FEOpExecutor.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/FEOpExecutor.java
@@ -67,6 +67,9 @@ public class FEOpExecutor {
public void execute() throws Exception {
result = forward(feAddr, buildStmtForwardParams());
+ if (result.isSetAffectedRows()) {
+ ctx.updateReturnRows((int) result.getAffectedRows());
+ }
}
public void cancel() throws Exception {
diff --git a/gensrc/thrift/FrontendService.thrift
b/gensrc/thrift/FrontendService.thrift
index 174ac9989d1..236d11917dc 100644
--- a/gensrc/thrift/FrontendService.thrift
+++ b/gensrc/thrift/FrontendService.thrift
@@ -632,6 +632,7 @@ struct TMasterOpResult {
// transaction load
9: optional TTxnLoadInfo txnLoadInfo;
10: optional i64 groupCommitLoadBeId;
+ 11: optional i64 affectedRows;
}
struct TUpdateExportTaskStatusRequest {
diff --git
a/regression-test/suites/load_p0/insert/test_insert_from_follower.groovy
b/regression-test/suites/load_p0/insert/test_insert_from_follower.groovy
new file mode 100644
index 00000000000..31b230ceb04
--- /dev/null
+++ b/regression-test/suites/load_p0/insert/test_insert_from_follower.groovy
@@ -0,0 +1,62 @@
+// 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.
+
+import org.apache.doris.regression.suite.ClusterOptions
+
+suite("test_insert_from_follower", "docker") {
+ def options = new ClusterOptions()
+ options.setFeNum(3)
+ options.setBeNum(3)
+ docker(options) {
+ def masterFe = cluster.getMasterFe()
+ def allFes = cluster.getAllFrontends()
+ def followerFes = allFes.findAll { fe -> fe.index != masterFe.index }
+ def followerFe = followerFes[0]
+ logger.info("Master FE: ${masterFe.host}")
+ logger.info("Using follower FE: ${followerFe.host}")
+ // Connect to follower FE
+ def url = String.format(
+
"jdbc:mysql://%s:%s/?useLocalSessionState=true&allowLoadLocalInfile=false",
+ followerFe.host, followerFe.queryPort)
+ logger.info("Connecting to follower FE: ${url}")
+ context.connectTo(url, context.config.jdbcUser,
context.config.jdbcPassword)
+
+ sql "drop database if exists test_insert_from_follower"
+ sql "create database test_insert_from_follower"
+ sql "use test_insert_from_follower"
+ def tbl = 'test_insert_from_follower_tbl'
+ sql """ DROP TABLE IF EXISTS ${tbl} """
+ sql """
+ CREATE TABLE ${tbl} (
+ `k1` int(11) NULL,
+ `k2` char(5) NULL
+ )
+ DUPLICATE KEY(`k1`, `k2`)
+ COMMENT 'OLAP'
+ DISTRIBUTED BY HASH(`k1`) BUCKETS 2
+ PROPERTIES (
+ "replication_num"="3"
+ );
+ """
+
+ def loadRes = sql """ INSERT INTO ${tbl} (k1, k2) VALUES (1, "a"), (2,
"b"), (3, "c"), (4, "e");"""
+ logger.info("loadRes: ${loadRes}")
+ assertTrue(loadRes[0][0] == 4)
+ sql """ DROP TABLE IF EXISTS ${tbl} """
+ sleep(5000)
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]