[FEAT MERGE]Query Interface Enhancement
Co-authored-by: chinaxing <chen.yack@gmail.com>
This commit is contained in:
@ -50,6 +50,8 @@
|
||||
#include "lib/string/ob_hex_utils_base.h"
|
||||
#include "share/stat/ob_opt_stat_manager.h"
|
||||
#include "sql/plan_cache/ob_ps_cache.h"
|
||||
#include "observer/ob_sql_client_decorator.h"
|
||||
#include "ob_sess_info_verify.h"
|
||||
|
||||
using namespace oceanbase::sql;
|
||||
using namespace oceanbase::common;
|
||||
@ -172,6 +174,7 @@ ObSQLSessionInfo::ObSQLSessionInfo() :
|
||||
got_user_conn_res_(false),
|
||||
conn_res_user_id_(OB_INVALID_ID),
|
||||
mem_context_(nullptr),
|
||||
has_query_executed_(false),
|
||||
cur_exec_ctx_(nullptr),
|
||||
restore_auto_commit_(false),
|
||||
dblink_context_(this),
|
||||
@ -320,6 +323,7 @@ void ObSQLSessionInfo::reset(bool skip_sys_var)
|
||||
cur_exec_ctx_ = nullptr;
|
||||
plan_cache_ = NULL;
|
||||
client_app_info_.reset();
|
||||
has_query_executed_ = false;
|
||||
flt_control_info_.reset();
|
||||
is_send_control_info_ = false;
|
||||
trace_enable_ = false;
|
||||
@ -2222,10 +2226,19 @@ int ObSQLSessionInfo::clear_context(const ObString &context_name,
|
||||
|
||||
void ObSQLSessionInfo::set_flt_control_info(const FLTControlInfo &con_info)
|
||||
{
|
||||
bool support_show_trace = flt_control_info_.support_show_trace_;
|
||||
flt_control_info_ = con_info;
|
||||
flt_control_info_.support_show_trace_ = support_show_trace;
|
||||
control_info_encoder_.is_changed_ = true;
|
||||
}
|
||||
|
||||
void ObSQLSessionInfo::set_flt_control_info_no_sync(const FLTControlInfo &con_info)
|
||||
{
|
||||
bool support_show_trace = flt_control_info_.support_show_trace_;
|
||||
flt_control_info_ = con_info;
|
||||
flt_control_info_.support_show_trace_ = support_show_trace;
|
||||
}
|
||||
|
||||
int ObSQLSessionInfo::set_client_id(const common::ObString &client_identifier)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
@ -2571,6 +2584,7 @@ int ObSQLSessionInfo::set_client_info(const common::ObString &client_info) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int ObSQLSessionInfo::get_sess_encoder(const SessionSyncInfoType sess_sync_info_type, ObSessInfoEncoder* &encoder)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
@ -2667,6 +2681,131 @@ int64_t ObSysVarEncoder::get_serialize_size(ObSQLSessionInfo& sess) const {
|
||||
return len;
|
||||
}
|
||||
|
||||
int ObSysVarEncoder::fetch_sess_info(ObSQLSessionInfo &sess, char *buf, const int64_t length, int64_t &pos)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_FAIL(sess.get_sys_var_cache_inc_data().serialize(buf, length, pos))) {
|
||||
LOG_WARN("failed to serialize", K(length), K(ret));
|
||||
} else if (OB_FAIL(sess.get_sys_var_in_pc_str().serialize(buf, length, pos))) {
|
||||
LOG_WARN("failed to serialize", K(ret), K(length), K(pos));
|
||||
} else {
|
||||
for (int64_t j = 0; OB_SUCC(ret) && j< share::ObSysVarFactory::ALL_SYS_VARS_COUNT; ++j) {
|
||||
if (ObSysVariables::get_sys_var_id(j) == SYS_VAR_SERVER_UUID ||
|
||||
ObSysVariables::get_sys_var_id(j) == SYS_VAR_OB_PROXY_PARTITION_HIT ||
|
||||
ObSysVariables::get_sys_var_id(j) == SYS_VAR_OB_STATEMENT_TRACE_ID) {
|
||||
// no need sync sys var
|
||||
continue;
|
||||
}
|
||||
if (OB_FAIL(sess.get_sys_var(j)->serialize(buf, length, pos))) {
|
||||
LOG_WARN("failed to serialize", K(length), K(ret));
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int64_t ObSysVarEncoder::get_fetch_sess_info_size(ObSQLSessionInfo& sess)
|
||||
{
|
||||
int64_t size = 0;
|
||||
size = sess.get_sys_var_cache_inc_data().get_serialize_size();
|
||||
size += sess.get_sys_var_in_pc_str().get_serialize_size();
|
||||
for (int64_t j = 0; j< share::ObSysVarFactory::ALL_SYS_VARS_COUNT; ++j) {
|
||||
if (ObSysVariables::get_sys_var_id(j) == SYS_VAR_SERVER_UUID ||
|
||||
ObSysVariables::get_sys_var_id(j) == SYS_VAR_OB_PROXY_PARTITION_HIT ||
|
||||
ObSysVariables::get_sys_var_id(j) == SYS_VAR_OB_STATEMENT_TRACE_ID) {
|
||||
// no need sync sys var
|
||||
continue;
|
||||
}
|
||||
size += sess.get_sys_var(j)->get_serialize_size();
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
int ObSysVarEncoder::compare_sess_info(const char* current_sess_buf, int64_t current_sess_length,
|
||||
const char* last_sess_buf, int64_t last_sess_length)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (current_sess_length != last_sess_length) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("fail to compare session info", K(ret), K(current_sess_length), K(last_sess_length),
|
||||
KPHEX(current_sess_buf, current_sess_length), KPHEX(last_sess_buf, last_sess_length));
|
||||
} else if (memcmp(current_sess_buf, last_sess_buf, current_sess_length) == 0) {
|
||||
LOG_TRACE("success to compare session info", K(ret));
|
||||
} else {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("fail to compare buf session info", K(ret),
|
||||
KPHEX(current_sess_buf, current_sess_length), KPHEX(last_sess_buf, last_sess_length));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObSysVarEncoder::display_sess_info(ObSQLSessionInfo &sess, const char* current_sess_buf,
|
||||
int64_t current_sess_length, const char* last_sess_buf, int64_t last_sess_length)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
UNUSED(current_sess_buf);
|
||||
UNUSED(current_sess_length);
|
||||
int64_t pos = 0;
|
||||
const char *buf = last_sess_buf;
|
||||
int64_t data_len = last_sess_length;
|
||||
common::ObArenaAllocator allocator(common::ObModIds::OB_SQL_SESSION,
|
||||
OB_MALLOC_NORMAL_BLOCK_SIZE,
|
||||
sess.get_effective_tenant_id());
|
||||
ObBasicSessionInfo::SysVarsCacheData last_sess_sys_var_cache_data;
|
||||
ObString last_sess_sys_var_in_pc_str;
|
||||
bool is_error = false; // judging the error location
|
||||
if (OB_FAIL(last_sess_sys_var_cache_data.deserialize(buf, data_len, pos))) {
|
||||
LOG_WARN("failed to deserialize", K(ret), K(data_len), K(pos));
|
||||
} else if (OB_FAIL(last_sess_sys_var_in_pc_str.deserialize(buf, data_len, pos))) {
|
||||
LOG_WARN("failed to deserialize", K(ret), K(data_len), K(pos));
|
||||
} else {
|
||||
ObBasicSysVar *last_sess_sys_vars = NULL;
|
||||
for (int64_t j = 0; OB_SUCC(ret) && j< share::ObSysVarFactory::ALL_SYS_VARS_COUNT; ++j) {
|
||||
if (ObSysVariables::get_sys_var_id(j) == SYS_VAR_SERVER_UUID ||
|
||||
ObSysVariables::get_sys_var_id(j) == SYS_VAR_OB_PROXY_PARTITION_HIT ||
|
||||
ObSysVariables::get_sys_var_id(j) == SYS_VAR_OB_STATEMENT_TRACE_ID) {
|
||||
// no need sync sys var
|
||||
continue;
|
||||
}
|
||||
if (OB_FAIL(ObSessInfoVerify::create_tmp_sys_var(sess, ObSysVariables::get_sys_var_id(j),
|
||||
last_sess_sys_vars, allocator))) {
|
||||
LOG_WARN("fail to create sys var", K(ret));
|
||||
} else if (OB_FAIL(last_sess_sys_vars->deserialize(buf, data_len, pos))) {
|
||||
LOG_WARN("failed to deserialize", K(ret), K(data_len), K(pos));
|
||||
} else if (!sess.get_sys_var(j)->get_value().can_compare(
|
||||
last_sess_sys_vars->get_value())) {
|
||||
share::ObTaskController::get().allow_next_syslog();
|
||||
LOG_WARN("failed to verify sys vars", K(j), K(ret),
|
||||
"current_sess_sys_vars", sess.get_sys_var(j)->get_value(),
|
||||
"last_sess_sys_vars", last_sess_sys_vars->get_value());
|
||||
is_error = true;
|
||||
} else if (sess.get_sys_var(j)->get_value() != last_sess_sys_vars->get_value()) {
|
||||
share::ObTaskController::get().allow_next_syslog();
|
||||
LOG_WARN("failed to verify sys vars", K(j), K(ret),
|
||||
"current_sess_sys_vars", sess.get_sys_var(j)->get_value(),
|
||||
"last_sess_sys_vars", last_sess_sys_vars->get_value());
|
||||
is_error = true;
|
||||
} else {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
if (OB_FAIL(ret)) {
|
||||
|
||||
} else if (sess.get_sys_var_in_pc_str() != last_sess_sys_var_in_pc_str) {
|
||||
share::ObTaskController::get().allow_next_syslog();
|
||||
LOG_WARN("failed to verify sys var in pc str", K(ret), "current_sess_sys_var_in_pc_str",
|
||||
sess.get_sys_var_in_pc_str(),
|
||||
"last_sess_sys_var_in_pc_str", last_sess_sys_var_in_pc_str);
|
||||
} else if (!is_error) {
|
||||
share::ObTaskController::get().allow_next_syslog();
|
||||
LOG_WARN("failed to verify sys vars cache inc data", K(ret),
|
||||
"current_sess_sys_var_cache_data", sess.get_sys_var_cache_inc_data(),
|
||||
"last_sess_sys_var_cache_data", last_sess_sys_var_cache_data);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObAppInfoEncoder::serialize(ObSQLSessionInfo &sess, char *buf, const int64_t length, int64_t &pos)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
@ -2706,6 +2845,76 @@ int64_t ObAppInfoEncoder::get_serialize_size(ObSQLSessionInfo& sess) const {
|
||||
return sess.get_client_app_info().get_serialize_size();
|
||||
}
|
||||
|
||||
int ObAppInfoEncoder::fetch_sess_info(ObSQLSessionInfo &sess, char *buf, const int64_t length, int64_t &pos)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_FAIL(serialize(sess, buf, length, pos))) {
|
||||
LOG_WARN("failed to fetch session info.", K(ret), K(pos), K(length));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int64_t ObAppInfoEncoder::get_fetch_sess_info_size(ObSQLSessionInfo& sess)
|
||||
{
|
||||
return get_serialize_size(sess);
|
||||
}
|
||||
|
||||
int ObAppInfoEncoder::compare_sess_info(const char* current_sess_buf, int64_t current_sess_length,
|
||||
const char* last_sess_buf, int64_t last_sess_length)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (current_sess_length != last_sess_length) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("fail to compare session info", K(ret), K(current_sess_length), K(last_sess_length),
|
||||
KPHEX(current_sess_buf, current_sess_length), KPHEX(last_sess_buf, last_sess_length));
|
||||
} else if (memcmp(current_sess_buf, last_sess_buf, current_sess_length) == 0) {
|
||||
LOG_TRACE("success to compare session info", K(ret));
|
||||
} else {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("fail to compare buf session info", K(ret),
|
||||
KPHEX(current_sess_buf, current_sess_length), KPHEX(last_sess_buf, last_sess_length));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObAppInfoEncoder::display_sess_info(ObSQLSessionInfo &sess, const char* current_sess_buf,
|
||||
int64_t current_sess_length, const char* last_sess_buf, int64_t last_sess_length)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int64_t pos = 0;
|
||||
UNUSED(current_sess_buf);
|
||||
UNUSED(current_sess_length);
|
||||
ObSQLSessionInfo::ApplicationInfo last_sess_app_info;
|
||||
if (OB_FAIL(last_sess_app_info.deserialize(last_sess_buf, last_sess_length, pos))) {
|
||||
LOG_WARN("failed to deserialize application info.", K(ret), K(pos), K(last_sess_length));
|
||||
} else if (sess.get_client_info() != last_sess_app_info.client_info_) {
|
||||
share::ObTaskController::get().allow_next_syslog();
|
||||
LOG_WARN("failed to verify client info", K(ret),
|
||||
"current_sess_app_info.client_info_", sess.get_client_info(),
|
||||
"last_sess_app_info.client_info_", last_sess_app_info.client_info_);
|
||||
} else if (sess.get_action_name() != last_sess_app_info.action_name_) {
|
||||
share::ObTaskController::get().allow_next_syslog();
|
||||
LOG_WARN("failed to verify action name", K(ret),
|
||||
"current_sess_app_info.action_name_", sess.get_action_name(),
|
||||
"last_sess_app_info.action_name_", last_sess_app_info.action_name_);
|
||||
} else if (sess.get_module_name() != last_sess_app_info.module_name_) {
|
||||
share::ObTaskController::get().allow_next_syslog();
|
||||
LOG_WARN("failed to verify module name", K(ret),
|
||||
"current_sess_app_info.module_name_", sess.get_module_name(),
|
||||
"last_sess_app_info.module_name_", last_sess_app_info.module_name_);
|
||||
} else {
|
||||
share::ObTaskController::get().allow_next_syslog();
|
||||
LOG_INFO("success to verify app info",
|
||||
"current_sess_app_info client info", sess.get_client_info(),
|
||||
"last_sess_app_info client info", last_sess_app_info.client_info_,
|
||||
"current_sess_app_info action name", sess.get_action_name(),
|
||||
"last_sess_app_info action name", last_sess_app_info.action_name_,
|
||||
"current_sess_app_info module name", sess.get_module_name(),
|
||||
"last_sess_app_info module name", last_sess_app_info.module_name_);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObAppInfoEncoder::set_client_info(ObSQLSessionInfo* sess, const ObString &client_info)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
@ -2770,6 +2979,65 @@ int64_t ObClientIdInfoEncoder::get_serialize_size(ObSQLSessionInfo& sess) const
|
||||
OB_UNIS_ADD_LEN(sess.get_client_identifier());
|
||||
return len;
|
||||
}
|
||||
|
||||
int ObClientIdInfoEncoder::fetch_sess_info(ObSQLSessionInfo &sess, char *buf, const int64_t length, int64_t &pos)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_FAIL(serialize(sess, buf, length, pos))) {
|
||||
LOG_WARN("failed to fetch session info.", K(ret), K(pos), K(length));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int64_t ObClientIdInfoEncoder::get_fetch_sess_info_size(ObSQLSessionInfo& sess)
|
||||
{
|
||||
return get_serialize_size(sess);
|
||||
}
|
||||
|
||||
int ObClientIdInfoEncoder::compare_sess_info(const char* current_sess_buf, int64_t current_sess_length,
|
||||
const char* last_sess_buf, int64_t last_sess_length)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (current_sess_length != last_sess_length) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("fail to compare session info", K(ret), K(current_sess_length), K(last_sess_length),
|
||||
KPHEX(current_sess_buf, current_sess_length), KPHEX(last_sess_buf, last_sess_length));
|
||||
} else if (memcmp(current_sess_buf, last_sess_buf, current_sess_length) == 0) {
|
||||
LOG_TRACE("success to compare session info", K(ret));
|
||||
} else {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("fail to compare buf session info", K(ret),
|
||||
KPHEX(current_sess_buf, current_sess_length), KPHEX(last_sess_buf, last_sess_length));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObClientIdInfoEncoder::display_sess_info(ObSQLSessionInfo &sess, const char* current_sess_buf,
|
||||
int64_t current_sess_length, const char* last_sess_buf, int64_t last_sess_length)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
UNUSED(current_sess_buf);
|
||||
UNUSED(current_sess_length);
|
||||
common::ObString last_sess_client_identifier;
|
||||
const char *buf = last_sess_buf;
|
||||
int64_t pos = 0;
|
||||
int64_t data_len = last_sess_length;
|
||||
LST_DO_CODE(OB_UNIS_DECODE, last_sess_client_identifier);
|
||||
if (sess.get_client_identifier() != last_sess_client_identifier) {
|
||||
share::ObTaskController::get().allow_next_syslog();
|
||||
LOG_WARN("failed to verify client_identifier", K(ret),
|
||||
"current_sess_client_identifier", sess.get_client_identifier(),
|
||||
"last_sess_client_identifier", last_sess_client_identifier);
|
||||
} else {
|
||||
share::ObTaskController::get().allow_next_syslog();
|
||||
LOG_INFO("success to verify clientid info",
|
||||
"current_sess_client_identifier", sess.get_client_identifier(),
|
||||
"last_sess_client_identifier", last_sess_client_identifier);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObAppCtxInfoEncoder::serialize(ObSQLSessionInfo &sess, char *buf, const int64_t buf_len, int64_t &pos)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
@ -2814,6 +3082,88 @@ int64_t ObAppCtxInfoEncoder::get_serialize_size(ObSQLSessionInfo& sess) const
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
int ObAppCtxInfoEncoder::fetch_sess_info(ObSQLSessionInfo &sess, char *buf, const int64_t length, int64_t &pos)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_FAIL(serialize(sess, buf, length, pos))) {
|
||||
LOG_WARN("failed to fetch session info.", K(ret), K(pos), K(length));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int64_t ObAppCtxInfoEncoder::get_fetch_sess_info_size(ObSQLSessionInfo& sess)
|
||||
{
|
||||
return get_serialize_size(sess);
|
||||
}
|
||||
|
||||
int ObAppCtxInfoEncoder::compare_sess_info(const char* current_sess_buf, int64_t current_sess_length,
|
||||
const char* last_sess_buf, int64_t last_sess_length)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (current_sess_length != last_sess_length) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("fail to compare session info", K(ret), K(current_sess_length), K(last_sess_length),
|
||||
KPHEX(current_sess_buf, current_sess_length), KPHEX(last_sess_buf, last_sess_length));
|
||||
} else if (memcmp(current_sess_buf, last_sess_buf, current_sess_length) == 0) {
|
||||
LOG_TRACE("success to compare session info", K(ret));
|
||||
} else {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("fail to compare buf session info", K(ret),
|
||||
KPHEX(current_sess_buf, current_sess_length), KPHEX(last_sess_buf, last_sess_length));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObAppCtxInfoEncoder::display_sess_info(ObSQLSessionInfo &sess, const char* current_sess_buf,
|
||||
int64_t current_sess_length, const char* last_sess_buf, int64_t last_sess_length)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
UNUSED(current_sess_buf);
|
||||
UNUSED(current_sess_length);
|
||||
const char *buf = last_sess_buf;
|
||||
int64_t pos = 0;
|
||||
int64_t data_len = last_sess_length;
|
||||
int64_t map_size = 0;
|
||||
common::ObArenaAllocator allocator(common::ObModIds::OB_SQL_SESSION,
|
||||
OB_MALLOC_NORMAL_BLOCK_SIZE,
|
||||
sess.get_effective_tenant_id());
|
||||
ObContextsMap &map = sess.get_contexts_map();
|
||||
OB_UNIS_DECODE(map_size);
|
||||
if (map_size != sess.get_contexts_map().size()) {
|
||||
LOG_WARN("failed to verify app ctx info", K(ret), "current_map_size", map_size,
|
||||
"last_map_size", sess.get_contexts_map().size());
|
||||
} else {
|
||||
auto it = map.begin();
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < map_size && it != map.end(); ++i, ++it) {
|
||||
ObInnerContextMap *last_inner_map = nullptr;
|
||||
if (OB_ISNULL(last_inner_map = static_cast<ObInnerContextMap *>
|
||||
(allocator.alloc(sizeof(ObInnerContextMap))))) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_WARN("failed to alloc inner context map", K(ret));
|
||||
} else {
|
||||
new (last_inner_map) ObInnerContextMap(allocator);
|
||||
OB_UNIS_DECODE(*last_inner_map);
|
||||
if (*last_inner_map == *it->second) {
|
||||
// do nothing
|
||||
} else {
|
||||
share::ObTaskController::get().allow_next_syslog();
|
||||
LOG_WARN("failed to verify app ctx info", K(ret),
|
||||
"current_inner_map", it->second,
|
||||
"last_inner_map", last_inner_map);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (OB_FAIL(ret)) {
|
||||
} else {
|
||||
LOG_TRACE("success to verify app ctx info", K(ret));
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
OB_DEF_SERIALIZE(ObInnerContextMap)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
@ -2936,6 +3286,85 @@ int64_t ObControlInfoEncoder::get_serialize_size(ObSQLSessionInfo& sess) const
|
||||
return sess.get_control_info().get_serialize_size() + 6 + sizeof(bool);
|
||||
}
|
||||
|
||||
int ObControlInfoEncoder::fetch_sess_info(ObSQLSessionInfo &sess, char *buf, const int64_t length, int64_t &pos)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_FAIL(serialize(sess, buf, length, pos))) {
|
||||
LOG_WARN("failed to fetch session info.", K(ret), K(pos), K(length));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int64_t ObControlInfoEncoder::get_fetch_sess_info_size(ObSQLSessionInfo& sess)
|
||||
{
|
||||
return get_serialize_size(sess);
|
||||
}
|
||||
|
||||
int ObControlInfoEncoder::compare_sess_info(const char* current_sess_buf, int64_t current_sess_length,
|
||||
const char* last_sess_buf, int64_t last_sess_length)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (current_sess_length != last_sess_length) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("fail to compare session info", K(ret), K(current_sess_length), K(last_sess_length),
|
||||
KPHEX(current_sess_buf, current_sess_length), KPHEX(last_sess_buf, last_sess_length));
|
||||
} else if (memcmp(current_sess_buf, last_sess_buf, current_sess_length) == 0) {
|
||||
LOG_TRACE("success to compare session info", K(ret));
|
||||
} else {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("fail to compare buf session info", K(ret),
|
||||
KPHEX(current_sess_buf, current_sess_length), KPHEX(last_sess_buf, last_sess_length));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObControlInfoEncoder::display_sess_info(ObSQLSessionInfo &sess, const char* current_sess_buf,
|
||||
int64_t current_sess_length, const char* last_sess_buf, int64_t last_sess_length)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
UNUSED(current_sess_buf);
|
||||
UNUSED(current_sess_length);
|
||||
const char *buf = last_sess_buf;
|
||||
int64_t pos = 0;
|
||||
int64_t data_len = last_sess_length;
|
||||
FLTControlInfo last_sess_con;
|
||||
FullLinkTraceExtraInfoType extra_type;
|
||||
int32_t v_len = 0;
|
||||
int16_t id = 0;
|
||||
int8_t last_sess_setby_sess = 0;
|
||||
if (OB_FAIL(FLTExtraInfo::resolve_type_and_len(buf, data_len, pos, extra_type, v_len))) {
|
||||
LOG_WARN("failed to resolve type and len", K(data_len), K(pos));
|
||||
} else if (extra_type != FLT_TYPE_CONTROL_INFO) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid extra type", K(extra_type), K(ret));
|
||||
} else if (OB_FAIL(last_sess_con.deserialize(buf, pos+v_len, pos))) {
|
||||
LOG_WARN("failed to resolve control info", K(v_len), K(pos));
|
||||
} else if (OB_FAIL(ObProtoTransUtil::resolve_type_and_len(buf, data_len, pos, id, v_len))) {
|
||||
LOG_WARN("failed to get extra_info", K(ret), KP(buf));
|
||||
} else if (CONINFO_BY_SESS != id) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid id", K(id));
|
||||
} else if (OB_FAIL(ObProtoTransUtil::get_int1(buf, *(const_cast<int64_t *>(&data_len)),
|
||||
pos, static_cast<int64_t>(v_len), last_sess_setby_sess))) {
|
||||
LOG_WARN("failed to resolve set by sess", K(ret));
|
||||
} else {
|
||||
if (sess.is_coninfo_set_by_sess() != last_sess_setby_sess) {
|
||||
LOG_WARN("failed to verify control info", K(ret),
|
||||
"current_coninfo_set_by_sess", sess.is_coninfo_set_by_sess(),
|
||||
"last_coninfo_set_by_sess", last_sess_setby_sess);
|
||||
} else if (sess.get_control_info().is_equal(last_sess_con)) {
|
||||
LOG_INFO("success to verify control info, no need to attention support_show_trace", K(ret),
|
||||
"current_coninfo", sess.get_control_info(),
|
||||
"last_coninfo", last_sess_con);
|
||||
} else {
|
||||
LOG_WARN("failed to verify control info, no need to attention support_show_trace", K(ret),
|
||||
"current_coninfo", sess.get_control_info(),
|
||||
"last_coninfo", last_sess_con);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define SESS_ENCODER_DELEGATE_TO_TXN(CLS, func) \
|
||||
int CLS::serialize(ObSQLSessionInfo &sess, char *buf, const int64_t length, int64_t &pos)\
|
||||
{ \
|
||||
@ -2948,6 +3377,23 @@ int CLS::deserialize(ObSQLSessionInfo &sess, const char *buf, const int64_t leng
|
||||
int64_t CLS::get_serialize_size(ObSQLSessionInfo &sess) const \
|
||||
{ \
|
||||
return ObSqlTransControl::get_txn_##func##_state_serialize_size(sess); \
|
||||
} \
|
||||
int CLS::fetch_sess_info(ObSQLSessionInfo &sess, char *buf, const int64_t data_len, int64_t &pos) \
|
||||
{ \
|
||||
return ObSqlTransControl::fetch_txn_##func##_state(sess, buf, data_len, pos); \
|
||||
} \
|
||||
int64_t CLS::get_fetch_sess_info_size(ObSQLSessionInfo &sess) \
|
||||
{ \
|
||||
return ObSqlTransControl::get_fetch_txn_##func##_state_size(sess); \
|
||||
} \
|
||||
int CLS::compare_sess_info(const char* current_sess_buf, int64_t current_sess_length, const char* last_sess_buf, int64_t last_sess_length) \
|
||||
{ \
|
||||
return ObSqlTransControl::cmp_txn_##func##_state(current_sess_buf, current_sess_length, last_sess_buf, last_sess_length); \
|
||||
} \
|
||||
int CLS::display_sess_info(ObSQLSessionInfo &sess, const char* current_sess_buf, int64_t current_sess_length, const char* last_sess_buf, int64_t last_sess_length) \
|
||||
{ \
|
||||
ObSqlTransControl::display_txn_##func##_state(sess, current_sess_buf, current_sess_length, last_sess_buf, last_sess_length); \
|
||||
return OB_SUCCESS; \
|
||||
}
|
||||
|
||||
SESS_ENCODER_DELEGATE_TO_TXN(ObTxnStaticInfoEncoder, static)
|
||||
|
||||
Reference in New Issue
Block a user