print backtrace and tenant memory status when failed to alloc memory

This commit is contained in:
gaopy3
2025-02-18 00:15:43 +00:00
committed by ob-robot
parent b9b0f95927
commit 327bbc2b3c
3 changed files with 15 additions and 4 deletions

View File

@ -126,7 +126,9 @@ char *alloc_failed_msg()
return msg;
}
void print_alloc_failed_msg()
void print_alloc_failed_msg(uint64_t tenant_id, uint64_t ctx_id,
int64_t ctx_hold, int64_t ctx_limit,
int64_t tenant_hold, int64_t tenant_limit)
{
if (TC_REACH_TIME_INTERVAL(1 * 1000 * 1000)) {
#ifdef FATAL_ERROR_HANG
@ -136,7 +138,12 @@ void print_alloc_failed_msg()
}
#endif
const char *msg = alloc_failed_msg();
LOG_DBA_WARN_V2(OB_LIB_ALLOCATE_MEMORY_FAIL, OB_ALLOCATE_MEMORY_FAILED, "[OOPS]: alloc failed reason is that ", msg);
LOG_DBA_WARN_V2(OB_LIB_ALLOCATE_MEMORY_FAIL, OB_ALLOCATE_MEMORY_FAILED, "[oops]: alloc failed reason is that ", msg);
_OB_LOG_RET(WARN, OB_ALLOCATE_MEMORY_FAILED, "[OOPS]: alloc failed reason is that %s. "
"detailed info: tenant_id=%lu, ctx_id=%lu, ctx_name=%s, ctx_hold=%ld, "
"ctx_limit=%ld, tenant_hold=%ld, tenant_limit=%ld, backtrace=%s",
msg, tenant_id, ctx_id, get_global_ctx_info().get_ctx_name(ctx_id),
ctx_hold, ctx_limit, tenant_hold, tenant_limit, lbt());
// 49 is the user defined signal to dump memory
raise(49);
}

View File

@ -71,7 +71,9 @@ public:
char *alloc_failed_msg();
AllocFailedCtx &g_alloc_failed_ctx();
void print_alloc_failed_msg();
void print_alloc_failed_msg(uint64_t tenant_id, uint64_t ctx_id,
int64_t ctx_hold, int64_t ctx_limit,
int64_t tenant_hold, int64_t tenant_limit);
} // end of namespace lib
} // end of namespace oceanbase

View File

@ -412,7 +412,9 @@ public:
}
}
if (NULL == nptr) {
print_alloc_failed_msg();
print_alloc_failed_msg(ta.get_tenant_id(), ta.get_ctx_id(),
ta.get_hold(), ta.get_limit(),
ta.get_tenant_hold(), ta.get_tenant_limit());
}
return nptr;
}