[CP] [FEAT MERGE] CRASH ERROR include SQL_INFO 2.0
This commit is contained in:
parent
eb197925b7
commit
d6e0624219
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_
|
||||
|
@ -690,7 +690,7 @@ OB_INLINE int ObMPQuery::do_process(ObSQLSessionInfo &session,
|
||||
ObTenantCachedSchemaGuardInfo &cached_schema_info = session.get_cached_schema_guard_info();
|
||||
int64_t tenant_version = 0;
|
||||
int64_t sys_version = 0;
|
||||
common::ObSqlInfoGuard si_guard(sql);
|
||||
SQL_INFO_GUARD(sql, session.get_cur_sql_id());
|
||||
ObSqlFatalErrExtraInfoGuard extra_info_guard;
|
||||
extra_info_guard.set_cur_sql(sql);
|
||||
extra_info_guard.set_tenant_id(session.get_effective_tenant_id());
|
||||
|
@ -1830,6 +1830,7 @@ int ObMPStmtExecute::process()
|
||||
lib::CompatModeGuard g(sess->get_compatibility_mode() == ORACLE_MODE ?
|
||||
lib::Worker::CompatMode::ORACLE : lib::Worker::CompatMode::MYSQL);
|
||||
ObSQLSessionInfo::LockGuard lock_guard(session.get_query_lock());
|
||||
SQL_INFO_GUARD(ctx_.cur_sql_, ObString(ctx_.sql_id_));
|
||||
session.set_current_trace_id(ObCurTraceId::get_trace_id());
|
||||
session.init_use_rich_format();
|
||||
session.get_raw_audit_record().request_memory_used_ = 0;
|
||||
|
@ -179,6 +179,7 @@ int ObMPStmtPrepare::process()
|
||||
lib::CompatModeGuard g(sess->get_compatibility_mode() == ORACLE_MODE ?
|
||||
lib::Worker::CompatMode::ORACLE : lib::Worker::CompatMode::MYSQL);
|
||||
ObSQLSessionInfo::LockGuard lock_guard(session.get_query_lock());
|
||||
SQL_INFO_GUARD(ctx_.cur_sql_, ObString(ctx_.sql_id_));
|
||||
session.set_current_trace_id(ObCurTraceId::get_trace_id());
|
||||
session.init_use_rich_format();
|
||||
session.get_raw_audit_record().request_memory_used_ = 0;
|
||||
|
@ -76,7 +76,7 @@ public:
|
||||
virtual int execute(sql::ObSql &engine, sql::ObSqlCtx &ctx, sql::ObResultSet &res)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
common::ObSqlInfoGuard si_guard(sql_);
|
||||
SQL_INFO_GUARD(sql_, ObString(OB_MAX_SQL_ID_LENGTH, ctx.sql_id_));
|
||||
// Deep copy sql, because sql may be destroyed before result iteration.
|
||||
const int64_t alloc_size = sizeof(ObString) + sql_.length() + 1; // 1 for C terminate char
|
||||
void *mem = res.get_mem_pool().alloc(alloc_size);
|
||||
|
@ -140,7 +140,7 @@ int ObInnerSQLResult::open()
|
||||
LOG_WARN("switch tenant failed", K(ret), K(session_.get_effective_tenant_id()));
|
||||
} else {
|
||||
lib::CompatModeGuard g(compat_mode_);
|
||||
common::ObSqlInfoGuard si_guard(session_.get_current_query_string());
|
||||
SQL_INFO_GUARD(session_.get_current_query_string(), session_.get_cur_sql_id());
|
||||
bool is_select = has_tenant_resource() ?
|
||||
ObStmt::is_select_stmt(result_set_->get_stmt_type())
|
||||
: ObStmt::is_select_stmt(remote_result_set_->get_stmt_type());
|
||||
@ -205,7 +205,7 @@ int ObInnerSQLResult::inner_close()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
lib::CompatModeGuard g(compat_mode_);
|
||||
common::ObSqlInfoGuard si_guard(session_.get_current_query_string());
|
||||
SQL_INFO_GUARD(session_.get_current_query_string(), session_.get_cur_sql_id());
|
||||
LOG_DEBUG("compat_mode_", K(ret), K(compat_mode_), K(lbt()));
|
||||
|
||||
MAKE_TENANT_SWITCH_SCOPE_GUARD(tenant_guard);
|
||||
@ -244,7 +244,7 @@ int ObInnerSQLResult::next()
|
||||
} else {
|
||||
row_ = NULL;
|
||||
lib::CompatModeGuard g(compat_mode_);
|
||||
common::ObSqlInfoGuard si_guard(session_.get_current_query_string());
|
||||
SQL_INFO_GUARD(session_.get_current_query_string(), session_.get_cur_sql_id());
|
||||
WITH_CONTEXT(mem_context_) {
|
||||
if (has_tenant_resource() && OB_FAIL(result_set_->get_next_row(row_))) {
|
||||
if (OB_ITER_END != ret) {
|
||||
|
@ -11,6 +11,7 @@
|
||||
*/
|
||||
|
||||
#define USING_LOG_PREFIX SQL_DAS
|
||||
#include "lib/signal/ob_signal_struct.h"
|
||||
#include "sql/das/ob_das_rpc_processor.h"
|
||||
#include "sql/das/ob_data_access_service.h"
|
||||
#include "sql/das/ob_das_utils.h"
|
||||
@ -76,6 +77,7 @@ int ObDASBaseAccessP<pcode>::process()
|
||||
LOG_DEBUG("DAS base access remote process", K_(RpcProcessor::arg));
|
||||
ObDASTaskArg &task = RpcProcessor::arg_;
|
||||
ObDASTaskResp &task_resp = RpcProcessor::result_;
|
||||
SQL_INFO_GUARD(ObString("DAS REMOTE PROCESS"), task.get_remote_info()->sql_id_);
|
||||
const common::ObSEArray<ObIDASTaskOp*, 2> &task_ops = task.get_task_ops();
|
||||
common::ObSEArray<ObIDASTaskResult*, 2> &task_results = task_resp.get_op_results();
|
||||
ObDASTaskFactory *das_factory = ObDASBaseAccessP<pcode>::get_das_factory();
|
||||
|
@ -105,8 +105,8 @@ int ObQCMonitoringInfo::init(const ObExecContext &exec_ctx) {
|
||||
if (OB_NOT_NULL(exec_ctx.get_my_session())) {
|
||||
cur_sql_ = exec_ctx.get_my_session()->get_current_query_string();
|
||||
}
|
||||
if (cur_sql_.length() > ObQCMonitoringInfo::LIMIT_LENGTH) {
|
||||
cur_sql_.assign(cur_sql_.ptr(), ObQCMonitoringInfo::LIMIT_LENGTH);
|
||||
if (cur_sql_.length() > OB_TINY_SQL_LENGTH) {
|
||||
cur_sql_.assign(cur_sql_.ptr(), OB_TINY_SQL_LENGTH);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -192,8 +192,6 @@ public:
|
||||
common::ObString cur_sql_;
|
||||
// in nested px situation, it is the current px coordinator's thread id
|
||||
int64_t qc_tid_;
|
||||
// no need to deserialize
|
||||
static constexpr int64_t LIMIT_LENGTH = 100;
|
||||
TO_STRING_KV(K_(cur_sql), K_(qc_tid));
|
||||
};
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "ob_px_task_process.h"
|
||||
#include "ob_px_admission.h"
|
||||
#include "ob_px_sqc_handler.h"
|
||||
#include "lib/signal/ob_signal_struct.h"
|
||||
#include "lib/ash/ob_active_session_guard.h"
|
||||
#include "sql/executor/ob_executor_rpc_processor.h"
|
||||
#include "sql/dtl/ob_dtl_channel_group.h"
|
||||
@ -167,6 +168,7 @@ int ObInitSqcP::startup_normal_sqc(ObPxSqcHandler &sqc_handler)
|
||||
LOG_WARN("session is NULL", K(ret));
|
||||
} else {
|
||||
ObPxRpcInitSqcArgs &arg = sqc_handler.get_sqc_init_arg();
|
||||
SQL_INFO_GUARD(arg.sqc_.get_monitoring_info().cur_sql_, session->get_cur_sql_id());
|
||||
ObWorkerSessionGuard worker_session_guard(session);
|
||||
ObSQLSessionInfo::LockGuard lock_guard(session->get_query_lock());
|
||||
session->set_current_trace_id(ObCurTraceId::get_trace_id());
|
||||
@ -461,6 +463,7 @@ int ObInitFastSqcP::startup_normal_sqc(ObPxSqcHandler &sqc_handler)
|
||||
LOG_WARN("session is NULL", K(ret));
|
||||
} else {
|
||||
ObPxRpcInitSqcArgs &arg = sqc_handler.get_sqc_init_arg();
|
||||
SQL_INFO_GUARD(arg.sqc_.get_monitoring_info().cur_sql_, session->get_cur_sql_id());
|
||||
ObWorkerSessionGuard worker_session_guard(session);
|
||||
ObSQLSessionInfo::LockGuard lock_guard(session->get_query_lock());
|
||||
session->set_peer_addr(arg.sqc_.get_qc_addr());
|
||||
|
@ -139,13 +139,16 @@ int ObPxTaskProcess::process()
|
||||
ObSQLSessionInfo *session = (NULL == arg_.exec_ctx_
|
||||
? NULL
|
||||
: arg_.exec_ctx_->get_my_session());
|
||||
if (OB_ISNULL(session)) {
|
||||
ObPxSqcHandler *sqc_handler = arg_.sqc_handler_;
|
||||
if (OB_ISNULL(session) || OB_ISNULL(sqc_handler)) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("session is NULL", K(ret));
|
||||
LOG_WARN("session or sqc_handler is NULL", K(ret));
|
||||
} else if (OB_FAIL(session->store_query_string(ObString::make_string("PX DFO EXECUTING")))) {
|
||||
LOG_WARN("store query string to session failed", K(ret));
|
||||
} else {
|
||||
// 设置诊断功能环境
|
||||
ObPxRpcInitSqcArgs &arg = arg_.sqc_handler_->get_sqc_init_arg();
|
||||
SQL_INFO_GUARD(arg.sqc_.get_monitoring_info().cur_sql_, session->get_cur_sql_id());
|
||||
const bool enable_perf_event = lib::is_diagnose_info_enabled();
|
||||
const bool enable_sql_audit =
|
||||
GCONF.enable_sql_audit && session->get_local_ob_enable_sql_audit();
|
||||
|
@ -648,6 +648,7 @@ int ObRemoteBaseExecuteP<T>::execute_with_sql(ObRemoteTask &task)
|
||||
// 设置诊断功能环境
|
||||
if (OB_SUCC(ret)) {
|
||||
ObSessionStatEstGuard stat_est_guard(session->get_effective_tenant_id(), session->get_sessid());
|
||||
SQL_INFO_GUARD(task.get_remote_sql_info()->remote_sql_, session->get_cur_sql_id());
|
||||
// 初始化ObTask的执行环节
|
||||
//
|
||||
//
|
||||
@ -946,6 +947,7 @@ int ObRpcRemoteExecuteP::process()
|
||||
ObSessionStatEstGuard stat_est_guard(
|
||||
session->get_effective_tenant_id(),
|
||||
session->get_sessid());
|
||||
SQL_INFO_GUARD(task.get_sql_string(), session->get_cur_sql_id());
|
||||
// 初始化ObTask的执行环节
|
||||
//
|
||||
//
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
#define USING_LOG_PREFIX SQL_EXE
|
||||
|
||||
#include "lib/signal/ob_signal_struct.h"
|
||||
#include "sql/session/ob_sql_session_info.h"
|
||||
#include "sql/engine/ob_physical_plan_ctx.h"
|
||||
#include "sql/engine/ob_exec_context.h"
|
||||
@ -174,6 +175,7 @@ int ObRemoteTaskExecutor::build_task(ObExecContext &query_ctx,
|
||||
task.set_runner_server(task_info.get_task_location().get_server());
|
||||
task.set_ob_task_id(task_info.get_task_location().get_ob_task_id());
|
||||
task.set_serialize_param(&query_ctx, root_spec, phy_plan);
|
||||
task.set_sql_string(ObSqlInfoGuard::get_tl_sql_info().sql_string_);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
@ -157,6 +157,9 @@ OB_DEF_DESERIALIZE(ObTask)
|
||||
LST_DO_CODE(OB_UNIS_DECODE, max_sql_no_);
|
||||
ObString sql_string;
|
||||
OB_UNIS_DECODE(sql_string);
|
||||
if(OB_SUCC(ret)) {
|
||||
set_sql_string(sql_string);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -69,6 +69,17 @@ public:
|
||||
void set_max_sql_no(int64_t max_sql_no) { max_sql_no_ = max_sql_no; }
|
||||
const common::ObIArray<ObNewRange> &get_ranges() const { return ranges_; }
|
||||
int assign_ranges(const ObIArray<ObNewRange> &ranges);
|
||||
const ObString get_sql_string() const { return ObString(sql_string_); }
|
||||
void set_sql_string(const ObString &sql_string)
|
||||
{
|
||||
if (0 == sql_string.length()) {
|
||||
sql_string_[0] = '\0';
|
||||
} else {
|
||||
int64_t str_size = min(sql_string.length(), common::OB_TINY_SQL_LENGTH);
|
||||
STRNCPY(sql_string_, sql_string.ptr(), str_size);
|
||||
sql_string_[str_size] = '\0';
|
||||
}
|
||||
}
|
||||
TO_STRING_KV(N_OB_TASK_ID, ob_task_id_,
|
||||
K_(runner_svr),
|
||||
K_(ctrl_svr),
|
||||
|
@ -4710,6 +4710,9 @@ OB_DEF_DESERIALIZE(ObBasicSessionInfo)
|
||||
}();
|
||||
ObString sql_id;
|
||||
OB_UNIS_DECODE(sql_id);
|
||||
if (OB_SUCC(ret)) {
|
||||
set_cur_sql_id(sql_id.ptr());
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
LST_DO_CODE(OB_UNIS_DECODE,
|
||||
proxy_user_id_,
|
||||
|
@ -985,7 +985,7 @@ public:
|
||||
int load_all_sys_vars(const share::schema::ObSysVariableSchema &sys_var_schema, bool sys_var_created);
|
||||
int clean_all_sys_vars();
|
||||
SysVarIncInfo sys_var_inc_info_;
|
||||
|
||||
const ObString get_cur_sql_id() const { return ObString(sql_id_); }
|
||||
void get_cur_sql_id(char *sql_id_buf, int64_t sql_id_buf_size) const;
|
||||
void set_cur_sql_id(char *sql_id);
|
||||
int set_cur_phy_plan(ObPhysicalPlan *cur_phy_plan);
|
||||
|
Loading…
x
Reference in New Issue
Block a user