diff --git a/be/src/olap/txn_manager.cpp b/be/src/olap/txn_manager.cpp index 7bdf970154..90ed82242f 100644 --- a/be/src/olap/txn_manager.cpp +++ b/be/src/olap/txn_manager.cpp @@ -17,6 +17,7 @@ #include "txn_manager.h" +#include #include #include #include @@ -66,6 +67,8 @@ using std::vector; namespace doris { using namespace ErrorCode; +bvar::Adder g_tablet_txn_info_txn_partitions_count("tablet_txn_info_txn_partitions_count"); + TxnManager::TxnManager(StorageEngine& engine, int32_t txn_map_shard_size, int32_t txn_shard_size) : _engine(engine), _txn_map_shard_size(txn_map_shard_size), @@ -174,6 +177,9 @@ Status TxnManager::prepare_txn(TPartitionId partition_id, TTransactionId transac // case 2: loading txn from meta env auto load_info = std::make_shared(load_id, nullptr, ingest); load_info->prepare(); + if (!txn_tablet_map.contains(key)) { + g_tablet_txn_info_txn_partitions_count << 1; + } txn_tablet_map[key][tablet_info] = std::move(load_info); _insert_txn_partition_map_unlocked(transaction_id, partition_id); VLOG_NOTICE << "add transaction to engine successfully." @@ -621,6 +627,7 @@ void TxnManager::_remove_txn_tablet_info_unlocked(TPartitionId partition_id, it->second.erase(tablet_info); 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); } } @@ -670,6 +677,7 @@ Status TxnManager::rollback_txn(TPartitionId partition_id, TTransactionId transa << ", tablet: " << tablet_info.to_string(); if (tablet_txn_info_map.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::OK(); @@ -718,6 +726,7 @@ Status TxnManager::delete_txn(OlapMeta* meta, TPartitionId partition_id, } 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::OK(); @@ -778,6 +787,7 @@ void TxnManager::force_rollback_tablet_related_txns(OlapMeta* meta, TTabletId ta if (it->second.empty()) { _clear_txn_partition_map_unlocked(it->first.second, it->first.first); it = txn_tablet_map.erase(it); + g_tablet_txn_info_txn_partitions_count << -1; } else { ++it; }