This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.1 by this push:
new 60f6975850e branch-2.1-pick: [Fix](txn) Remove `TabletTxnInfo` if
version exists when publish version (#49564) (#49590)
60f6975850e is described below
commit 60f6975850e190f8c8475b2a62022483e7754103
Author: bobhan1 <[email protected]>
AuthorDate: Fri Mar 28 09:56:41 2025 +0800
branch-2.1-pick: [Fix](txn) Remove `TabletTxnInfo` if version exists when
publish version (#49564) (#49590)
pick https://github.com/apache/doris/pull/49564
---
be/src/olap/task/engine_publish_version_task.cpp | 3 +++
be/src/olap/txn_manager.cpp | 29 +++++++++++++++++++-----
be/src/olap/txn_manager.h | 8 +++++++
3 files changed, 34 insertions(+), 6 deletions(-)
diff --git a/be/src/olap/task/engine_publish_version_task.cpp
b/be/src/olap/task/engine_publish_version_task.cpp
index 66721f56237..6519e03d62a 100644
--- a/be/src/olap/task/engine_publish_version_task.cpp
+++ b/be/src/olap/task/engine_publish_version_task.cpp
@@ -208,6 +208,9 @@ Status EnginePublishVersionTask::execute() {
}
if (version.first != max_version + 1) {
if (tablet->check_version_exist(version)) {
+
StorageEngine::instance()->txn_manager()->remove_txn_tablet_info(
+ partition_id, transaction_id,
tablet->tablet_id(),
+ tablet->tablet_uid());
continue;
}
auto handle_version_not_continuous = [&]() {
diff --git a/be/src/olap/txn_manager.cpp b/be/src/olap/txn_manager.cpp
index a8c502e0173..7bdf9701549 100644
--- a/be/src/olap/txn_manager.cpp
+++ b/be/src/olap/txn_manager.cpp
@@ -600,21 +600,38 @@ Status TxnManager::publish_txn(OlapMeta* meta,
TPartitionId partition_id,
std::lock_guard<std::shared_mutex> txn_lock(_get_txn_lock(transaction_id));
std::lock_guard<std::shared_mutex>
wrlock(_get_txn_map_lock(transaction_id));
stats->lock_wait_time_us += MonotonicMicros() - t6;
+ _remove_txn_tablet_info_unlocked(partition_id, transaction_id, tablet_id,
tablet_uid, txn_lock,
+ wrlock);
+ VLOG_NOTICE << "publish txn successfully."
+ << " partition_id: " << key.first << ", txn_id: " << key.second
+ << ", tablet_id: " << tablet_info.tablet_id << ", rowsetid: "
<< rowset->rowset_id()
+ << ", version: " << version.first << "," << version.second;
+ return status;
+}
+
+void TxnManager::_remove_txn_tablet_info_unlocked(TPartitionId partition_id,
+ TTransactionId
transaction_id,
+ TTabletId tablet_id,
TabletUid tablet_uid,
+
std::lock_guard<std::shared_mutex>& txn_lock,
+
std::lock_guard<std::shared_mutex>& wrlock) {
+ std::pair<int64_t, int64_t> key {partition_id, transaction_id};
+ TabletInfo tablet_info {tablet_id, tablet_uid};
txn_tablet_map_t& txn_tablet_map = _get_txn_tablet_map(transaction_id);
if (auto it = txn_tablet_map.find(key); it != txn_tablet_map.end()) {
it->second.erase(tablet_info);
- VLOG_NOTICE << "publish txn successfully."
- << " partition_id: " << key.first << ", txn_id: " <<
key.second
- << ", tablet_id: " << tablet_info.tablet_id
- << ", rowsetid: " << rowset->rowset_id() << ", version: "
<< version.first
- << "," << version.second;
if (it->second.empty()) {
txn_tablet_map.erase(it);
_clear_txn_partition_map_unlocked(transaction_id, partition_id);
}
}
+}
- return status;
+void TxnManager::remove_txn_tablet_info(TPartitionId partition_id,
TTransactionId transaction_id,
+ TTabletId tablet_id, TabletUid
tablet_uid) {
+ std::lock_guard<std::shared_mutex> txn_lock(_get_txn_lock(transaction_id));
+ std::lock_guard<std::shared_mutex>
wrlock(_get_txn_map_lock(transaction_id));
+ _remove_txn_tablet_info_unlocked(partition_id, transaction_id, tablet_id,
tablet_uid, txn_lock,
+ wrlock);
}
// txn could be rollbacked if it does not have related rowset
diff --git a/be/src/olap/txn_manager.h b/be/src/olap/txn_manager.h
index ab34113c7e7..800d223c99d 100644
--- a/be/src/olap/txn_manager.h
+++ b/be/src/olap/txn_manager.h
@@ -221,6 +221,9 @@ public:
TxnState get_txn_state(TPartitionId partition_id, TTransactionId
transaction_id,
TTabletId tablet_id, TabletUid tablet_uid);
+ void remove_txn_tablet_info(TPartitionId partition_id, TTransactionId
transaction_id,
+ TTabletId tablet_id, TabletUid tablet_uid);
+
private:
using TxnKey = std::pair<int64_t, int64_t>; // partition_id,
transaction_id;
@@ -264,6 +267,11 @@ private:
void _insert_txn_partition_map_unlocked(int64_t transaction_id, int64_t
partition_id);
void _clear_txn_partition_map_unlocked(int64_t transaction_id, int64_t
partition_id);
+ void _remove_txn_tablet_info_unlocked(TPartitionId partition_id,
TTransactionId transaction_id,
+ TTabletId tablet_id, TabletUid
tablet_uid,
+ std::lock_guard<std::shared_mutex>&
txn_lock,
+ std::lock_guard<std::shared_mutex>&
wrlock);
+
class TabletVersionCache : public LRUCachePolicyTrackingManual {
public:
TabletVersionCache(size_t capacity)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]