[CP] [FEAT MERGE] CRASH ERROR include SQL_INFO 2.0
This commit is contained in:
23
deps/oblib/src/lib/signal/ob_signal_handlers.cpp
vendored
23
deps/oblib/src/lib/signal/ob_signal_handlers.cpp
vendored
@ -224,19 +224,24 @@ void coredump_cb(volatile int sig, volatile int sig_code, void* volatile sig_add
|
||||
crash_info, ip, bp, sig, sig_code, sig_addr, rlimit_core,
|
||||
ts, GETTID(), tname, TRACE_ID_FORMAT_PARAM(uval),
|
||||
(NULL == extra_info) ? NULL : to_cstring(*extra_info), bt);
|
||||
const auto &si_guard = ObSqlInfoGuard::get_cur_guard();
|
||||
char sql[] = "SQL=";
|
||||
ObSqlInfo sql_info = ObSqlInfoGuard::get_tl_sql_info();
|
||||
char sql_id[] = "SQL_ID=";
|
||||
char sql_string[] = ", SQL_STRING=";
|
||||
char end[] = "\n";
|
||||
struct iovec iov[4];
|
||||
struct iovec iov[6];
|
||||
memset(iov, 0, sizeof(iov));
|
||||
iov[0].iov_base = print_buf;
|
||||
iov[0].iov_len = print_len;
|
||||
iov[1].iov_base = sql;
|
||||
iov[1].iov_len = strlen(sql);
|
||||
iov[2].iov_base = NULL != si_guard ? si_guard->sql_.ptr() : NULL;
|
||||
iov[2].iov_len = NULL != si_guard ? si_guard->sql_.length() : 0;
|
||||
iov[3].iov_base = end;
|
||||
iov[3].iov_len = strlen(end);
|
||||
iov[1].iov_base = sql_id;
|
||||
iov[1].iov_len = strlen(sql_id);
|
||||
iov[2].iov_base = sql_info.sql_id_.ptr();
|
||||
iov[2].iov_len = sql_info.sql_id_.length();
|
||||
iov[3].iov_base = sql_string;
|
||||
iov[3].iov_len = strlen(sql_string);
|
||||
iov[4].iov_base = sql_info.sql_string_.ptr();
|
||||
iov[4].iov_len = sql_info.sql_string_.length();
|
||||
iov[5].iov_base = end;
|
||||
iov[5].iov_len = strlen(end);
|
||||
writev(STDERR_FILENO, iov, sizeof(iov) / sizeof(iov[0]));
|
||||
if (OB_SUCC(ret)) {
|
||||
int status = 0;
|
||||
|
||||
@ -27,6 +27,8 @@ const int MP_SIG = SIGURG;
|
||||
const int SIG_STACK_SIZE = 16L<<10;
|
||||
uint64_t g_rlimit_core = 0;
|
||||
|
||||
thread_local ObSqlInfo ObSqlInfoGuard::tl_sql_info;
|
||||
|
||||
DTraceId DTraceId::gen_trace_id()
|
||||
{
|
||||
static int64_t seq = 0;
|
||||
|
||||
30
deps/oblib/src/lib/signal/ob_signal_struct.h
vendored
30
deps/oblib/src/lib/signal/ob_signal_struct.h
vendored
@ -112,32 +112,38 @@ struct ObSigHandlerCtx
|
||||
|
||||
extern ObSigHandlerCtx g_sig_handler_ctx_;
|
||||
|
||||
struct ObSqlInfo
|
||||
{
|
||||
ObString sql_string_;
|
||||
ObString sql_id_;
|
||||
};
|
||||
|
||||
class ObSqlInfoGuard
|
||||
{
|
||||
public:
|
||||
ObSqlInfoGuard(const ObString &sql)
|
||||
: sql_(sql)
|
||||
ObSqlInfoGuard(const ObString &sql_string, const ObString &sql_id)
|
||||
: last_sql_info_(tl_sql_info)
|
||||
{
|
||||
last_ = get_cur_guard();
|
||||
get_cur_guard() = this;
|
||||
tl_sql_info.sql_string_ = sql_string;
|
||||
tl_sql_info.sql_id_ = sql_id;
|
||||
}
|
||||
~ObSqlInfoGuard()
|
||||
{
|
||||
get_cur_guard() = last_;
|
||||
tl_sql_info = last_sql_info_;
|
||||
}
|
||||
static ObSqlInfoGuard *&get_cur_guard()
|
||||
static ObSqlInfo get_tl_sql_info()
|
||||
{
|
||||
static thread_local ObSqlInfoGuard *cur_guard = NULL;
|
||||
return cur_guard;
|
||||
return tl_sql_info;
|
||||
}
|
||||
public:
|
||||
ObString sql_;
|
||||
private:
|
||||
|
||||
ObSqlInfoGuard *last_;
|
||||
static thread_local ObSqlInfo tl_sql_info;
|
||||
ObSqlInfo last_sql_info_;
|
||||
};
|
||||
|
||||
} // namespace common
|
||||
} // namespace oceanbase
|
||||
|
||||
#define SQL_INFO_GUARD(sql_string, sql_id) \
|
||||
oceanbase::common::ObSqlInfoGuard sql_info_guard(sql_string, sql_id);
|
||||
|
||||
#endif // OCEANBASE_SIGNAL_STRUCT_H_
|
||||
|
||||
Reference in New Issue
Block a user