patch 4.0

This commit is contained in:
wangzelin.wzl
2022-10-24 10:34:53 +08:00
parent 4ad6e00ec3
commit 93a1074b0c
10533 changed files with 2588271 additions and 2299373 deletions

View File

@ -16,9 +16,11 @@
#include "lib/allocator/ob_mod_define.h"
#include "share/ob_thread_mgr.h"
namespace oceanbase {
namespace oceanbase
{
using namespace common;
namespace storage {
namespace storage
{
// ------------------ Statistic ------------------ //
bool ObMergeIterStat::is_valid() const
{
@ -41,7 +43,7 @@ int ObMergeIterStat::add(const ObMergeIterStat& other)
return ret;
}
ObMergeIterStat& ObMergeIterStat::operator=(const ObMergeIterStat& other)
ObMergeIterStat & ObMergeIterStat::operator=(const ObMergeIterStat &other)
{
if (this != &other) {
MEMCPY(this, &other, sizeof(ObMergeIterStat));
@ -70,7 +72,7 @@ int ObBlockAccessStat::add(const ObBlockAccessStat& other)
return ret;
}
ObBlockAccessStat& ObBlockAccessStat::operator=(const ObBlockAccessStat& other)
ObBlockAccessStat & ObBlockAccessStat::operator=(const ObBlockAccessStat &other)
{
if (this != &other) {
MEMCPY(this, &other, sizeof(ObBlockAccessStat));
@ -90,20 +92,29 @@ void ObTableStoreStat::reset()
void ObTableStoreStat::reuse()
{
common::ObPartitionKey pkey = pkey_;
share::ObLSID ls_id = ls_id_;
common::ObTabletID tablet_id = tablet_id_;
common::ObTableID table_id = table_id_;
MEMSET(this, 0, sizeof(ObTableStoreStat));
pkey_ = pkey;
ls_id_ = ls_id;
tablet_id_ = tablet_id;
table_id_ = table_id;
}
bool ObTableStoreStat::is_valid() const
{
bool valid = true;
if (row_cache_hit_cnt_ < 0 || row_cache_miss_cnt_ < 0 || row_cache_put_cnt_ < 0 || bf_filter_cnt_ < 0 ||
bf_empty_read_cnt_ < 0 || bf_access_cnt_ < 0 || block_cache_hit_cnt_ < 0 || block_cache_miss_cnt_ < 0 ||
access_row_cnt_ < 0 || output_row_cnt_ < 0 || fuse_row_cache_hit_cnt_ < 0 || fuse_row_cache_miss_cnt_ < 0 ||
fuse_row_cache_put_cnt_ < 0 || !single_get_stat_.is_valid() || !multi_get_stat_.is_valid() ||
!index_back_stat_.is_valid() || !single_scan_stat_.is_valid() || !multi_scan_stat_.is_valid() ||
!exist_row_.is_valid() || !get_row_.is_valid() || !scan_row_.is_valid()) {
if (row_cache_hit_cnt_ < 0 || row_cache_miss_cnt_ < 0 || row_cache_put_cnt_ < 0
|| bf_filter_cnt_ < 0 || bf_empty_read_cnt_ < 0 || bf_access_cnt_ < 0
|| block_cache_hit_cnt_ < 0 || block_cache_miss_cnt_ < 0
|| access_row_cnt_ < 0 || output_row_cnt_ < 0 || fuse_row_cache_hit_cnt_ < 0
|| fuse_row_cache_miss_cnt_ < 0 || fuse_row_cache_put_cnt_ < 0
|| macro_access_cnt_ < 0 || micro_access_cnt_ < 0 || pushdown_micro_access_cnt_ < 0
|| pushdown_row_access_cnt_ < 0 || pushdown_row_select_cnt_ < 0
|| !single_get_stat_.is_valid() || !multi_get_stat_.is_valid() || !index_back_stat_.is_valid()
|| !single_scan_stat_.is_valid() || !multi_scan_stat_.is_valid()
|| !exist_row_.is_valid() ||!get_row_.is_valid() || !scan_row_.is_valid()
|| logical_read_cnt_ < 0 || physical_read_cnt_ < 0) {
valid = false;
}
return valid;
@ -118,7 +129,7 @@ int ObTableStoreStat::add(const ObTableStoreStat& other)
} else if (!other.is_valid()) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("other is invalid", K(ret), K(other));
} else if (other.pkey_ != pkey_) {
} else if (other.ls_id_ != ls_id_ || other.tablet_id_ != tablet_id_ || other.table_id_ != table_id_) {
ret = OB_NOT_THE_OBJECT;
LOG_WARN("not the same table store", K(ret), K(other));
} else {
@ -135,7 +146,12 @@ int ObTableStoreStat::add(const ObTableStoreStat& other)
fuse_row_cache_hit_cnt_ += other.fuse_row_cache_hit_cnt_;
fuse_row_cache_miss_cnt_ += other.fuse_row_cache_miss_cnt_;
fuse_row_cache_put_cnt_ += other.fuse_row_cache_put_cnt_;
// ignore ret
macro_access_cnt_ += other.macro_access_cnt_;
micro_access_cnt_ += other.micro_access_cnt_;
pushdown_micro_access_cnt_ += other.pushdown_micro_access_cnt_;
pushdown_row_access_cnt_ += other.pushdown_row_access_cnt_;
pushdown_row_select_cnt_ += other.pushdown_row_select_cnt_;
//ignore ret
single_get_stat_.add(other.single_get_stat_);
multi_get_stat_.add(other.multi_get_stat_);
index_back_stat_.add(other.index_back_stat_);
@ -144,11 +160,14 @@ int ObTableStoreStat::add(const ObTableStoreStat& other)
exist_row_.add(other.exist_row_);
get_row_.add(other.get_row_);
scan_row_.add(other.scan_row_);
logical_read_cnt_ += other.logical_read_cnt_;
physical_read_cnt_ += other.physical_read_cnt_;
}
return ret;
}
ObTableStoreStat& ObTableStoreStat::operator=(const ObTableStoreStat& other)
ObTableStoreStat &ObTableStoreStat::operator=(const ObTableStoreStat& other)
{
if (this != &other) {
MEMCPY(this, &other, sizeof(ObTableStoreStat));
@ -157,11 +176,15 @@ ObTableStoreStat& ObTableStoreStat::operator=(const ObTableStoreStat& other)
}
// ------------------ Iterator ------------------ //
ObTableStoreStatIterator::ObTableStoreStatIterator() : cur_idx_(0), is_opened_(false)
{}
ObTableStoreStatIterator::ObTableStoreStatIterator()
: cur_idx_(0),
is_opened_(false)
{
}
ObTableStoreStatIterator::~ObTableStoreStatIterator()
{}
{
}
void ObTableStoreStatIterator::reset()
{
@ -182,7 +205,7 @@ int ObTableStoreStatIterator::open()
return ret;
}
int ObTableStoreStatIterator::get_next_stat(ObTableStoreStat& stat)
int ObTableStoreStatIterator::get_next_stat(ObTableStoreStat &stat)
{
int ret = OB_SUCCESS;
if (!is_opened_) {
@ -196,7 +219,7 @@ int ObTableStoreStatIterator::get_next_stat(ObTableStoreStat& stat)
}
// ------------------ Manager ------------------ //
int ObTableStoreStatMgr::ReportTask::init(ObTableStoreStatMgr* stat_mgr)
int ObTableStoreStatMgr::ReportTask::init(ObTableStoreStatMgr *stat_mgr)
{
int ret = OB_SUCCESS;
if (OB_ISNULL(stat_mgr)) {
@ -218,17 +241,18 @@ void ObTableStoreStatMgr::ReportTask::runTimerTask()
}
ObTableStoreStatMgr::ObTableStoreStatMgr()
: is_inited_(false),
lock_(),
quick_map_(),
cur_cnt_(0),
limit_cnt_(0),
lru_head_(NULL),
lru_tail_(NULL),
report_cursor_(0),
pending_cursor_(0),
report_task_()
{}
: is_inited_(false),
lock_(),
quick_map_(),
cur_cnt_(0),
limit_cnt_(0),
lru_head_(NULL),
lru_tail_(NULL),
report_cursor_(0),
pending_cursor_(0),
report_task_()
{
}
ObTableStoreStatMgr::~ObTableStoreStatMgr()
{
@ -259,8 +283,7 @@ int ObTableStoreStatMgr::init(const int64_t limit_cnt)
} else if (limit_cnt <= 0 || limit_cnt > DEFAULT_MAX_CNT) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid argument", K(ret), K(limit_cnt));
} else if (OB_FAIL(
quick_map_.create(limit_cnt, ObModIds::OB_TABLE_STORE_STAT_MGR, ObModIds::OB_TABLE_STORE_STAT_MGR))) {
} else if (OB_FAIL(quick_map_.create(limit_cnt, ObModIds::OB_TABLE_STORE_STAT_MGR, ObModIds::OB_TABLE_STORE_STAT_MGR))) {
LOG_WARN("Fail to create merge info map, ", K(ret));
} else if (OB_FAIL(report_task_.init(this))) {
LOG_WARN("Fail to init report task, ", K(ret));
@ -277,7 +300,8 @@ int ObTableStoreStatMgr::init(const int64_t limit_cnt)
node_pool_[i].stat_ = &(stat_array_[i]);
}
limit_cnt_ = limit_cnt;
if (OB_FAIL(TG_SCHEDULE(lib::TGDefIDs::TableStatRpt, report_task_, REPORT_TASK_INTERVAL_US, /*repeat*/ true))) {
if (OB_FAIL(TG_SCHEDULE(lib::TGDefIDs::TableStatRpt, report_task_,
REPORT_TASK_INTERVAL_US, /*repeat*/true))) {
LOG_WARN("schedule report task fail", K(ret));
} else {
LOG_INFO("schedule report task succeed");
@ -287,13 +311,13 @@ int ObTableStoreStatMgr::init(const int64_t limit_cnt)
return ret;
}
ObTableStoreStatMgr& ObTableStoreStatMgr::get_instance()
ObTableStoreStatMgr &ObTableStoreStatMgr::get_instance()
{
static ObTableStoreStatMgr instance_;
return instance_;
}
void ObTableStoreStatMgr::move_node_to_head(ObTableStoreStatNode* node)
void ObTableStoreStatMgr::move_node_to_head(ObTableStoreStatNode *node)
{
if (node == lru_head_) {
// do nothing
@ -317,7 +341,7 @@ void ObTableStoreStatMgr::move_node_to_head(ObTableStoreStatNode* node)
}
}
int ObTableStoreStatMgr::report_stat(const ObTableStoreStat& stat)
int ObTableStoreStatMgr::report_stat(const ObTableStoreStat &stat)
{
int ret = OB_SUCCESS;
if (IS_NOT_INIT) {
@ -342,7 +366,7 @@ int ObTableStoreStatMgr::report_stat(const ObTableStoreStat& stat)
return ret;
}
int ObTableStoreStatMgr::get_table_store_stat(const int64_t idx, ObTableStoreStat& stat)
int ObTableStoreStatMgr::get_table_store_stat(const int64_t idx, ObTableStoreStat &stat)
{
int ret = OB_SUCCESS;
if (IS_NOT_INIT) {
@ -370,28 +394,28 @@ void ObTableStoreStatMgr::run_report_task()
LOG_WARN("ObTableStoreStatMgr hasn't been initiated", K(ret));
} else {
int64_t start = static_cast<int64_t>(ATOMIC_LOAD(&report_cursor_));
int64_t end = static_cast<int64_t>(ATOMIC_LOAD(&pending_cursor_) % MAX_PENDDING_CNT);
int64_t end = static_cast<int64>(ATOMIC_LOAD(&pending_cursor_) % MAX_PENDDING_CNT);
if (end == (start + 1) % MAX_PENDDING_CNT) {
// sleep 100ms to give chance for the latest stat be assigned in report_stat
usleep(1000 * 100);
ob_usleep(1000 * 100);
}
if (start == end) {
// do nothing
} else if (start < end) {
for (int64_t i = start; i < end; ++i) {
if (OB_FAIL(add_stat(stat_queue_[i]))) {
if(OB_FAIL(add_stat(stat_queue_[i]))) {
LOG_WARN("report stat fail", K(ret), K(i), K(stat_queue_[i]));
}
}
ATOMIC_STORE(&report_cursor_, end);
} else {
for (int64_t i = start; i < MAX_PENDDING_CNT - 1; ++i) {
if (OB_FAIL(add_stat(stat_queue_[i]))) {
if(OB_FAIL(add_stat(stat_queue_[i]))) {
LOG_WARN("report stat fail", K(ret), K(i), K(stat_queue_[i]));
}
}
for (int64_t i = 0; i < end; ++i) {
if (OB_FAIL(add_stat(stat_queue_[i]))) {
if(OB_FAIL(add_stat(stat_queue_[i]))) {
LOG_WARN("report stat fail", K(ret), K(i), K(stat_queue_[i]));
}
}
@ -400,7 +424,7 @@ void ObTableStoreStatMgr::run_report_task()
}
}
int ObTableStoreStatMgr::add_stat(const ObTableStoreStat& stat)
int ObTableStoreStatMgr::add_stat(const ObTableStoreStat &stat)
{
int ret = OB_SUCCESS;
if (IS_NOT_INIT) {
@ -410,8 +434,8 @@ int ObTableStoreStatMgr::add_stat(const ObTableStoreStat& stat)
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid stat", K(ret), K(stat));
} else {
ObTableStoreStatKey key(stat.pkey_.get_table_id(), stat.pkey_.get_partition_id());
ObTableStoreStatNode* node = NULL;
ObTableStoreStatKey key(stat.table_id_, stat.tablet_id_);
ObTableStoreStatNode *node = NULL;
SpinWLockGuard guard(lock_);
// retrieve node
@ -419,15 +443,16 @@ int ObTableStoreStatMgr::add_stat(const ObTableStoreStat& stat)
if (OB_HASH_NOT_EXIST == ret) {
ret = OB_SUCCESS;
node = NULL;
if (cur_cnt_ < limit_cnt_) { // has free node
if (cur_cnt_ < limit_cnt_) { // has free node
node = &(node_pool_[cur_cnt_++]);
} else { // evict the tail node
} else { // evict the tail node
if (NULL == lru_tail_) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("LRU tail is NULL", K(ret), K(stat), K(cur_cnt_));
} else {
ObTableStoreStatKey old_key(
lru_tail_->stat_->pkey_.get_table_id(), lru_tail_->stat_->pkey_.get_partition_id());
lru_tail_->stat_->table_id_,
lru_tail_->stat_->tablet_id_);
if (OB_FAIL(quick_map_.erase_refactored(old_key))) {
LOG_WARN("add new node to hash map fail", K(ret), K(old_key));
}
@ -440,7 +465,9 @@ int ObTableStoreStatMgr::add_stat(const ObTableStoreStat& stat)
if (NULL == node) {
LOG_WARN("node is NULL", K(ret), K(stat));
} else {
node->stat_->pkey_ = stat.pkey_;
node->stat_->ls_id_ = stat.ls_id_;
node->stat_->tablet_id_ = stat.tablet_id_;
node->stat_->table_id_ = stat.table_id_;
if (OB_FAIL(quick_map_.set_refactored(key, node))) {
LOG_WARN("add new node to hash map fail", K(ret), K(key), K(*(node->stat_)));
}
@ -465,5 +492,5 @@ int ObTableStoreStatMgr::add_stat(const ObTableStoreStat& stat)
}
return ret;
}
} // namespace storage
} // namespace oceanbase
} // namespace oceanbase
} // namespace storage