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

dataroaring 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 ba493a5e526 [fix](binlog) Acquire migration lock before ingesting 
binlog (#50663)
ba493a5e526 is described below

commit ba493a5e5267a0b385057c6322c26723fea0845b
Author: walter <[email protected]>
AuthorDate: Thu May 8 17:26:23 2025 +0800

    [fix](binlog) Acquire migration lock before ingesting binlog (#50663)
---
 be/src/service/backend_service.cpp | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/be/src/service/backend_service.cpp 
b/be/src/service/backend_service.cpp
index a379c52157a..114d99fe264 100644
--- a/be/src/service/backend_service.cpp
+++ b/be/src/service/backend_service.cpp
@@ -1083,13 +1083,18 @@ void BackendService::ingest_binlog(TIngestBinlogResult& 
result,
     PUniqueId p_load_id;
     p_load_id.set_hi(load_id.hi);
     p_load_id.set_lo(load_id.lo);
-    auto status = _engine.txn_manager()->prepare_txn(partition_id, 
*local_tablet, txn_id, p_load_id,
-                                                     is_ingrest);
-    if (!status.ok()) {
-        LOG(WARNING) << "prepare txn failed. txn_id=" << txn_id
-                     << ", status=" << status.to_string();
-        status.to_thrift(&tstatus);
-        return;
+
+    {
+        // See RowsetBuilder::prepare_txn for details
+        std::shared_lock 
base_migration_lock(local_tablet->get_migration_lock());
+        auto status = _engine.txn_manager()->prepare_txn(partition_id, 
*local_tablet, txn_id,
+                                                         p_load_id, 
is_ingrest);
+        if (!status.ok()) {
+            LOG(WARNING) << "prepare txn failed. txn_id=" << txn_id
+                         << ", status=" << status.to_string();
+            status.to_thrift(&tstatus);
+            return;
+        }
     }
 
     bool is_async = (_ingest_binlog_workers != nullptr);
@@ -1110,7 +1115,7 @@ void BackendService::ingest_binlog(TIngestBinlogResult& 
result,
     };
 
     if (is_async) {
-        status = 
_ingest_binlog_workers->submit_func(std::move(ingest_binlog_func));
+        auto status = 
_ingest_binlog_workers->submit_func(std::move(ingest_binlog_func));
         if (!status.ok()) {
             status.to_thrift(&tstatus);
             return;


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

Reply via email to