fix miss check for tenant memory leak
This commit is contained in:
5
deps/oblib/src/lib/alloc/block_set.cpp
vendored
5
deps/oblib/src/lib/alloc/block_set.cpp
vendored
@ -43,6 +43,11 @@ BlockSet::~BlockSet()
|
||||
reset();
|
||||
}
|
||||
|
||||
bool BlockSet::check_has_unfree()
|
||||
{
|
||||
return clist_ != NULL;
|
||||
}
|
||||
|
||||
void BlockSet::reset()
|
||||
{
|
||||
while (NULL != clist_) {
|
||||
|
||||
1
deps/oblib/src/lib/alloc/block_set.h
vendored
1
deps/oblib/src/lib/alloc/block_set.h
vendored
@ -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);
|
||||
|
||||
11
deps/oblib/src/lib/alloc/ob_malloc_allocator.cpp
vendored
11
deps/oblib/src/lib/alloc/ob_malloc_allocator.cpp
vendored
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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); }
|
||||
|
||||
4
deps/oblib/src/lib/alloc/object_mgr.cpp
vendored
4
deps/oblib/src/lib/alloc/object_mgr.cpp
vendored
@ -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;
|
||||
|
||||
4
deps/oblib/src/lib/alloc/object_mgr.h
vendored
4
deps/oblib/src/lib/alloc/object_mgr.h
vendored
@ -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);
|
||||
|
||||
3
deps/oblib/src/lib/alloc/object_set.h
vendored
3
deps/oblib/src/lib/alloc/object_set.h
vendored
@ -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_;
|
||||
|
||||
@ -90,10 +90,6 @@ 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();
|
||||
@ -103,8 +99,6 @@ int ObTenantMemoryPrinter::print_tenant_usage()
|
||||
mallocator->print_tenant_memory_usage(id);
|
||||
mallocator->print_tenant_ctx_memory_usage(id);
|
||||
}
|
||||
last_print_ts = now;
|
||||
}
|
||||
}
|
||||
|
||||
if (OB_SIZE_OVERFLOW == ret) {
|
||||
|
||||
Reference in New Issue
Block a user