[CP] add elr transaction event statistic

This commit is contained in:
obdev
2022-11-02 15:38:35 +00:00
committed by wangzelin.wzl
parent de361652db
commit fc00df48dd
5 changed files with 42 additions and 0 deletions

View File

@ -114,6 +114,13 @@ STAT_EVENT_ADD_DEF(HA_GTS_HANDLE_GET_REQUEST_COUNT, "ha gts handle get request c
STAT_EVENT_ADD_DEF(HA_GTS_SEND_GET_RESPONSE_COUNT, "ha gts send get response count", ObStatClassIds::TRANS, "ha gts send get response count", 30070, true, true)
STAT_EVENT_ADD_DEF(HA_GTS_HANDLE_PING_REQUEST_COUNT, "ha gts handle ping request count", ObStatClassIds::TRANS, "ha gts handle ping request count", 30071, true, true)
STAT_EVENT_ADD_DEF(HA_GTS_HANDLE_PING_RESPONSE_COUNT, "ha gts handle ping response count", ObStatClassIds::TRANS, "ha gts handle ping response count", 30072, true, true)
STAT_EVENT_ADD_DEF(HA_GTS_SOURCE_REQUEST_COUNT, "ha gts source request count", ObStatClassIds::TRANS, "ha gts source request count", 30073, true, true)
STAT_EVENT_ADD_DEF(HA_GTS_SOURCE_REQUEST_COST_TIME, "ha gts source request cost time", ObStatClassIds::TRANS, "ha gts source request cost time", 30074, true, true)
STAT_EVENT_ADD_DEF(HA_GTS_CACHE_HIT_COUNT, "ha gts cache hit count", ObStatClassIds::TRANS, "ha gts cache hit count", 30075, true, true)
STAT_EVENT_ADD_DEF(HA_GTS_CACHE_MISS_COUNT, "ha gts cache miss count", ObStatClassIds::TRANS, "ha gts cache miss count", 30076, true, true)
STAT_EVENT_ADD_DEF(TRANS_ELR_ENABLE_COUNT, "trans early lock release enable count", ObStatClassIds::TRANS, "trans early lock releaes enable count", 30077, true, true)
STAT_EVENT_ADD_DEF(TRANS_ELR_UNABLE_COUNT, "trans early lock release unable count", ObStatClassIds::TRANS, "trans early lock releaes unable count", 30078, true, true)
STAT_EVENT_ADD_DEF(READ_ELR_ROW_COUNT, "read elr row count", ObStatClassIds::TRANS, "read elr row count", 30079, true, true)
// SQL
//STAT_EVENT_ADD_DEF(PLAN_CACHE_HIT, "PLAN_CACHE_HIT", SQL, "PLAN_CACHE_HIT")

View File

@ -26,6 +26,7 @@
#include "storage/tx/ob_trans_part_ctx.h"
#include "storage/memtable/ob_memtable_context.h"
#include "storage/tx/ob_trans_ctx.h"
#include "storage/tx/ob_trans_event.h"
#include "storage/memtable/mvcc/ob_mvcc_trans_ctx.h"
#include "storage/blocksstable/ob_datum_row.h"
@ -996,6 +997,14 @@ int ObMvccRow::mvcc_write_(ObIMemtableCtx &ctx,
res.tx_node_ = &writer_node;
total_trans_node_cnt_++;
}
if (ctx.is_can_elr()
&& NULL != writer_node.prev_
&& writer_node.prev_->is_elr()) {
ObMemtableCtx &mt_ctx = static_cast<ObMemtableCtx &>(ctx);
if (NULL != mt_ctx.get_trans_ctx()) {
TX_STAT_READ_ELR_ROW_COUNT_INC(mt_ctx.get_trans_ctx()->get_tenant_id());
}
}
}
}

View File

@ -129,6 +129,22 @@ void ObTransStatistic::add_trans_total_used_time(const uint64_t tenant_id, const
//trans_total_used_time_stat_.add(value);
}
void ObTransStatistic::add_elr_enable_trans_count(const uint64_t tenant_id, const int64_t value)
{
common::ObTenantStatEstGuard guard(tenant_id);
EVENT_ADD(TRANS_ELR_ENABLE_COUNT, value);
}
void ObTransStatistic::add_elr_unable_trans_count(const uint64_t tenant_id, const int64_t value)
{
common::ObTenantStatEstGuard guard(tenant_id);
EVENT_ADD(TRANS_ELR_UNABLE_COUNT, value);
}
void ObTransStatistic::add_read_elr_row_count(const uint64_t tenant_id, const int64_t value)
{
common::ObTenantStatEstGuard guard(tenant_id);
EVENT_ADD(READ_ELR_ROW_COUNT, value);
}
void ObTransStatistic::add_local_stmt_count(const uint64_t tenant_id, const int64_t value)
{
UNUSED(value);

View File

@ -61,6 +61,11 @@ public:
void add_commit_trans_count(const uint64_t tenant_id, const int64_t value);
// count the number of aborted transactions
void add_rollback_trans_count(const uint64_t tenant_id, const int64_t value);
// count the number of elr enable transactions
void add_elr_enable_trans_count(const uint64_t tenant_id, const int64_t value);
// count the number of elr unable transactions
void add_elr_unable_trans_count(const uint64_t tenant_id, const int64_t value);
void add_read_elr_row_count(const uint64_t tenant_id, const int64_t value);
// count the number of timeout transactions: count when commit the transaction(end_trans)
void add_trans_timeout_count(const uint64_t tenant_id, const int64_t value);
// count how many transactions are started, via start_trans
@ -284,6 +289,9 @@ private:
#define TX_STAT_DIST_INC ObTransStatistic::get_instance().add_dist_count(tenant_id_, 1);
#define TX_STAT_LOCAL_INC ObTransStatistic::get_instance().add_local_count(tenant_id_, 1);
#define TX_STAT_READONLY_INC ObTransStatistic::get_instance().add_readonly_count(tenant_id_, 1);
#define TX_STAT_ELR_ENABLE_TRANS_INC ObTransStatistic::get_instance().add_elr_enable_trans_count(MTL_ID(), 1);
#define TX_STAT_ELR_UNABLE_TRANS_INC ObTransStatistic::get_instance().add_elr_unable_trans_count(MTL_ID(), 1);
#define TX_STAT_READ_ELR_ROW_COUNT_INC transaction::ObTransStatistic::get_instance().add_read_elr_row_count(MTL_ID(), 1);
// TODO: following events is not used, do clean up
// count the interval time between statements

View File

@ -13,6 +13,7 @@
#include "ob_tx_elr_util.h"
#include "common/ob_clock_generator.h"
#include "observer/omt/ob_tenant_config_mgr.h"
#include "ob_trans_event.h"
namespace oceanbase
{
@ -24,6 +25,7 @@ int ObTxELRUtil::check_and_update_tx_elr_info(ObTxDesc &tx, const bool can_elr)
int ret = OB_SUCCESS;
if (can_elr && can_tenant_elr_) { // tenant config enable elr
tx.set_can_elr(true);
TX_STAT_ELR_ENABLE_TRANS_INC(MTL_ID());
} else {
refresh_elr_tenant_config_();
}