make mysqltest stable and fix MEMORY_LOG leak when tenant_500::DEFAULT_CTX reaches limit.
This commit is contained in:
8
deps/oblib/src/lib/alloc/memory_dump.cpp
vendored
8
deps/oblib/src/lib/alloc/memory_dump.cpp
vendored
@ -132,18 +132,16 @@ int ObMemoryDump::init()
|
||||
array_ = pre_mem->array_buf_;
|
||||
tenant_ids_ = (uint64_t*)pre_mem->tenant_ids_buf_;
|
||||
log_buf_ = pre_mem->log_buf_;
|
||||
if (OB_FAIL(lmap_.create(1000, "MemDumpMap"))) {
|
||||
if (OB_FAIL(lmap_.create(1000, ObMemAttr(OB_SERVER_TENANT_ID, "MemDumpMap", ObCtxIds::DEFAULT_CTX_ID, OB_HIGH_ALLOC)))) {
|
||||
LOG_WARN("create map failed", K(ret));
|
||||
} else {
|
||||
r_stat_ = new (pre_mem->stats_buf_) Stat();
|
||||
w_stat_ = new (r_stat_ + 1) Stat();
|
||||
dump_context_ = context;
|
||||
is_inited_ = true;
|
||||
if (OB_FAIL(r_stat_->malloc_sample_map_.create(1000, "MallocInfoMap",
|
||||
"MallocInfoMap"))) {
|
||||
if (OB_FAIL(r_stat_->malloc_sample_map_.create(1000, ObMemAttr(OB_SERVER_TENANT_ID, "MallocInfoMap", ObCtxIds::DEFAULT_CTX_ID, OB_HIGH_ALLOC)))) {
|
||||
LOG_WARN("create memory info map for reading failed", K(ret));
|
||||
} else if (OB_FAIL(w_stat_->malloc_sample_map_.create(1000, "MallocInfoMap",
|
||||
"MallocInfoMap"))) {
|
||||
} else if (OB_FAIL(w_stat_->malloc_sample_map_.create(1000, ObMemAttr(OB_SERVER_TENANT_ID, "MallocInfoMap", ObCtxIds::DEFAULT_CTX_ID, OB_HIGH_ALLOC)))) {
|
||||
LOG_WARN("create memory info map for writing failed", K(ret));
|
||||
}
|
||||
}
|
||||
|
53
deps/oblib/src/lib/alloc/ob_malloc_allocator.cpp
vendored
53
deps/oblib/src/lib/alloc/ob_malloc_allocator.cpp
vendored
@ -21,6 +21,7 @@
|
||||
#include "lib/allocator/ob_page_manager.h"
|
||||
#include "lib/rc/ob_rc.h"
|
||||
#include "lib/rc/context.h"
|
||||
#include "common/ob_smart_var.h"
|
||||
|
||||
using namespace oceanbase::lib;
|
||||
using namespace oceanbase::common;
|
||||
@ -496,37 +497,31 @@ void ObMallocAllocator::print_tenant_memory_usage(uint64_t tenant_id) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
with_resource_handle_invoke(tenant_id, [&](ObTenantMemoryMgr *mgr) {
|
||||
CREATE_WITH_TEMP_CONTEXT(ContextParam().set_label(ObModIds::OB_TEMP_VARIABLES)) {
|
||||
static const int64_t BUFLEN = 1 << 17;
|
||||
char *buf = (char *)ctxalp(BUFLEN);
|
||||
if (OB_ISNULL(buf)) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LIB_LOG(WARN, "no memory", K(ret));
|
||||
} else {
|
||||
int64_t ctx_pos = 0;
|
||||
const volatile int64_t *ctx_hold_bytes = mgr->get_ctx_hold_bytes();
|
||||
for (uint64_t i = 0; i < ObCtxIds::MAX_CTX_ID; i++) {
|
||||
if (ctx_hold_bytes[i] > 0) {
|
||||
int64_t limit = 0;
|
||||
IGNORE_RETURN mgr->get_ctx_limit(i, limit);
|
||||
ret = databuff_printf(buf, BUFLEN, ctx_pos,
|
||||
"[MEMORY] ctx_id=%25s hold_bytes=%'15ld limit=%'26ld\n",
|
||||
get_global_ctx_info().get_ctx_name(i), ctx_hold_bytes[i], limit);
|
||||
}
|
||||
static const int64_t BUFLEN = 1 << 16;
|
||||
SMART_VAR(char[BUFLEN], buf) {
|
||||
int64_t ctx_pos = 0;
|
||||
const volatile int64_t *ctx_hold_bytes = mgr->get_ctx_hold_bytes();
|
||||
for (uint64_t i = 0; OB_SUCC(ret) && i < ObCtxIds::MAX_CTX_ID; i++) {
|
||||
if (ctx_hold_bytes[i] > 0) {
|
||||
int64_t limit = 0;
|
||||
IGNORE_RETURN mgr->get_ctx_limit(i, limit);
|
||||
ret = databuff_printf(buf, BUFLEN, ctx_pos,
|
||||
"[MEMORY] ctx_id=%25s hold_bytes=%'15ld limit=%'26ld\n",
|
||||
get_global_ctx_info().get_ctx_name(i), ctx_hold_bytes[i], limit);
|
||||
}
|
||||
buf[std::min(ctx_pos, BUFLEN - 1)] = '\0';
|
||||
allow_next_syslog();
|
||||
_LOG_INFO("[MEMORY] tenant: %lu, limit: %'lu hold: %'lu rpc_hold: %'lu cache_hold: %'lu "
|
||||
"cache_used: %'lu cache_item_count: %'lu \n%s",
|
||||
tenant_id,
|
||||
mgr->get_limit(),
|
||||
mgr->get_sum_hold(),
|
||||
mgr->get_rpc_hold(),
|
||||
mgr->get_cache_hold(),
|
||||
mgr->get_cache_hold(),
|
||||
mgr->get_cache_item_count(),
|
||||
buf);
|
||||
}
|
||||
buf[std::min(ctx_pos, BUFLEN - 1)] = '\0';
|
||||
allow_next_syslog();
|
||||
_LOG_INFO("[MEMORY] tenant: %lu, limit: %'lu hold: %'lu rpc_hold: %'lu cache_hold: %'lu "
|
||||
"cache_used: %'lu cache_item_count: %'lu \n%s",
|
||||
tenant_id,
|
||||
mgr->get_limit(),
|
||||
mgr->get_sum_hold(),
|
||||
mgr->get_rpc_hold(),
|
||||
mgr->get_cache_hold(),
|
||||
mgr->get_cache_hold(),
|
||||
mgr->get_cache_item_count(),
|
||||
buf);
|
||||
}
|
||||
return ret;
|
||||
});
|
||||
|
@ -94,9 +94,6 @@ int ObMemLeakCheckerInfo::fill_row(common::ObNewRow *&row)
|
||||
ObObj *cells = NULL;
|
||||
if (OB_FAIL(sanity_check())) {
|
||||
// error
|
||||
} else if (0 == col_count) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
SERVER_LOG(WARN, "col count could not be zero");
|
||||
} else if (OB_ISNULL(cells = cur_row_.cells_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
SERVER_LOG(WARN, "cur row cell is NULL", K(ret));
|
||||
|
Reference in New Issue
Block a user