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 7d243086587 branch-4.1: [fix](storage) Reject prepare txn on shutdown 
tablet #66448 (#66457)
7d243086587 is described below

commit 7d24308658716fd5e6098ea372e52a1765aef50c
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Thu Aug 6 10:34:52 2026 +0800

    branch-4.1: [fix](storage) Reject prepare txn on shutdown tablet #66448 
(#66457)
    
    Cherry-picked from #66448
    
    Co-authored-by: deardeng <[email protected]>
---
 be/src/storage/tablet/tablet.cpp         |  3 +--
 be/test/storage/txn/txn_manager_test.cpp | 14 ++++++++++++++
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/be/src/storage/tablet/tablet.cpp b/be/src/storage/tablet/tablet.cpp
index 71cc3475c60..644747dc300 100644
--- a/be/src/storage/tablet/tablet.cpp
+++ b/be/src/storage/tablet/tablet.cpp
@@ -2880,8 +2880,7 @@ Status Tablet::prepare_txn(TPartitionId partition_id, 
TTransactionId transaction
     }
 
     std::lock_guard<std::mutex> push_lock(get_push_lock());
-    return _engine.txn_manager()->prepare_txn(partition_id, transaction_id, 
tablet_id(),
-                                              tablet_uid(), load_id, ingest);
+    return _engine.txn_manager()->prepare_txn(partition_id, *this, 
transaction_id, load_id, ingest);
 }
 
 #include "common/compile_check_end.h"
diff --git a/be/test/storage/txn/txn_manager_test.cpp 
b/be/test/storage/txn/txn_manager_test.cpp
index 1e717b32629..df573228087 100644
--- a/be/test/storage/txn/txn_manager_test.cpp
+++ b/be/test/storage/txn/txn_manager_test.cpp
@@ -211,6 +211,20 @@ TEST_F(TxnManagerTest, PrepareNewTxn) {
     EXPECT_TRUE(status == Status::OK());
 }
 
+TEST_F(TxnManagerTest, PrepareTxnRejectsOldShutdownTablet) {
+    auto tablet = k_engine->tablet_manager()->get_tablet(tablet_id);
+    ASSERT_NE(tablet, nullptr);
+    ASSERT_TRUE(tablet->set_tablet_state(TABLET_SHUTDOWN).ok());
+
+    auto status = tablet->prepare_txn(partition_id, transaction_id, load_id, 
false);
+    EXPECT_FALSE(status.ok()) << status;
+
+    std::map<TabletInfo, RowsetSharedPtr> related_tablets;
+    k_engine->txn_manager()->get_txn_related_tablets(transaction_id, 
partition_id,
+                                                     &related_tablets);
+    EXPECT_TRUE(related_tablets.empty());
+}
+
 // 1. prepare txn
 // 2. commit txn
 // 3. should be success


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

Reply via email to