diff --git a/deps/oblib/src/lib/alloc/block_set.cpp b/deps/oblib/src/lib/alloc/block_set.cpp index c987b1260a..6862c0bada 100644 --- a/deps/oblib/src/lib/alloc/block_set.cpp +++ b/deps/oblib/src/lib/alloc/block_set.cpp @@ -43,6 +43,11 @@ BlockSet::~BlockSet() reset(); } +bool BlockSet::check_has_unfree() +{ + return clist_ != NULL; +} + void BlockSet::reset() { while (NULL != clist_) { diff --git a/deps/oblib/src/lib/alloc/block_set.h b/deps/oblib/src/lib/alloc/block_set.h index 29e5c86112..ff19361821 100644 --- a/deps/oblib/src/lib/alloc/block_set.h +++ b/deps/oblib/src/lib/alloc/block_set.h @@ -73,6 +73,7 @@ public: void reset(); void set_locker(ISetLocker *locker) { locker_ = locker; } int64_t sync_wash(int64_t wash_size=INT64_MAX); + bool check_has_unfree(); private: DISALLOW_COPY_AND_ASSIGN(BlockSet); diff --git a/deps/oblib/src/lib/alloc/ob_malloc_allocator.cpp b/deps/oblib/src/lib/alloc/ob_malloc_allocator.cpp index c4e887b6c0..831c5a69f5 100644 --- a/deps/oblib/src/lib/alloc/ob_malloc_allocator.cpp +++ b/deps/oblib/src/lib/alloc/ob_malloc_allocator.cpp @@ -705,7 +705,7 @@ int ObMallocAllocator::recycle_tenant_allocator(uint64_t tenant_id) int64_t ref_cnt = tas[ctx_id]->get_ref_cnt(); if (0 == ref_cnt) { LOG_INFO("wait tenant ctx allocator success", K(tenant_id), K(ctx_id), - K(get_global_ctx_info().get_ctx_name(ctx_id))); + "ctx_name", get_global_ctx_info().get_ctx_name(ctx_id)); tas[ctx_id] = NULL; waiting_cnt--; } @@ -718,7 +718,7 @@ int ObMallocAllocator::recycle_tenant_allocator(uint64_t tenant_id) if (ctx_allocator != NULL) { LOG_ERROR("tenant ctx allocator is still refered by upper-layer modules", K(tenant_id), K(ctx_id), - K(get_global_ctx_info().get_ctx_name(ctx_id)), + "ctx_name", get_global_ctx_info().get_ctx_name(ctx_id), K(ctx_allocator->get_ref_cnt())); } } @@ -728,11 +728,10 @@ int ObMallocAllocator::recycle_tenant_allocator(uint64_t tenant_id) ObTenantCtxAllocator *ctx_allocator = tas[ctx_id]; if (NULL == ctx_allocator) { ctx_allocator = &ta[ctx_id]; - const char *first_label = NULL; - bool has_unfree = ctx_allocator->check_has_unfree(&first_label); + bool has_unfree = ctx_allocator->check_has_unfree(); if (has_unfree) { - LOG_ERROR("tenant ctx allocator has unfree objects", K(tenant_id), - K(ctx_id), K(get_global_ctx_info().get_ctx_name(ctx_id)), K(first_label)); + LOG_ERROR("tenant memory leak!!!", K(tenant_id), + K(ctx_id), "ctx_name", get_global_ctx_info().get_ctx_name(ctx_id)); tas[ctx_id] = ctx_allocator; } } diff --git a/deps/oblib/src/lib/alloc/ob_tenant_ctx_allocator.h b/deps/oblib/src/lib/alloc/ob_tenant_ctx_allocator.h index 90db152ed7..3b2f18fef8 100644 --- a/deps/oblib/src/lib/alloc/ob_tenant_ctx_allocator.h +++ b/deps/oblib/src/lib/alloc/ob_tenant_ctx_allocator.h @@ -165,7 +165,7 @@ public: int iter_label(VisitFunc func) const; int64_t sync_wash(int64_t wash_size); int64_t sync_wash(); - bool check_has_unfree(const char **first_label) { return obj_mgr_.check_has_unfree(first_label); } + bool check_has_unfree() { return obj_mgr_.check_has_unfree(); } void update_wash_stat(int64_t related_chunks, int64_t blocks, int64_t size); private: int64_t inc_ref_cnt(int64_t cnt) { return ATOMIC_FAA(&ref_cnt_, cnt); } diff --git a/deps/oblib/src/lib/alloc/object_mgr.cpp b/deps/oblib/src/lib/alloc/object_mgr.cpp index 0f479dac49..cb17c4add8 100644 --- a/deps/oblib/src/lib/alloc/object_mgr.cpp +++ b/deps/oblib/src/lib/alloc/object_mgr.cpp @@ -296,7 +296,7 @@ ObjectMgr::Stat ObjectMgr::get_stat() }; } -bool ObjectMgr::check_has_unfree(const char **first_label) +bool ObjectMgr::check_has_unfree() { bool has_unfree = false; for (uint64_t idx = 0; idx < ATOMIC_LOAD(&sub_cnt_) && !has_unfree; idx++) { @@ -304,7 +304,7 @@ bool ObjectMgr::check_has_unfree(const char **first_label) if (OB_ISNULL(sub_mgr)) { // do nothing } else { - has_unfree = sub_mgr->check_has_unfree(first_label); + has_unfree = sub_mgr->check_has_unfree(); } } return has_unfree; diff --git a/deps/oblib/src/lib/alloc/object_mgr.h b/deps/oblib/src/lib/alloc/object_mgr.h index 5ac86d06a1..121328f1b3 100644 --- a/deps/oblib/src/lib/alloc/object_mgr.h +++ b/deps/oblib/src/lib/alloc/object_mgr.h @@ -59,7 +59,7 @@ public: OB_INLINE int64_t get_hold() { return bs_.get_total_hold(); } OB_INLINE int64_t get_payload() { return bs_.get_total_payload(); } OB_INLINE int64_t get_used() { return bs_.get_total_used(); } - OB_INLINE bool check_has_unfree(const char **first_label) { return os_.check_has_unfree(first_label); } + OB_INLINE bool check_has_unfree() { return bs_.check_has_unfree(); } private: #ifndef ENABLE_SANITY lib::ObMutex mutex_; @@ -101,7 +101,7 @@ public: void print_usage() const; int64_t sync_wash(int64_t wash_size) override; Stat get_stat(); - bool check_has_unfree(const char **first_label); + bool check_has_unfree(); private: SubObjectMgr *create_sub_mgr(); void destroy_sub_mgr(SubObjectMgr *sub_mgr); diff --git a/deps/oblib/src/lib/alloc/object_set.h b/deps/oblib/src/lib/alloc/object_set.h index 8916937d93..94289644f5 100644 --- a/deps/oblib/src/lib/alloc/object_set.h +++ b/deps/oblib/src/lib/alloc/object_set.h @@ -69,7 +69,6 @@ public: inline int64_t get_normal_hold() const; inline int64_t get_normal_used() const; inline int64_t get_normal_alloc() const; - bool check_has_unfree(const char **first_label=NULL); private: AObject *alloc_normal_object(const uint32_t cls, const ObMemAttr &attr); @@ -92,9 +91,9 @@ private: void do_free_object(AObject *obj); void do_free_dirty_list(); + bool check_has_unfree(const char **first_label=NULL); private: - bool check_unfree_; __MemoryContext__ *mem_context_; ISetLocker *locker_; IBlockMgr *blk_mgr_; diff --git a/src/storage/tx_storage/ob_tenant_memory_printer.cpp b/src/storage/tx_storage/ob_tenant_memory_printer.cpp index 996395e00a..ec190468f5 100644 --- a/src/storage/tx_storage/ob_tenant_memory_printer.cpp +++ b/src/storage/tx_storage/ob_tenant_memory_printer.cpp @@ -90,20 +90,14 @@ int ObTenantMemoryPrinter::print_tenant_usage() LOG_WARN("print mtl tenant usage failed", K(tmp_ret), K(tenant_id)); } } - static int64_t last_print_ts = 0; - const int64_t now = ObTimeUtility::current_time(); - const int64_t INTERVAL = 10 * 60 * 1000000L; - if (now - last_print_ts >= INTERVAL) { - int tenant_cnt = 0; - static uint64_t all_tenant_ids[OB_MAX_SERVER_TENANT_CNT] = {0}; - lib::ObMallocAllocator *mallocator = lib::ObMallocAllocator::get_instance(); - mallocator->get_unrecycled_tenant_ids(all_tenant_ids, OB_MAX_SERVER_TENANT_CNT, tenant_cnt); - for (int64_t i = 0; OB_SUCC(ret) && i < tenant_cnt; ++i) { - uint64_t id = all_tenant_ids[i]; - mallocator->print_tenant_memory_usage(id); - mallocator->print_tenant_ctx_memory_usage(id); - } - last_print_ts = now; + int tenant_cnt = 0; + static uint64_t all_tenant_ids[OB_MAX_SERVER_TENANT_CNT] = {0}; + lib::ObMallocAllocator *mallocator = lib::ObMallocAllocator::get_instance(); + mallocator->get_unrecycled_tenant_ids(all_tenant_ids, OB_MAX_SERVER_TENANT_CNT, tenant_cnt); + for (int64_t i = 0; OB_SUCC(ret) && i < tenant_cnt; ++i) { + uint64_t id = all_tenant_ids[i]; + mallocator->print_tenant_memory_usage(id); + mallocator->print_tenant_ctx_memory_usage(id); } }