[FEAT MERGE]

This commit is contained in:
obdev
2022-11-21 07:38:55 +00:00
committed by wangzelin.wzl
parent 4cf8473874
commit e082b0bc9b
5 changed files with 51 additions and 3 deletions

View File

@ -183,10 +183,24 @@ void coredump_cb(int sig, siginfo_t *si, void *context)
safe_snprintf(rlimit_core, sizeof(rlimit_core), "%lu", g_rlimit_core);
}
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"\n",
"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],
(NULL == extra_info) ? NULL : to_cstring(*extra_info), bt);
write(STDERR_FILENO, print_buf, print_len);
const auto &si_guard = ObSqlInfoGuard::get_cur_guard();
char sql[] = "SQL=";
char end[] = "\n";
struct iovec iov[4];
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);
writev(STDERR_FILENO, iov, sizeof(iov) / sizeof(iov[0]));
#if MINICORE
} else {
// child

View File

@ -17,6 +17,7 @@
#include <stdint.h>
#include <time.h>
#include <signal.h>
#include "lib/string/ob_string.h"
namespace oceanbase
{
@ -111,6 +112,31 @@ struct ObSigHandlerCtx
extern ObSigHandlerCtx g_sig_handler_ctx_;
class ObSqlInfoGuard
{
public:
ObSqlInfoGuard(const ObString &sql)
: sql_(sql)
{
last_ = get_cur_guard();
get_cur_guard() = this;
}
~ObSqlInfoGuard()
{
get_cur_guard() = last_;
}
static ObSqlInfoGuard *&get_cur_guard()
{
static thread_local ObSqlInfoGuard *cur_guard = NULL;
return cur_guard;
}
public:
ObString sql_;
private:
ObSqlInfoGuard *last_;
};
} // namespace common
} // namespace oceanbase

View File

@ -699,6 +699,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);
ObSqlFatalErrExtraInfoGuard extra_info_guard;
extra_info_guard.set_cur_sql(sql);
extra_info_guard.set_tenant_id(session.get_effective_tenant_id());

View File

@ -69,6 +69,7 @@ public:
virtual int execute(sql::ObSql &engine, sql::ObSqlCtx &ctx, sql::ObResultSet &res)
{
int ret = OB_SUCCESS;
common::ObSqlInfoGuard si_guard(sql_);
// 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);
@ -1858,6 +1859,7 @@ int ObInnerSQLConnection::execute_write_inner(const uint64_t tenant_id, const Ob
}
}
if (OB_SUCC(ret)) {
get_session().store_query_string(sql);
ObInnerSQLTransmitArg arg (MYADDR, get_resource_svr(), tenant_id, get_resource_conn_id(),
sql, ObInnerSQLTransmitArg::OPERATION_TYPE_EXECUTE_WRITE,
lib::Worker::CompatMode::ORACLE == get_compat_mode(), GCONF.cluster_id,
@ -2043,6 +2045,7 @@ int ObInnerSQLConnection::execute_read_inner(const int64_t cluster_id,
}
}
if (OB_SUCC(ret)) {
get_session().store_query_string(sql);
ObInnerSQLTransmitArg arg (MYADDR, get_resource_svr(), tenant_id, get_resource_conn_id(),
sql, ObInnerSQLTransmitArg::OPERATION_TYPE_EXECUTE_READ,
lib::Worker::CompatMode::ORACLE == get_compat_mode(), GCONF.cluster_id,

View File

@ -17,6 +17,7 @@
#include "lib/mysqlclient/ob_mysql_result.h"
#include "lib/hash/ob_hashmap.h"
#include "lib/rc/context.h"
#include "lib/signal/ob_signal_struct.h"
#include "share/rc/ob_tenant_base.h"
#include "observer/ob_req_time_service.h"
#include "omt/ob_tenant.h"
@ -136,6 +137,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());
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());
@ -196,11 +198,11 @@ int ObInnerSQLResult::force_close()
column_indexed_ = false;
return ret;
}
int ObInnerSQLResult::inner_close()
{
int ret = OB_SUCCESS;
lib::CompatModeGuard g(compat_mode_);
common::ObSqlInfoGuard si_guard(session_.get_current_query_string());
LOG_DEBUG("compat_mode_", K(ret), K(compat_mode_), K(lbt()));
MAKE_TENANT_SWITCH_SCOPE_GUARD(tenant_guard);
@ -239,6 +241,7 @@ int ObInnerSQLResult::next()
} else {
row_ = NULL;
lib::CompatModeGuard g(compat_mode_);
common::ObSqlInfoGuard si_guard(session_.get_current_query_string());
WITH_CONTEXT(mem_context_) {
if (has_tenant_resource() && OB_FAIL(result_set_->get_next_row(row_))) {
if (OB_ITER_END != ret) {
@ -251,6 +254,7 @@ int ObInnerSQLResult::next()
K(ret), K(remote_result_set_->get_field_columns()->count()));
}
}
}
}
return ret;