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 dc3afaab6bc [Fix](txn) Remove `TabletTxnInfo` if version exists when publish version (#49564) dc3afaab6bc is described below commit dc3afaab6bc2a468903b796fe8d443af2cd414b0 Author: bobhan1 <bao...@selectdb.com> AuthorDate: Thu Mar 27 19:08:43 2025 +0800 [Fix](txn) Remove `TabletTxnInfo` if version exists when publish version (#49564) `TabletTxnInfo` should be removed if version exists when publish version. Otherwise, the related txn info will not be deleted and occupy large memories --- 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 2fd45a8e09f..3329816478d 100644 --- a/be/src/olap/txn_manager.cpp +++ b/be/src/olap/txn_manager.cpp @@ -602,21 +602,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 1994dec9494..95853c09705 100644 --- a/be/src/olap/txn_manager.h +++ b/be/src/olap/txn_manager.h @@ -245,6 +245,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; @@ -288,6 +291,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