[MONITOR] add time guard to keybtree destroy

This commit is contained in:
Handora
2023-08-29 07:10:40 +00:00
committed by ob-robot
parent 608e7a1da9
commit 763e93247c
3 changed files with 20 additions and 0 deletions

View File

@ -1615,18 +1615,23 @@ void ObKeyBtree<BtreeKey, BtreeVal>::print(FILE *file) const
template<typename BtreeKey, typename BtreeVal> template<typename BtreeKey, typename BtreeVal>
int ObKeyBtree<BtreeKey, BtreeVal>::destroy() int ObKeyBtree<BtreeKey, BtreeVal>::destroy()
{ {
ObTimeGuard tg("keybtree destroy", 50L * 1000L); // 50ms
destroy(ATOMIC_SET(&root_, nullptr)); destroy(ATOMIC_SET(&root_, nullptr));
tg.click();
{ {
HazardList reclaim_list; HazardList reclaim_list;
BtreeNode *p = nullptr; BtreeNode *p = nullptr;
CriticalGuard(get_qsync()); CriticalGuard(get_qsync());
get_retire_station().purge(reclaim_list); get_retire_station().purge(reclaim_list);
tg.click();
while (OB_NOT_NULL(p = reinterpret_cast<BtreeNode *>(reclaim_list.pop()))) { while (OB_NOT_NULL(p = reinterpret_cast<BtreeNode *>(reclaim_list.pop()))) {
free_node(p); free_node(p);
p = nullptr; p = nullptr;
} }
tg.click();
} }
WaitQuiescent(get_qsync()); WaitQuiescent(get_qsync());
tg.click();
return OB_SUCCESS; return OB_SUCCESS;
} }

View File

@ -59,6 +59,7 @@ struct ObMtStat
int64_t ready_for_flush_time_; int64_t ready_for_flush_time_;
int64_t create_flush_dag_time_; int64_t create_flush_dag_time_;
int64_t release_time_; int64_t release_time_;
int64_t push_table_into_gc_queue_time_;
int64_t last_print_time_; int64_t last_print_time_;
}; };
@ -493,6 +494,7 @@ public:
K_(read_barrier), K_(is_flushed), K_(freeze_state), K_(allow_freeze), K_(read_barrier), K_(is_flushed), K_(freeze_state), K_(allow_freeze),
K_(mt_stat_.frozen_time), K_(mt_stat_.ready_for_flush_time), K_(mt_stat_.frozen_time), K_(mt_stat_.ready_for_flush_time),
K_(mt_stat_.create_flush_dag_time), K_(mt_stat_.release_time), K_(mt_stat_.create_flush_dag_time), K_(mt_stat_.release_time),
K_(mt_stat_.push_table_into_gc_queue_time),
K_(mt_stat_.last_print_time), K_(ls_id), K_(transfer_freeze_flag), K_(recommend_snapshot_version)); K_(mt_stat_.last_print_time), K_(ls_id), K_(transfer_freeze_flag), K_(recommend_snapshot_version));
private: private:
static const int64_t OB_EMPTY_MEMSTORE_MAX_SIZE = 10L << 20; // 10MB static const int64_t OB_EMPTY_MEMSTORE_MAX_SIZE = 10L << 20; // 10MB

View File

@ -377,6 +377,19 @@ int ObTenantMetaMemMgr::push_table_into_gc_queue(ObITable *table, const ObITable
ret = OB_ALLOCATE_MEMORY_FAILED; ret = OB_ALLOCATE_MEMORY_FAILED;
LOG_ERROR("fail to allocate memory for TableGCItem", K(ret), K(size)); LOG_ERROR("fail to allocate memory for TableGCItem", K(ret), K(size));
} else { } else {
if (ObITable::TableType::DATA_MEMTABLE == table_type) {
ObMemtable *memtable = static_cast<ObMemtable *>(table);
memtable::ObMtStat& mt_stat = memtable->get_mt_stat();
if (0 == mt_stat.push_table_into_gc_queue_time_) {
mt_stat.push_table_into_gc_queue_time_ = ObTimeUtility::current_time();
if (0 != mt_stat.release_time_
&& mt_stat.push_table_into_gc_queue_time_ -
mt_stat.release_time_ >= 10 * 1000 * 1000 /*10s*/) {
LOG_WARN("It cost too much time to dec ref cnt", K(ret), KPC(memtable), K(lbt()));
}
}
}
item->table_ = table; item->table_ = table;
item->table_type_ = table_type; item->table_type_ = table_type;
if (OB_FAIL(free_tables_queue_.push((ObLink *)item))) { if (OB_FAIL(free_tables_queue_.push((ObLink *)item))) {