This is an automated email from the ASF dual-hosted git repository.
deardeng 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 5a24e633b15 [fix](storage) Reject prepare txn on shutdown tablet
(#66448)
5a24e633b15 is described below
commit 5a24e633b15a942c9a43649a4a192535b62bec32
Author: deardeng <[email protected]>
AuthorDate: Wed Aug 5 10:37:08 2026 +0800
[fix](storage) Reject prepare txn on shutdown tablet (#66448)
Cause:
PR #54124 moved the migration and push locks from RowsetBuilder into
Tablet::prepare_txn. During that refactor, the call to
TxnManager::prepare_txn changed from the const Tablet& overload to the
raw tablet_id/tablet_uid overload. This silently bypassed the
TABLET_SHUTDOWN guard introduced by PR #42296.
Impact:
A load thread holding an old Tablet instance could resume after
migration and register the stale tablet UID in the transaction map.
Publish would then operate on the reloaded Tablet with a new UID and
leave the transaction in an E-909 state.
Fix:
Call the const Tablet& overload with *this while the migration and push
locks are held. This preserves the lock encapsulation from PR #54124 and
restores the shutdown-tablet protection from PR #42296.
Test:
Add a deterministic unit test that marks a Tablet as TABLET_SHUTDOWN,
verifies Tablet::prepare_txn fails, and verifies no stale tablet entry
is registered. TxnManagerTest.* passes 16/16.
---
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 25189c32921..195ce5058ff 100644
--- a/be/src/storage/tablet/tablet.cpp
+++ b/be/src/storage/tablet/tablet.cpp
@@ -3268,8 +3268,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);
}
} // namespace doris
diff --git a/be/test/storage/txn/txn_manager_test.cpp
b/be/test/storage/txn/txn_manager_test.cpp
index 30e2e96233e..ed384edff3d 100644
--- a/be/test/storage/txn/txn_manager_test.cpp
+++ b/be/test/storage/txn/txn_manager_test.cpp
@@ -245,6 +245,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]