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();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool BlockSet::check_has_unfree()
|
||||||
|
{
|
||||||
|
return clist_ != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void BlockSet::reset()
|
void BlockSet::reset()
|
||||||
{
|
{
|
||||||
while (NULL != clist_) {
|
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 reset();
|
||||||
void set_locker(ISetLocker *locker) { locker_ = locker; }
|
void set_locker(ISetLocker *locker) { locker_ = locker; }
|
||||||
int64_t sync_wash(int64_t wash_size=INT64_MAX);
|
int64_t sync_wash(int64_t wash_size=INT64_MAX);
|
||||||
|
bool check_has_unfree();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DISALLOW_COPY_AND_ASSIGN(BlockSet);
|
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();
|
int64_t ref_cnt = tas[ctx_id]->get_ref_cnt();
|
||||||
if (0 == ref_cnt) {
|
if (0 == ref_cnt) {
|
||||||
LOG_INFO("wait tenant ctx allocator success", K(tenant_id), K(ctx_id),
|
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;
|
tas[ctx_id] = NULL;
|
||||||
waiting_cnt--;
|
waiting_cnt--;
|
||||||
}
|
}
|
||||||
@ -718,7 +718,7 @@ int ObMallocAllocator::recycle_tenant_allocator(uint64_t tenant_id)
|
|||||||
if (ctx_allocator != NULL) {
|
if (ctx_allocator != NULL) {
|
||||||
LOG_ERROR("tenant ctx allocator is still refered by upper-layer modules",
|
LOG_ERROR("tenant ctx allocator is still refered by upper-layer modules",
|
||||||
K(tenant_id), K(ctx_id),
|
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()));
|
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];
|
ObTenantCtxAllocator *ctx_allocator = tas[ctx_id];
|
||||||
if (NULL == ctx_allocator) {
|
if (NULL == ctx_allocator) {
|
||||||
ctx_allocator = &ta[ctx_id];
|
ctx_allocator = &ta[ctx_id];
|
||||||
const char *first_label = NULL;
|
bool has_unfree = ctx_allocator->check_has_unfree();
|
||||||
bool has_unfree = ctx_allocator->check_has_unfree(&first_label);
|
|
||||||
if (has_unfree) {
|
if (has_unfree) {
|
||||||
LOG_ERROR("tenant ctx allocator has unfree objects", K(tenant_id),
|
LOG_ERROR("tenant memory leak!!!", K(tenant_id),
|
||||||
K(ctx_id), K(get_global_ctx_info().get_ctx_name(ctx_id)), K(first_label));
|
K(ctx_id), "ctx_name", get_global_ctx_info().get_ctx_name(ctx_id));
|
||||||
tas[ctx_id] = ctx_allocator;
|
tas[ctx_id] = ctx_allocator;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -165,7 +165,7 @@ public:
|
|||||||
int iter_label(VisitFunc func) const;
|
int iter_label(VisitFunc func) const;
|
||||||
int64_t sync_wash(int64_t wash_size);
|
int64_t sync_wash(int64_t wash_size);
|
||||||
int64_t sync_wash();
|
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);
|
void update_wash_stat(int64_t related_chunks, int64_t blocks, int64_t size);
|
||||||
private:
|
private:
|
||||||
int64_t inc_ref_cnt(int64_t cnt) { return ATOMIC_FAA(&ref_cnt_, cnt); }
|
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;
|
bool has_unfree = false;
|
||||||
for (uint64_t idx = 0; idx < ATOMIC_LOAD(&sub_cnt_) && !has_unfree; idx++) {
|
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)) {
|
if (OB_ISNULL(sub_mgr)) {
|
||||||
// do nothing
|
// do nothing
|
||||||
} else {
|
} else {
|
||||||
has_unfree = sub_mgr->check_has_unfree(first_label);
|
has_unfree = sub_mgr->check_has_unfree();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 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_hold() { return bs_.get_total_hold(); }
|
||||||
OB_INLINE int64_t get_payload() { return bs_.get_total_payload(); }
|
OB_INLINE int64_t get_payload() { return bs_.get_total_payload(); }
|
||||||
OB_INLINE int64_t get_used() { return bs_.get_total_used(); }
|
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:
|
private:
|
||||||
#ifndef ENABLE_SANITY
|
#ifndef ENABLE_SANITY
|
||||||
lib::ObMutex mutex_;
|
lib::ObMutex mutex_;
|
||||||
@ -101,7 +101,7 @@ public:
|
|||||||
void print_usage() const;
|
void print_usage() const;
|
||||||
int64_t sync_wash(int64_t wash_size) override;
|
int64_t sync_wash(int64_t wash_size) override;
|
||||||
Stat get_stat();
|
Stat get_stat();
|
||||||
bool check_has_unfree(const char **first_label);
|
bool check_has_unfree();
|
||||||
private:
|
private:
|
||||||
SubObjectMgr *create_sub_mgr();
|
SubObjectMgr *create_sub_mgr();
|
||||||
void destroy_sub_mgr(SubObjectMgr *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_hold() const;
|
||||||
inline int64_t get_normal_used() const;
|
inline int64_t get_normal_used() const;
|
||||||
inline int64_t get_normal_alloc() const;
|
inline int64_t get_normal_alloc() const;
|
||||||
bool check_has_unfree(const char **first_label=NULL);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AObject *alloc_normal_object(const uint32_t cls, const ObMemAttr &attr);
|
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_object(AObject *obj);
|
||||||
void do_free_dirty_list();
|
void do_free_dirty_list();
|
||||||
|
bool check_has_unfree(const char **first_label=NULL);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool check_unfree_;
|
|
||||||
__MemoryContext__ *mem_context_;
|
__MemoryContext__ *mem_context_;
|
||||||
ISetLocker *locker_;
|
ISetLocker *locker_;
|
||||||
IBlockMgr *blk_mgr_;
|
IBlockMgr *blk_mgr_;
|
||||||
|
|||||||
@ -90,20 +90,14 @@ int ObTenantMemoryPrinter::print_tenant_usage()
|
|||||||
LOG_WARN("print mtl tenant usage failed", K(tmp_ret), K(tenant_id));
|
LOG_WARN("print mtl tenant usage failed", K(tmp_ret), K(tenant_id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static int64_t last_print_ts = 0;
|
int tenant_cnt = 0;
|
||||||
const int64_t now = ObTimeUtility::current_time();
|
static uint64_t all_tenant_ids[OB_MAX_SERVER_TENANT_CNT] = {0};
|
||||||
const int64_t INTERVAL = 10 * 60 * 1000000L;
|
lib::ObMallocAllocator *mallocator = lib::ObMallocAllocator::get_instance();
|
||||||
if (now - last_print_ts >= INTERVAL) {
|
mallocator->get_unrecycled_tenant_ids(all_tenant_ids, OB_MAX_SERVER_TENANT_CNT, tenant_cnt);
|
||||||
int tenant_cnt = 0;
|
for (int64_t i = 0; OB_SUCC(ret) && i < tenant_cnt; ++i) {
|
||||||
static uint64_t all_tenant_ids[OB_MAX_SERVER_TENANT_CNT] = {0};
|
uint64_t id = all_tenant_ids[i];
|
||||||
lib::ObMallocAllocator *mallocator = lib::ObMallocAllocator::get_instance();
|
mallocator->print_tenant_memory_usage(id);
|
||||||
mallocator->get_unrecycled_tenant_ids(all_tenant_ids, OB_MAX_SERVER_TENANT_CNT, tenant_cnt);
|
mallocator->print_tenant_ctx_memory_usage(id);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user