This is an automated email from the ASF dual-hosted git repository.

liaoxin01 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 3416d7e8e29 [fix](group commit) Propagate transaction commit errors to 
synchronous group commit loads (#70915)
3416d7e8e29 is described below

commit 3416d7e8e29f05a26894a8e1d6aeb4715c06f766
Author: hui lai <[email protected]>
AuthorDate: Thu Nov 26 16:16:10 2026 +0800

    [fix](group commit) Propagate transaction commit errors to synchronous 
group commit loads (#70915)
    
    ### Background
    
    Group Commit can combine several loads in a single transaction. A
    synchronous load waits for the shared transaction to finish. An
    asynchronous load also waits if the backend switches it to synchronous
    mode because the WAL directory has insufficient space.
    
    ### What problem does this PR solve?
    
    Issue Number: None
    Related PR: None
    PR Type: Bugfix
    
    Problem Summary: A waiting load could return success after a failed
    commit RPC or an unsuccessful commit response from the frontend. Record
    the error on the shared load queue before releasing the waiting loads.
    
    ### Details
    
    - **Frequency:** Affects a waiting load when fragment execution succeeds
    and the final commit attempt reports an error.
    - **Root cause:** The callback used the RPC and transaction outcomes to
    choose WAL recovery, but the waiting sink read a queue status that still
    indicated success.
    - **Why existing tests missed it:** The low-space test checked
    successful fallback. The WAL recovery tests exercised errors with
    asynchronous requests.
    - **Fix:** Set the queue status under its mutex before marking the queue
    finished. Preserve the first queue error and give a transport error
    precedence over the response payload.
    - **Other paths and branches:** A publish timeout still counts as a
    committed transaction. WAL deletion and recovery use the same success
    criteria as before.
    - **Behavior change:** A waiting client receives the commit error. A
    transport error can leave the actual transaction outcome unknown.
---
 be/src/load/group_commit/group_commit_mgr.cpp      | 18 +++++++-------
 .../test_low_wal_disk_space_fault_injection.groovy | 28 ++++++++++++++++++++++
 2 files changed, 38 insertions(+), 8 deletions(-)

diff --git a/be/src/load/group_commit/group_commit_mgr.cpp 
b/be/src/load/group_commit/group_commit_mgr.cpp
index 1a505e635d6..e88b8bd3a5a 100644
--- a/be/src/load/group_commit/group_commit_mgr.cpp
+++ b/be/src/load/group_commit/group_commit_mgr.cpp
@@ -680,6 +680,12 @@ Status GroupCommitTable::_finish_group_commit_load(int64_t 
db_id, int64_t table_
                     Status ::InternalError(msg));
         });
     }
+    DBUG_EXECUTE_IF("LoadBlockQueue._finish_group_commit_load.err_st", {
+        st = 
Status::InternalError("LoadBlockQueue._finish_group_commit_load.err_st");
+    });
+    // PUBLISH_TIMEOUT means the transaction committed but is not visible yet.
+    const bool txn_succeeded =
+            st.ok() && (result_status.ok() || 
result_status.is<ErrorCode::PUBLISH_TIMEOUT>());
     std::shared_ptr<LoadBlockQueue> load_block_queue;
     {
         std::lock_guard<std::mutex> l(_lock);
@@ -694,6 +700,9 @@ Status GroupCommitTable::_finish_group_commit_load(int64_t 
db_id, int64_t table_
             // notify sync mode loads
             {
                 std::unique_lock l2(load_block_queue->mutex);
+                if (!txn_succeeded && load_block_queue->status.ok()) {
+                    load_block_queue->status = st.ok() ? result_status : st;
+                }
                 load_block_queue->process_finish = true;
                 for (auto dep : load_block_queue->dependencies) {
                     dep->set_always_ready();
@@ -706,14 +715,7 @@ Status GroupCommitTable::_finish_group_commit_load(int64_t 
db_id, int64_t table_
         LOG(WARNING) << "finish group commit can not find load block queue, 
label=" << label
                      << ", txn_id=" << txn_id << ", instance_id=" << 
print_id(instance_id);
     }
-    // status: exec_plan_fragment result
-    // st: commit txn rpc status
-    // result_status: commit txn result
-    DBUG_EXECUTE_IF("LoadBlockQueue._finish_group_commit_load.err_st", {
-        st = 
Status::InternalError("LoadBlockQueue._finish_group_commit_load.err_st");
-    });
-    if (status.ok() && st.ok() &&
-        (result_status.ok() || 
result_status.is<ErrorCode::PUBLISH_TIMEOUT>())) {
+    if (status.ok() && txn_succeeded) {
         if (!config::group_commit_wait_replay_wal_finish) {
             auto delete_st = _exec_env->wal_mgr()->delete_wal(table_id, 
txn_id);
             if (!delete_st.ok()) {
diff --git 
a/regression-test/suites/fault_injection_p0/test_low_wal_disk_space_fault_injection.groovy
 
b/regression-test/suites/fault_injection_p0/test_low_wal_disk_space_fault_injection.groovy
index ab5fbc82cdc..04cc787315a 100644
--- 
a/regression-test/suites/fault_injection_p0/test_low_wal_disk_space_fault_injection.groovy
+++ 
b/regression-test/suites/fault_injection_p0/test_low_wal_disk_space_fault_injection.groovy
@@ -75,6 +75,34 @@ 
suite("test_low_wal_disk_space_fault_injection","nonConcurrent") {
         
GetDebugPoint().disableDebugPointForAllBEs("LoadBlockQueue.has_enough_wal_disk_space.low_space")
     }
 
+    // Both explicit sync and an async load downgraded to sync must see the 
commit error.
+    def lowSpace = "LoadBlockQueue.has_enough_wal_disk_space.low_space"
+    def finish = "LoadBlockQueue._finish_group_commit_load"
+    [["sync_mode", "err_st"], ["async_mode", 
"commit_success_and_rpc_error"]].each { mode, fault ->
+        try {
+            GetDebugPoint().enableDebugPointForAllBEs(lowSpace)
+            GetDebugPoint().enableDebugPointForAllBEs("${finish}.${fault}")
+            streamLoad {
+                table tableName
+                set 'column_separator', ','
+                set 'group_commit', mode
+                unset 'label'
+                inputText "1,2"
+                check { result, exception, startTime, endTime ->
+                    if (exception != null) {
+                        throw exception
+                    }
+                    def json = parseJson(result)
+                    assertEquals("Fail", json.Status)
+                    assertTrue(json.Message.contains(fault), result)
+                }
+            }
+        } finally {
+            GetDebugPoint().disableDebugPointForAllBEs("${finish}.${fault}")
+            GetDebugPoint().disableDebugPointForAllBEs(lowSpace)
+        }
+    }
+
     // case 2: Set a minimal WAL limit to test HTTP layer admission checks
     logger.info("=== case 2: Set a minimal WAL limit to test HTTP layer 
admission checks ===")
     try {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to