add right_to_die info into CRASH ERROR

This commit is contained in:
tushicheng 2023-05-11 14:11:12 +00:00 committed by ob-robot
parent cf5be5d6f4
commit b4a80d0e0c
3 changed files with 25 additions and 2 deletions

View File

@ -181,9 +181,17 @@ void coredump_cb(int sig, siginfo_t *si, void *context)
if (UINT64_MAX != g_rlimit_core) {
safe_snprintf(rlimit_core, sizeof(rlimit_core), "%lu", g_rlimit_core);
}
char crash_info[128] = "CRASH ERROR!!!";
int64_t fatal_error_thread_id = get_fatal_error_thread_id();
if (-1 != fatal_error_thread_id) {
safe_snprintf(crash_info, sizeof(crash_info),
"Right to Die or Duty to Live's Thread Existed before CRASH ERROR!!!"
"ThreadId=%ld,", fatal_error_thread_id);
}
ssize_t print_len = safe_snprintf(print_buf, sizeof(print_buf),
"CRASH ERROR!!! IP=%lx, RBP=%lx, sig=%d, sig_code=%d, sig_addr=%p, RLIMIT_CORE=%s, "COMMON_FMT", ",
ip, bp, sig, si->si_code, si->si_addr, rlimit_core, ts, GETTID(), tname, uval[0], uval[1], uval[2], uval[3],
"%s IP=%lx, RBP=%lx, sig=%d, sig_code=%d, sig_addr=%p, RLIMIT_CORE=%s, "COMMON_FMT", ",
crash_info, ip, bp, sig, si->si_code, si->si_addr, rlimit_core,
ts, GETTID(), tname, uval[0], uval[1], uval[2], uval[3],
(NULL == extra_info) ? NULL : to_cstring(*extra_info), bt);
const auto &si_guard = ObSqlInfoGuard::get_cur_guard();
char sql[] = "SQL=";

View File

@ -27,11 +27,22 @@ namespace oceanbase
namespace common
{
_RLOCAL(bool, in_try_stmt);
int64_t g_fatal_error_thread_id = -1;
int64_t get_fatal_error_thread_id()
{
return g_fatal_error_thread_id;
}
void set_fatal_error_thread_id(int64_t thread_id)
{
g_fatal_error_thread_id = thread_id;
}
// To die or to live, it's a problem.
void right_to_die_or_duty_to_live()
{
const ObFatalErrExtraInfoGuard *extra_info = ObFatalErrExtraInfoGuard::get_thd_local_val_ptr();
set_fatal_error_thread_id(GETTID());
while (true) {
const char *info = (NULL == extra_info) ? NULL : to_cstring(*extra_info);
LOG_DBA_ERROR(OB_ERR_THREAD_PANIC, "msg", "Trying so hard to die", KCSTRING(info), KCSTRING(lbt()));

View File

@ -21,6 +21,10 @@ namespace oceanbase
namespace common
{
extern void right_to_die_or_duty_to_live();
int64_t get_fatal_error_thread_id();
void set_fatal_error_thread_id(int64_t thread_id);
RLOCAL_EXTERN(bool, in_try_stmt);
struct OB_BASE_EXCEPTION : public std::exception