This is an automated email from the ASF dual-hosted git repository. dataroaring pushed a commit to branch branch-3.0 in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.0 by this push: new 86e96f52cd7 branch-3.0: [Fix](txn) Remove `TabletTxnInfo` if version exists when publish version #49564 (#49588) 86e96f52cd7 is described below commit 86e96f52cd72c8f69320633fa1b4d75fe76e094d Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> AuthorDate: Fri Mar 28 21:22:27 2025 +0800 branch-3.0: [Fix](txn) Remove `TabletTxnInfo` if version exists when publish version #49564 (#49588) Cherry-picked from #49564 Co-authored-by: bobhan1 <bao...@selectdb.com> --- 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 75e589f3b97..49784cd9e52 100644 --- a/be/src/olap/task/engine_publish_version_task.cpp +++ b/be/src/olap/task/engine_publish_version_task.cpp @@ -210,6 +210,9 @@ Status EnginePublishVersionTask::execute() { } if (version.first != max_version + 1) { if (tablet->check_version_exist(version)) { + _engine.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 abf951f6c8e..2970690a8df 100644 --- a/be/src/olap/txn_manager.cpp +++ b/be/src/olap/txn_manager.cpp @@ -608,22 +608,39 @@ 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); g_tablet_txn_info_txn_partitions_count << -1; _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 88ee97c5f6a..4d96f8c3acf 100644 --- a/be/src/olap/txn_manager.h +++ b/be/src/olap/txn_manager.h @@ -239,6 +239,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; @@ -282,6 +285,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 LRUCachePolicy { public: TabletVersionCache(size_t capacity) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org