patch 4.0
This commit is contained in:
3
src/sql/monitor/README
Normal file
3
src/sql/monitor/README
Normal file
@ -0,0 +1,3 @@
|
||||
该模块主要用来统计运行时状态信息,用于执行反馈指导优化器的优化方向,也可以精确优化器的统计数据,更精确的进行代价估计;
|
||||
另外一个功能可以评估一个查询语句是否是大查询;
|
||||
详细设计请参见:doc/Oceanbase1.0/SQL/monitor/运行时统计数据管理设计.md
|
||||
1061
src/sql/monitor/full_link_trace/ob_flt_control_info_mgr.cpp
Normal file
1061
src/sql/monitor/full_link_trace/ob_flt_control_info_mgr.cpp
Normal file
File diff suppressed because it is too large
Load Diff
168
src/sql/monitor/full_link_trace/ob_flt_control_info_mgr.h
Normal file
168
src/sql/monitor/full_link_trace/ob_flt_control_info_mgr.h
Normal file
@ -0,0 +1,168 @@
|
||||
/**
|
||||
* Copyright (c) 2021 OceanBase
|
||||
* OceanBase CE is licensed under Mulan PubL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||
* You may obtain a copy of Mulan PubL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PubL v2 for more details.
|
||||
*/
|
||||
|
||||
#ifndef OCEANBASE_SQL_OB_FLT_CONTROL_INFO_MGR_H_
|
||||
#define OCEANBASE_SQL_OB_FLT_CONTROL_INFO_MGR_H_
|
||||
#include "share/ob_define.h"
|
||||
#include "lib/utility/ob_macro_utils.h"
|
||||
#include "lib/oblog/ob_log.h"
|
||||
#include "lib/utility/utility.h"
|
||||
#include "lib/signal/ob_signal_utils.h"
|
||||
#include "sql/engine/ob_exec_context.h"
|
||||
|
||||
|
||||
namespace oceanbase
|
||||
{
|
||||
namespace sql
|
||||
{
|
||||
// for client identfier
|
||||
static const char TYPE_I[] = "type_i";
|
||||
// for mod_act
|
||||
static const char TYPE_MOD_ACT[] = "type_m";
|
||||
// for tenant
|
||||
static const char TYPE_TENANT[] = "type_t";
|
||||
// for control info
|
||||
static const char LEVEL[] = "level";
|
||||
static const char SAM_PCT[] = "sample_pct";
|
||||
static const char REC_POL[] = "record_policy";
|
||||
|
||||
// for record policy
|
||||
static const char RP_ALL[] = "ALL";
|
||||
static const char RP_ONLY_SLOW_QUERY[] = "ONLY_SLOW_QUERY";
|
||||
static const char RP_SAMPLE_AND_SLOW_QUERY[] = "SAMPLE_AND_SLOW_QUERY";
|
||||
|
||||
static const char ID_NAME[] = "identifier_name";
|
||||
static const char MOD_NAME[] = "mod_name";
|
||||
static const char ACT_NAME[] = "action_name";
|
||||
|
||||
class ObIdentifierConInfo {
|
||||
public:
|
||||
ObIdentifierConInfo():
|
||||
identifier_name_(),
|
||||
control_info_() {}
|
||||
ObString identifier_name_;
|
||||
FLTControlInfo control_info_;
|
||||
TO_STRING_KV(K_(identifier_name), K_(control_info));
|
||||
};
|
||||
|
||||
class ObModActConInfo {
|
||||
public:
|
||||
ObModActConInfo():
|
||||
mod_name_(),
|
||||
act_name_(),
|
||||
control_info_() {}
|
||||
ObString mod_name_;
|
||||
ObString act_name_;
|
||||
FLTControlInfo control_info_;
|
||||
TO_STRING_KV(K_(mod_name), K_(act_name), K_(control_info));
|
||||
};
|
||||
|
||||
class ObFLTControlInfoManager {
|
||||
public:
|
||||
ObFLTControlInfoManager(uint64_t t_id) :
|
||||
tenant_id_(t_id),
|
||||
identifier_infos_(),
|
||||
mod_infos_(),
|
||||
tenant_info_()
|
||||
{}
|
||||
int to_json(ObIAllocator &allocator, json::Value *&ret_val);
|
||||
int from_json(ObArenaAllocator &allocator, char *buf, const int64_t buf_len);
|
||||
int from_json_identifier(json::Value *&con_val);
|
||||
int from_json_control_info(FLTControlInfo &control_info, json::Pair* it);
|
||||
int from_json_mod_act(json::Value *&con_val);
|
||||
int set_control_info(sql::ObExecContext &ctx);
|
||||
int to_json_contorl_info(ObIAllocator &allocator, FLTControlInfo ftl_con, json::Value *&ret_val);
|
||||
int to_json_identifier(ObIAllocator &allocator, json::Value *&ret_val);
|
||||
int to_json_mod_act(ObIAllocator &allocator, json::Value *&ret_val);
|
||||
int add_identifier_con_info(sql::ObExecContext &ctx, ObIdentifierConInfo i_coninfo);
|
||||
int remove_identifier_con_info(sql::ObExecContext &ctx, common::ObString client_id);
|
||||
int add_mod_act_con_info(sql::ObExecContext &ctx, ObModActConInfo mod_coninfo);
|
||||
int remove_mod_act_con_info(sql::ObExecContext &ctx, common::ObString mod, common::ObString act);
|
||||
int add_tenant_con_info(sql::ObExecContext &ctx, FLTControlInfo coninfo);
|
||||
int remove_tenant_con_info(sql::ObExecContext &ctx);
|
||||
int find_identifier_con_info(common::ObString client_id, int64_t &idx);
|
||||
int find_mod_act_con_info(common::ObString mod, common::ObString act, int64_t &idx);
|
||||
int init();
|
||||
|
||||
int get_mod_act_con_info(common::ObString mod, common::ObString act, FLTControlInfo &coninfo);
|
||||
int get_client_id_con_info(common::ObString client_id, FLTControlInfo &coninfo);
|
||||
int find_appropriate_con_info(sql::ObSQLSessionInfo &sess);
|
||||
|
||||
bool is_valid_tenant_config() {
|
||||
return tenant_info_.is_valid();
|
||||
}
|
||||
|
||||
void reset_tenant_config() {
|
||||
tenant_info_.reset();
|
||||
}
|
||||
|
||||
FLTControlInfo get_control_info() {
|
||||
return tenant_info_;
|
||||
}
|
||||
|
||||
int apply_control_info();
|
||||
|
||||
private:
|
||||
uint64_t tenant_id_;
|
||||
// identifier trace
|
||||
common::ObSEArray<ObIdentifierConInfo, 1, common::ModulePageAllocator, true> identifier_infos_;
|
||||
// mod act trace
|
||||
common::ObSEArray<ObModActConInfo, 1, common::ModulePageAllocator, true> mod_infos_;
|
||||
// tenant trace
|
||||
FLTControlInfo tenant_info_;
|
||||
// allcator
|
||||
ObArenaAllocator alloc_;
|
||||
};
|
||||
|
||||
struct ObFLTApplyByClientIDOp {
|
||||
public:
|
||||
explicit ObFLTApplyByClientIDOp(uint64_t tenant_id, ObIdentifierConInfo id_con_info)
|
||||
: tenant_id_(tenant_id), id_con_info_(id_con_info) {}
|
||||
bool operator()(sql::ObSQLSessionMgr::Key key, ObSQLSessionInfo *sess_info);
|
||||
|
||||
private:
|
||||
uint64_t tenant_id_;
|
||||
ObIdentifierConInfo id_con_info_;
|
||||
};
|
||||
|
||||
struct ObFLTApplyByModActOp {
|
||||
public:
|
||||
explicit ObFLTApplyByModActOp(uint64_t tenant_id, ObModActConInfo mod_act_info)
|
||||
: tenant_id_(tenant_id), mod_act_info_(mod_act_info) {}
|
||||
bool operator()(sql::ObSQLSessionMgr::Key key, ObSQLSessionInfo *sess_info);
|
||||
|
||||
private:
|
||||
uint64_t tenant_id_;
|
||||
ObModActConInfo mod_act_info_;
|
||||
};
|
||||
|
||||
struct ObFLTApplyByTenantOp {
|
||||
public:
|
||||
explicit ObFLTApplyByTenantOp(uint64_t tenant_id, FLTControlInfo tenant_info)
|
||||
: tenant_id_(tenant_id), tenant_info_(tenant_info) {}
|
||||
bool operator()(sql::ObSQLSessionMgr::Key key, ObSQLSessionInfo *sess_info);
|
||||
|
||||
private:
|
||||
uint64_t tenant_id_;
|
||||
FLTControlInfo tenant_info_;
|
||||
};
|
||||
|
||||
struct ObFLTResetSessOp {
|
||||
public:
|
||||
explicit ObFLTResetSessOp() {}
|
||||
bool operator()(sql::ObSQLSessionMgr::Key key, ObSQLSessionInfo *sess_info);
|
||||
};
|
||||
} // namespace sql
|
||||
} // namespace oceanbase
|
||||
|
||||
|
||||
#endif
|
||||
450
src/sql/monitor/full_link_trace/ob_flt_extra_info.cpp
Normal file
450
src/sql/monitor/full_link_trace/ob_flt_extra_info.cpp
Normal file
@ -0,0 +1,450 @@
|
||||
/**
|
||||
* Copyright (c) 2021 OceanBase
|
||||
* OceanBase CE is licensed under Mulan PubL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||
* You may obtain a copy of Mulan PubL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PubL v2 for more details.
|
||||
*/
|
||||
|
||||
#define USING_LOG_PREFIX LIB_UTIL
|
||||
#include "sql/monitor/full_link_trace/ob_flt_extra_info.h"
|
||||
#include "lib/oblog/ob_log_module.h"
|
||||
#include "share/ob_errno.h"
|
||||
|
||||
using namespace oceanbase;
|
||||
using namespace oceanbase::common;
|
||||
using namespace oceanbase::sql;
|
||||
|
||||
// usage:
|
||||
// ...
|
||||
// if (OB_FAIL(FLTExtraInfo::resolve_type_and_len(buf, len, pos, extra_type, v_len))) {
|
||||
// // error
|
||||
// } else if (extra_type == FLT_CONTROL_INFO) {
|
||||
// FLTControlInfo extra_info;
|
||||
// extra_info.deserialize(buf, v_len, pos);
|
||||
// }
|
||||
int FLTExtraInfo::resolve_type_and_len(const char *buf, const int64_t len,
|
||||
int64_t &pos, FullLinkTraceExtraInfoType &extra_type,
|
||||
int32_t &v_len)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int16_t extra_type_val;
|
||||
if (OB_FAIL(ObProtoTransUtil::resolve_type_and_len(buf, len, pos, extra_type_val, v_len))) {
|
||||
OB_LOG(WARN,"failed to get extra info type", KP(buf), K(len), K(extra_type_val), K(v_len));
|
||||
} else {
|
||||
extra_type = FullLinkTraceExtraInfoType(extra_type_val);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
// extra_info.deserisalize(buf, v_len, pos);
|
||||
int FLTExtraInfo::deserialize(const char *buf, const int64_t len, int64_t &pos)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int64_t buf_end = pos + len;
|
||||
while (OB_SUCC(ret) && pos < len) {
|
||||
int32_t val_len = 0;
|
||||
int16_t extra_id;
|
||||
OB_LOG(TRACE, "deserialize flt extra info", KPHEX(buf+pos, len-pos));
|
||||
if (OB_FAIL(ObProtoTransUtil::resolve_type_and_len(buf, buf_end, pos, extra_id, val_len))) {
|
||||
OB_LOG(WARN,"failed to get extra_info", K(ret), KP(buf));
|
||||
} else if (OB_FAIL(deserialize_field(static_cast<FullLinkTraceExtraInfoId>(extra_id),
|
||||
val_len, buf, buf_end, pos))) {
|
||||
OB_LOG(WARN,"failed to resolve value", K(ret), KP(buf), K(buf_end), K(pos), K(val_len));
|
||||
} else {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
// usage:
|
||||
// FLTControlInfo* control_info;
|
||||
// ....
|
||||
// control_info->serialize(buf, len, pos);
|
||||
//
|
||||
// flt_id, len, value ...
|
||||
int FLTControlInfo::serialize(char *buf, const int64_t len, int64_t &pos)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
// resrver for type and len
|
||||
int64_t org_pos = pos;
|
||||
if (pos + FLT_HEADER_LEN > len) {
|
||||
ret = OB_SIZE_OVERFLOW;
|
||||
OB_LOG(WARN,"buffer size overflow", K(ret), K(pos), K(len));
|
||||
} else {
|
||||
MEMSET(buf+pos, 0x00, len-pos);
|
||||
pos += FLT_HEADER_LEN;
|
||||
}
|
||||
if (OB_FAIL(ret)) {
|
||||
// do nothing
|
||||
} else if (OB_FAIL(ObProtoTransUtil::store_int1(buf, len, pos, level_, FLT_LEVEL))) {
|
||||
OB_LOG(WARN,"failed to store extra info id", K(FLT_LEVEL), K(buf));
|
||||
} else if (OB_FAIL(ObProtoTransUtil::store_double(buf, len, pos,
|
||||
sample_pct_, FLT_SAMPLE_PERCENTAGE))) {
|
||||
OB_LOG(WARN,"failed to store extra info id", K(FLT_SAMPLE_PERCENTAGE), K(buf));
|
||||
} else if (OB_FAIL(ObProtoTransUtil::store_int1(buf, len, pos, rp_, FLT_RECORD_POLICY))) {
|
||||
OB_LOG(WARN,"failed to store extra info id", K(FLT_RECORD_POLICY), K(buf));
|
||||
} else if (OB_FAIL(ObProtoTransUtil::store_double(buf, len, pos,
|
||||
print_sample_pct_, FLT_PRINT_SAMPLE_PCT))) {
|
||||
OB_LOG(WARN,"failed to store extra info id", K(FLT_SAMPLE_PERCENTAGE), K(buf));
|
||||
} else if (OB_FAIL(ObProtoTransUtil::store_int8(buf, len, pos,
|
||||
slow_query_thres_, FLT_SLOW_QUERY_THRES))) {
|
||||
OB_LOG(WARN,"failed to store extra info id", K(FLT_RECORD_POLICY), K(buf));
|
||||
} else {
|
||||
// fill type and len in the head
|
||||
int32_t total_len = pos - org_pos - FLT_HEADER_LEN;
|
||||
if (OB_FAIL(ObProtoTransUtil::store_type_and_len(buf, len, org_pos, type_, total_len))) {
|
||||
OB_LOG(WARN,"failed to store extra info type", K(type_), K(buf));
|
||||
} else {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
int FLTControlInfo::deserialize_field(FullLinkTraceExtraInfoId extra_id, const int64_t v_len,
|
||||
const char *buf, const int64_t len, int64_t &pos)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
// this message is sent by server, and server will not receive this
|
||||
switch(extra_id) {
|
||||
case FLT_LEVEL: {
|
||||
int8_t v = 0;
|
||||
if (OB_FAIL(ObProtoTransUtil::get_int1(buf, len, pos, v_len, v))) {
|
||||
OB_LOG(WARN,"failed to resolve flt level", K(ret));
|
||||
} else {
|
||||
level_ = v;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case FLT_SAMPLE_PERCENTAGE: {
|
||||
double v = 0;
|
||||
if (OB_FAIL(ObProtoTransUtil::get_double(buf, len, pos, v_len, v))) {
|
||||
OB_LOG(WARN,"failed to resolve flt level", K(ret));
|
||||
} else {
|
||||
sample_pct_ = v;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case FLT_RECORD_POLICY: {
|
||||
int8_t v = 0;
|
||||
if (OB_FAIL(ObProtoTransUtil::get_int1(buf, len, pos, v_len, v))) {
|
||||
OB_LOG(WARN,"failed to resolve flt level", K(ret));
|
||||
} else {
|
||||
// do nothing
|
||||
rp_ = static_cast<RecordPolicy>(v);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case FLT_PRINT_SAMPLE_PCT: {
|
||||
double v = 0;
|
||||
if (OB_FAIL(ObProtoTransUtil::get_double(buf, len, pos, v_len, v))) {
|
||||
OB_LOG(WARN,"failed to resolve flt level", K(ret));
|
||||
} else {
|
||||
print_sample_pct_ = v;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case FLT_SLOW_QUERY_THRES: {
|
||||
int64_t v =0;
|
||||
if (OB_FAIL(ObProtoTransUtil::get_int8(buf, len, pos, v_len, v))) {
|
||||
OB_LOG(WARN,"failed to resolve flt level", K(ret));
|
||||
} else {
|
||||
// do nothing
|
||||
slow_query_thres_ = v;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
ret = OB_NOT_SUPPORTED;
|
||||
LOG_USER_ERROR(OB_NOT_SUPPORTED, "this extra info id");
|
||||
OB_LOG(WARN,"invalid extra info id", K(extra_id));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
int FLTControlInfo::get_serialize_size()
|
||||
{
|
||||
return FLT_HEADER_LEN + FLT_HEADER_LEN + sizeof(level_) +
|
||||
FLT_HEADER_LEN + sizeof(sample_pct_) +
|
||||
FLT_HEADER_LEN + sizeof(int8_t) +
|
||||
FLT_HEADER_LEN + sizeof(print_sample_pct_) +
|
||||
FLT_HEADER_LEN + sizeof(slow_query_thres_);
|
||||
}
|
||||
int FLTSpanInfo::serialize(char *buf, const int64_t len, int64_t &pos)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
// resrver for type and len
|
||||
int64_t org_pos = pos;
|
||||
if (pos + FLT_HEADER_LEN > len) {
|
||||
ret = OB_SIZE_OVERFLOW;
|
||||
OB_LOG(WARN,"buffer size overflow", K(ret), K(pos), K(len));
|
||||
} else {
|
||||
MEMSET(buf+pos, 0x00, len-pos);
|
||||
pos += FLT_HEADER_LEN;
|
||||
}
|
||||
if (OB_FAIL(ret)) {
|
||||
// do nothing
|
||||
} else if (OB_FAIL(ObProtoTransUtil::store_int1(buf, len, pos,
|
||||
trace_enable_, FLT_TRACE_ENABLE))) {
|
||||
OB_LOG(WARN,"failed to store extra info id", K(FLT_TRACE_ENABLE), K(buf));
|
||||
} else if (OB_FAIL(ObProtoTransUtil::store_int1(buf, len, pos,
|
||||
force_print_, FLT_FORCE_PRINT))) {
|
||||
OB_LOG(WARN,"failed to store extra info id", K(FLT_FORCE_PRINT), K(buf));
|
||||
} else if (OB_FAIL(ObProtoTransUtil::store_str(buf, len, pos,
|
||||
trace_id_.ptr(), trace_id_.length(), FLT_TRACE_ID))) {
|
||||
OB_LOG(WARN, "failed to store extra info id", K(FLT_TRACE_ID), K(trace_id_), K(buf));
|
||||
} else if (OB_FAIL(ObProtoTransUtil::store_int1(buf, len, pos,
|
||||
ref_type_, FLT_REF_TYPE))) {
|
||||
OB_LOG(WARN,"failed to store extra info id", K(FLT_REF_TYPE), K(buf));
|
||||
} else if (OB_FAIL(ObProtoTransUtil::store_str(buf, len, pos,
|
||||
span_id_.ptr(), span_id_.length(), FLT_SPAN_ID))) {
|
||||
OB_LOG(WARN, "failed to store extra info id", K(FLT_SPAN_ID), K(span_id_), K(buf));
|
||||
} else {
|
||||
// fill type and len in the head
|
||||
int32_t total_len = pos - org_pos - FLT_HEADER_LEN;
|
||||
if (OB_FAIL(ObProtoTransUtil::store_type_and_len(buf, len, org_pos, type_, total_len))) {
|
||||
OB_LOG(WARN,"failed to store extra info type", K(type_), K(buf));
|
||||
} else {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
int FLTSpanInfo::deserialize_field(FullLinkTraceExtraInfoId extra_id, const int64_t v_len,
|
||||
const char *buf, const int64_t len, int64_t &pos)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
switch(extra_id) {
|
||||
case FLT_TRACE_ENABLE: {
|
||||
int8_t v = 0;
|
||||
if (OB_FAIL(ObProtoTransUtil::get_int1(buf, len, pos, v_len, v))) {
|
||||
OB_LOG(WARN,"failed to resolve flt level", K(ret));
|
||||
} else {
|
||||
trace_enable_ = static_cast<bool>(v);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case FLT_FORCE_PRINT: {
|
||||
int8_t v = 0;
|
||||
if (OB_FAIL(ObProtoTransUtil::get_int1(buf, len, pos, v_len, v))) {
|
||||
OB_LOG(WARN,"failed to resolve flt level", K(ret));
|
||||
} else {
|
||||
force_print_ = static_cast<bool>(v);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case FLT_TRACE_ID: {
|
||||
char* ptr = NULL;
|
||||
if (OB_FAIL(ObProtoTransUtil::get_str(buf, len, pos, v_len, ptr))) {
|
||||
OB_LOG(WARN,"failed to resolve flt level", K(ret));
|
||||
} else {
|
||||
// do nothing
|
||||
trace_id_.assign(ptr, v_len);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case FLT_REF_TYPE: {
|
||||
int8_t v = 0;
|
||||
if (OB_FAIL(ObProtoTransUtil::get_int1(buf, len, pos, v_len, v))) {
|
||||
OB_LOG(WARN,"failed to resolve flt level", K(ret));
|
||||
} else {
|
||||
ref_type_ = static_cast<RefType>(v);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case FLT_SPAN_ID: {
|
||||
char* ptr = NULL;
|
||||
if (OB_FAIL(ObProtoTransUtil::get_str(buf, len, pos, v_len, ptr))) {
|
||||
OB_LOG(WARN,"failed to resolve flt level", K(ret));
|
||||
} else {
|
||||
// do nothing
|
||||
span_id_.assign(ptr, v_len);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
ret = OB_NOT_SUPPORTED;
|
||||
LOG_USER_ERROR(OB_NOT_SUPPORTED, "this extra info id");
|
||||
OB_LOG(WARN,"invalid extra info id", K(extra_id));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
int FLTSpanInfo::get_serialize_size()
|
||||
{
|
||||
return FLT_HEADER_LEN + FLT_HEADER_LEN + sizeof(trace_enable_) + FLT_HEADER_LEN + sizeof(force_print_) +
|
||||
FLT_HEADER_LEN + trace_id_.length() + FLT_HEADER_LEN + sizeof(int8_t) + FLT_HEADER_LEN + span_id_.length();
|
||||
}
|
||||
int FLTDrvSpan::serialize(char *buf, const int64_t len, int64_t &pos)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
// this message is written by driver, server will do nothing
|
||||
return ret;
|
||||
}
|
||||
int FLTDrvSpan::deserialize_field(FullLinkTraceExtraInfoId extra_id, const int64_t v_len,
|
||||
const char *buf, const int64_t len, int64_t &pos)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
switch(extra_id) {
|
||||
case FLT_DRV_LOG: {
|
||||
char* ptr;
|
||||
if (OB_FAIL(ObProtoTransUtil::get_str(buf, len, pos, v_len, ptr))) {
|
||||
OB_LOG(WARN,"failed to resolve flt level", K(ret));
|
||||
} else {
|
||||
span_info_.assign(ptr, len);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
ret = OB_NOT_SUPPORTED;
|
||||
LOG_USER_ERROR(OB_NOT_SUPPORTED, "this extra info id");
|
||||
OB_LOG(WARN,"invalid extra info id", K(extra_id));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
int FLTDrvSpan::get_serialize_size()
|
||||
{
|
||||
// this message is written by driver, server will do nothing
|
||||
return 0;
|
||||
}
|
||||
int FLTAppInfo::serialize(char *buf, const int64_t len, int64_t &pos)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
// this message is written by driver, server will do nothing
|
||||
return ret;
|
||||
}
|
||||
int FLTAppInfo::deserialize_field(FullLinkTraceExtraInfoId extra_id, const int64_t v_len,
|
||||
const char *buf, const int64_t len, int64_t &pos)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
switch(extra_id) {
|
||||
case FLT_CLIENT_IDENTIFIER: {
|
||||
char* ptr;
|
||||
if (OB_FAIL(ObProtoTransUtil::get_str(buf, len, pos, v_len, ptr))) {
|
||||
OB_LOG(WARN,"failed to resolve flt level", K(ret));
|
||||
} else {
|
||||
trace_client_identifier_.assign(ptr, v_len);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case FLT_MODULE: {
|
||||
char* ptr;
|
||||
if (OB_FAIL(ObProtoTransUtil::get_str(buf, len, pos, v_len, ptr))) {
|
||||
OB_LOG(WARN,"failed to resolve flt level", K(ret));
|
||||
} else {
|
||||
trace_module_.assign(ptr, v_len);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case FLT_ACTION: {
|
||||
char* ptr;
|
||||
if (OB_FAIL(ObProtoTransUtil::get_str(buf, len, pos, v_len, ptr))) {
|
||||
OB_LOG(WARN,"failed to resolve flt level", K(ret));
|
||||
} else {
|
||||
trace_action_.assign(ptr, v_len);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case FLT_CLIENT_INFO: {
|
||||
char* ptr;
|
||||
if (OB_FAIL(ObProtoTransUtil::get_str(buf, len, pos, v_len, ptr))) {
|
||||
OB_LOG(WARN,"failed to resolve flt level", K(ret));
|
||||
} else {
|
||||
trace_client_info_.assign(ptr, v_len);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
ret = OB_NOT_SUPPORTED;
|
||||
LOG_USER_ERROR(OB_NOT_SUPPORTED, "this extra info id");
|
||||
OB_LOG(WARN,"invalid extra info id", K(extra_id));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
int FLTAppInfo::get_serialize_size()
|
||||
{
|
||||
// this message is written by driver, server will do nothing
|
||||
return 0;
|
||||
}
|
||||
|
||||
int FLTQueryInfo::serialize(char *buf, const int64_t len, int64_t &pos)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
// resrver for type and len
|
||||
int64_t org_pos = pos;
|
||||
if (pos + FLT_HEADER_LEN > len) {
|
||||
ret = OB_SIZE_OVERFLOW;
|
||||
OB_LOG(WARN,"buffer size overflow", K(ret), K(pos), K(len));
|
||||
} else {
|
||||
MEMSET(buf+pos, 0x00, len-pos);
|
||||
pos += FLT_HEADER_LEN;
|
||||
}
|
||||
if (OB_FAIL(ret)) {
|
||||
// do nothing
|
||||
} else if (OB_FAIL(ObProtoTransUtil::store_int8(buf, len, pos,
|
||||
query_start_time_, FLT_QUERY_START_TIMESTAMP))) {
|
||||
OB_LOG(WARN,"failed to store extra info id", K(FLT_QUERY_START_TIMESTAMP), K(buf));
|
||||
} else if (OB_FAIL(ObProtoTransUtil::store_int8(buf, len, pos,
|
||||
query_end_time_, FLT_QUERY_END_TIMESTAMP))) {
|
||||
OB_LOG(WARN,"failed to store extra info id", K(FLT_QUERY_END_TIMESTAMP), K(buf));
|
||||
} else {
|
||||
// fill type and len in the head
|
||||
int32_t total_len = pos - org_pos - FLT_HEADER_LEN;
|
||||
if (OB_FAIL(ObProtoTransUtil::store_type_and_len(buf, len, org_pos, type_, total_len))) {
|
||||
OB_LOG(WARN,"failed to store extra info type", K(type_), K(buf));
|
||||
} else {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int FLTQueryInfo::deserialize_field(FullLinkTraceExtraInfoId extra_id, const int64_t v_len,
|
||||
const char *buf, const int64_t len, int64_t &pos)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
// this message is written by server, server will do nothing
|
||||
|
||||
switch(extra_id) {
|
||||
case FLT_QUERY_START_TIMESTAMP: {
|
||||
int64_t v = 0;
|
||||
if (OB_FAIL(ObProtoTransUtil::get_int8(buf, len, pos, v_len, v))) {
|
||||
OB_LOG(WARN,"failed to resolve flt level", K(ret));
|
||||
} else {
|
||||
query_start_time_ = v;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case FLT_QUERY_END_TIMESTAMP: {
|
||||
int64_t v = 0;
|
||||
if (OB_FAIL(ObProtoTransUtil::get_int8(buf, len, pos, v_len, v))) {
|
||||
OB_LOG(WARN,"failed to resolve flt level", K(ret));
|
||||
} else {
|
||||
query_end_time_ = v;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
ret = OB_NOT_SUPPORTED;
|
||||
LOG_USER_ERROR(OB_NOT_SUPPORTED, "this extra info id");
|
||||
OB_LOG(WARN,"invalid extra info id", K(extra_id));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int FLTQueryInfo::get_serialize_size()
|
||||
{
|
||||
return FLT_HEADER_LEN + FLT_HEADER_LEN + sizeof(int64_t) + FLT_HEADER_LEN + sizeof(int64_t);
|
||||
}
|
||||
|
||||
295
src/sql/monitor/full_link_trace/ob_flt_extra_info.h
Normal file
295
src/sql/monitor/full_link_trace/ob_flt_extra_info.h
Normal file
@ -0,0 +1,295 @@
|
||||
/**
|
||||
* Copyright (c) 2021 OceanBase
|
||||
* OceanBase CE is licensed under Mulan PubL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||
* You may obtain a copy of Mulan PubL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PubL v2 for more details.
|
||||
*/
|
||||
|
||||
#ifdef FLT_EXTRA_INFO_DEF
|
||||
// here to add driver's id
|
||||
//FLT_TYPE_DRV_LOG
|
||||
//logs from driver
|
||||
FLT_EXTRA_INFO_DEF(FLT_DRV_LOG, 1, EMySQLFieldType::MYSQL_TYPE_VAR_STRING)
|
||||
FLT_EXTRA_INFO_DEF(FLT_DRIVER_END, 1000, EMySQLFieldType::MYSQL_TYPE_NOT_DEFINED)
|
||||
// here to add proxy's id
|
||||
FLT_EXTRA_INFO_DEF(FLT_PROXY_END, 2000, EMySQLFieldType::MYSQL_TYPE_NOT_DEFINED)
|
||||
//APP_INFO
|
||||
FLT_EXTRA_INFO_DEF(FLT_CLIENT_IDENTIFIER, 2001, EMySQLFieldType::MYSQL_TYPE_VAR_STRING)
|
||||
FLT_EXTRA_INFO_DEF(FLT_MODULE, 2002, EMySQLFieldType::MYSQL_TYPE_VAR_STRING)
|
||||
FLT_EXTRA_INFO_DEF(FLT_ACTION, 2003, EMySQLFieldType::MYSQL_TYPE_VAR_STRING)
|
||||
FLT_EXTRA_INFO_DEF(FLT_CLIENT_INFO, 2004, EMySQLFieldType::MYSQL_TYPE_VAR_STRING)
|
||||
|
||||
// QUERY_INFO
|
||||
FLT_EXTRA_INFO_DEF(FLT_QUERY_START_TIMESTAMP, 2010, EMySQLFieldType::MYSQL_TYPE_LONGLONG)
|
||||
FLT_EXTRA_INFO_DEF(FLT_QUERY_END_TIMESTAMP, 2011, EMySQLFieldType::MYSQL_TYPE_LONGLONG)
|
||||
|
||||
// CONTROL_INFO
|
||||
FLT_EXTRA_INFO_DEF(FLT_LEVEL, 2020, EMySQLFieldType::MYSQL_TYPE_TINY)
|
||||
FLT_EXTRA_INFO_DEF(FLT_SAMPLE_PERCENTAGE, 2021, EMySQLFieldType::MYSQL_TYPE_DOUBLE)
|
||||
FLT_EXTRA_INFO_DEF(FLT_RECORD_POLICY, 2022, EMySQLFieldType::MYSQL_TYPE_TINY)
|
||||
FLT_EXTRA_INFO_DEF(FLT_PRINT_SAMPLE_PCT, 2023, EMySQLFieldType::MYSQL_TYPE_DOUBLE)
|
||||
FLT_EXTRA_INFO_DEF(FLT_SLOW_QUERY_THRES, 2024, EMySQLFieldType::MYSQL_TYPE_LONGLONG)
|
||||
|
||||
// SPAN_INFO
|
||||
FLT_EXTRA_INFO_DEF(FLT_TRACE_ENABLE, 2030, EMySQLFieldType::MYSQL_TYPE_TINY)
|
||||
FLT_EXTRA_INFO_DEF(FLT_FORCE_PRINT, 2031, EMySQLFieldType::MYSQL_TYPE_TINY)
|
||||
FLT_EXTRA_INFO_DEF(FLT_TRACE_ID, 2032, EMySQLFieldType::MYSQL_TYPE_VAR_STRING)
|
||||
FLT_EXTRA_INFO_DEF(FLT_REF_TYPE, 2033, EMySQLFieldType::MYSQL_TYPE_TINY)
|
||||
FLT_EXTRA_INFO_DEF(FLT_SPAN_ID, 2034, EMySQLFieldType::MYSQL_TYPE_VAR_STRING)
|
||||
|
||||
FLT_EXTRA_INFO_DEF(FLT_EXTRA_INFO_END, 65535, EMySQLFieldType::MYSQL_TYPE_NOT_DEFINED)
|
||||
#endif /* FLT_EXTRA_INFO_DEF */
|
||||
|
||||
#ifndef __OB_FLT_EXTRA_INFO_H__
|
||||
#define __OB_FLT_EXTRA_INFO_H__
|
||||
#include "rpc/obmysql/ob_mysql_global.h"
|
||||
#include "lib/utility/ob_proto_trans_util.h"
|
||||
#include "common/object/ob_object.h"
|
||||
namespace oceanbase {
|
||||
namespace sql {
|
||||
|
||||
using namespace obmysql;
|
||||
|
||||
enum FullLinkTraceExtraInfoId
|
||||
{
|
||||
#define FLT_EXTRA_INFO_DEF(extra_id, id, type) extra_id = id,
|
||||
#include "sql/monitor/full_link_trace/ob_flt_extra_info.h"
|
||||
#undef FLT_EXTRA_INFO_DEF
|
||||
};
|
||||
|
||||
enum FullLinkTraceExtraInfoType
|
||||
{
|
||||
// for driver private
|
||||
FLT_TYPE_DRV_LOG = 1,
|
||||
FLT_TYPE_DRV_END = 1000,
|
||||
|
||||
// for proxy private
|
||||
FLT_TYPE_PROXY_END = 2000,
|
||||
|
||||
// for public
|
||||
FLT_TYPE_APP_INFO = 2001,
|
||||
FLT_TYPE_QUERY_INFO = 2002,
|
||||
FLT_TYPE_CONTROL_INFO = 2003,
|
||||
FLT_TYPE_SPAN_INFO = 2004,
|
||||
FLT_EXTRA_TYPE_END = 65535
|
||||
};
|
||||
|
||||
|
||||
class FullLinkTraceExtraInfoSet
|
||||
{
|
||||
public:
|
||||
FullLinkTraceExtraInfoSet()
|
||||
{
|
||||
#define FLT_EXTRA_INFO_DEF(extra_id, id, type) set_flt_extra_info(extra_id, type);
|
||||
#include "sql/monitor/full_link_trace/ob_flt_extra_info.h"
|
||||
#undef FLT_EXTRA_INFO_DEF
|
||||
};
|
||||
|
||||
EMySQLFieldType get_type(FullLinkTraceExtraInfoId id);
|
||||
private:
|
||||
void set_flt_extra_info(FullLinkTraceExtraInfoId id, EMySQLFieldType type)
|
||||
{
|
||||
types[id] = type;
|
||||
}
|
||||
private:
|
||||
EMySQLFieldType types[FLT_EXTRA_INFO_END];
|
||||
static FullLinkTraceExtraInfoSet FLT_EXTRA_INFO_SET;
|
||||
|
||||
static EMySQLFieldType get_flt_extra_info_type(FullLinkTraceExtraInfoId id)
|
||||
{
|
||||
return FLT_EXTRA_INFO_SET.get_type(id);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
class FLTExtraInfo
|
||||
{
|
||||
public:
|
||||
FullLinkTraceExtraInfoType type_;
|
||||
FLTExtraInfo() : type_(FLT_EXTRA_TYPE_END) {}
|
||||
~FLTExtraInfo() {}
|
||||
virtual int serialize(char *buf, const int64_t len, int64_t &pos) = 0;
|
||||
virtual int deserialize_field(FullLinkTraceExtraInfoId extra_id,
|
||||
const int64_t v_len, const char *buf,
|
||||
const int64_t len, int64_t &pos) = 0;
|
||||
int deserialize(const char *buf, const int64_t len, int64_t &pos);
|
||||
virtual int get_serialize_size() = 0;
|
||||
static int resolve_type_and_len(const char *buf, const int64_t len,
|
||||
int64_t &pos, FullLinkTraceExtraInfoType &extra_type,
|
||||
int32_t &v_len);
|
||||
bool is_app_info() { return type_ == FLT_TYPE_APP_INFO; }
|
||||
bool is_query_info() { return type_ == FLT_TYPE_QUERY_INFO; }
|
||||
bool is_control_info() { return type_ == FLT_TYPE_CONTROL_INFO; }
|
||||
bool is_span_info() { return type_ == FLT_TYPE_SPAN_INFO; }
|
||||
static const int16_t FLT_TYPE_LEN = 2;
|
||||
static const int16_t FLT_LENGTH_LEN = 4;
|
||||
static const int16_t FLT_HEADER_LEN = FLT_TYPE_LEN + FLT_LENGTH_LEN;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class FLTControlInfo : public FLTExtraInfo
|
||||
{
|
||||
public:
|
||||
enum RecordPolicy {
|
||||
RP_ALL = 1,
|
||||
RP_ONLY_SLOW_QUERY = 2,
|
||||
RP_SAMPLE_AND_SLOW_QUERY = 3,
|
||||
MAX_RECORD_POLICY = 4
|
||||
};
|
||||
// control info
|
||||
int8_t level_;
|
||||
double sample_pct_;
|
||||
RecordPolicy rp_;
|
||||
double print_sample_pct_;
|
||||
int64_t slow_query_thres_;
|
||||
|
||||
FLTControlInfo() : level_(-1),
|
||||
sample_pct_(-1),
|
||||
rp_(MAX_RECORD_POLICY),
|
||||
print_sample_pct_(-1),
|
||||
slow_query_thres_(-1) {
|
||||
type_ = FLT_TYPE_CONTROL_INFO;
|
||||
}
|
||||
~FLTControlInfo() {}
|
||||
|
||||
bool is_valid() {
|
||||
return level_ > 0 && sample_pct_>=0 && sample_pct_<=1 && rp_>0 && rp_<MAX_RECORD_POLICY;
|
||||
}
|
||||
bool is_valid() const {
|
||||
return level_ > 0 && sample_pct_>=0 && sample_pct_<=1 && rp_>0 && rp_<MAX_RECORD_POLICY;
|
||||
}
|
||||
bool is_valid_sys_config() {
|
||||
return print_sample_pct_ >= 0 && print_sample_pct_ <= 1 && slow_query_thres_ > 0;
|
||||
}
|
||||
void reset() {
|
||||
level_ = -1;
|
||||
sample_pct_ = -1;
|
||||
rp_ = MAX_RECORD_POLICY;
|
||||
print_sample_pct_ = -1;
|
||||
slow_query_thres_ = -1;
|
||||
}
|
||||
|
||||
inline bool operator==(const FLTControlInfo &other) const {
|
||||
return level_ == other.level_ &&
|
||||
sample_pct_ == other.sample_pct_ &&
|
||||
rp_ == other.rp_;
|
||||
}
|
||||
// flt_id, len, value ...
|
||||
int serialize(char *buf, const int64_t len, int64_t &pos);
|
||||
int deserialize_field(FullLinkTraceExtraInfoId extra_id,
|
||||
const int64_t v_len, const char *buf,
|
||||
const int64_t len, int64_t &pos);
|
||||
int get_serialize_size();
|
||||
TO_STRING_KV(K_(level), K_(sample_pct), K_(rp), K_(print_sample_pct), K_(slow_query_thres));
|
||||
};
|
||||
|
||||
class FLTSpanInfo : public FLTExtraInfo
|
||||
{
|
||||
public:
|
||||
enum RefType {
|
||||
SYNC,
|
||||
ASYNC,
|
||||
MAX_REF_TYPE
|
||||
};
|
||||
bool trace_enable_;
|
||||
bool force_print_;
|
||||
ObString trace_id_;
|
||||
// 0-sync, 1-async
|
||||
RefType ref_type_;
|
||||
ObString span_id_;
|
||||
|
||||
FLTSpanInfo() : trace_enable_(false),
|
||||
force_print_(false),
|
||||
trace_id_(),
|
||||
ref_type_(MAX_REF_TYPE),
|
||||
span_id_() {
|
||||
type_ = FLT_TYPE_SPAN_INFO;
|
||||
}
|
||||
~FLTSpanInfo() {}
|
||||
|
||||
// flt_id, len, value ...
|
||||
int serialize(char *buf, const int64_t len, int64_t &pos);
|
||||
int deserialize_field(FullLinkTraceExtraInfoId extra_id,
|
||||
const int64_t v_len, const char *buf,
|
||||
const int64_t len, int64_t &pos);
|
||||
int get_serialize_size();
|
||||
TO_STRING_KV(K_(trace_enable), K_(force_print), K_(trace_id), K_(ref_type), K_(span_id));
|
||||
};
|
||||
|
||||
class FLTDrvSpan : public FLTExtraInfo
|
||||
{
|
||||
public:
|
||||
ObString span_info_;
|
||||
|
||||
FLTDrvSpan() : span_info_() {
|
||||
type_ = FLT_TYPE_DRV_LOG;
|
||||
}
|
||||
~FLTDrvSpan() {}
|
||||
|
||||
// flt_id, len, value ...
|
||||
int serialize(char *buf, const int64_t len, int64_t &pos);
|
||||
int deserialize_field(FullLinkTraceExtraInfoId extra_id,
|
||||
const int64_t v_len, const char *buf,
|
||||
const int64_t len, int64_t &pos);
|
||||
int get_serialize_size();
|
||||
TO_STRING_KV(K_(span_info));
|
||||
};
|
||||
|
||||
class FLTAppInfo : public FLTExtraInfo
|
||||
{
|
||||
public:
|
||||
ObString trace_client_identifier_;
|
||||
ObString trace_module_;
|
||||
ObString trace_action_;
|
||||
ObString trace_client_info_;
|
||||
|
||||
FLTAppInfo() : trace_client_identifier_(),
|
||||
trace_module_(),
|
||||
trace_action_(),
|
||||
trace_client_info_() {
|
||||
type_ = FLT_TYPE_APP_INFO;
|
||||
}
|
||||
~FLTAppInfo() {}
|
||||
|
||||
// flt_id, len, value ...
|
||||
int serialize(char *buf, const int64_t len, int64_t &pos);
|
||||
int deserialize_field(FullLinkTraceExtraInfoId extra_id,
|
||||
const int64_t v_len, const char *buf,
|
||||
const int64_t len, int64_t &pos);
|
||||
int get_serialize_size();
|
||||
TO_STRING_KV(K_(trace_client_identifier), K_(trace_module),
|
||||
K_(trace_action), K_(trace_client_info));
|
||||
};
|
||||
|
||||
class FLTQueryInfo : public FLTExtraInfo
|
||||
{
|
||||
public:
|
||||
int64_t query_start_time_;
|
||||
int64_t query_end_time_;
|
||||
|
||||
FLTQueryInfo() : query_start_time_(0),
|
||||
query_end_time_(0) {
|
||||
type_ = FLT_TYPE_QUERY_INFO;
|
||||
}
|
||||
~FLTQueryInfo() {}
|
||||
|
||||
// flt_id, len, value ...
|
||||
int serialize(char *buf, const int64_t len, int64_t &pos);
|
||||
int deserialize_field(FullLinkTraceExtraInfoId extra_id,
|
||||
const int64_t v_len, const char *buf,
|
||||
const int64_t len, int64_t &pos);
|
||||
int get_serialize_size();
|
||||
TO_STRING_KV(K_(query_start_time), K_(query_end_time));
|
||||
};
|
||||
|
||||
}; // end of namespace lib
|
||||
}; // end of namespace oceanbase
|
||||
|
||||
#endif /*__OB_FLT_EXTRA_INFO_H__*/
|
||||
305
src/sql/monitor/ob_audit_action_type.h
Normal file
305
src/sql/monitor/ob_audit_action_type.h
Normal file
@ -0,0 +1,305 @@
|
||||
/**
|
||||
* Copyright (c) 2021 OceanBase
|
||||
* OceanBase CE is licensed under Mulan PubL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||
* You may obtain a copy of Mulan PubL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PubL v2 for more details.
|
||||
*/
|
||||
|
||||
#ifdef OB_AUDIT_ACTION_TYPE_DEF
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_UNKNOWN, 0, "UNKNOWN")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_TABLE, 1, "CREATE TABLE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_INSERT, 2, "INSERT")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_SELECT, 3, "SELECT")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_CLUSTER, 4, "CREATE CLUSTER")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ALTER_CLUSTER, 5, "ALTER CLUSTER")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_UPDATE, 6, "UPDATE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DELETE, 7, "DELETE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DROP_CLUSTER, 8, "DROP CLUSTER")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_INDEX, 9, "CREATE INDEX")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DROP_INDEX, 10, "DROP INDEX")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ALTER_INDEX, 11, "ALTER INDEX")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DROP_TABLE, 12, "DROP TABLE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_SEQUENCE, 13, "CREATE SEQUENCE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ALTER_SEQUENCE, 14, "ALTER SEQUENCE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ALTER_TABLE, 15, "ALTER TABLE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DROP_SEQUENCE, 16, "DROP SEQUENCE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_GRANT_OBJECT, 17, "GRANT OBJECT")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_REVOKE_OBJECT, 18, "REVOKE OBJECT")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_SYNONYM, 19, "CREATE SYNONYM")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DROP_SYNONYM, 20, "DROP SYNONYM")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_VIEW, 21, "CREATE VIEW")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DROP_VIEW, 22, "DROP VIEW")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_VALIDATE_INDEX, 23, "VALIDATE INDEX")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_PROCEDURE, 24, "CREATE PROCEDURE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ALTER_PROCEDURE, 25, "ALTER PROCEDURE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_LOCK, 26, "LOCK")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_NO_OP, 27, "NO-OP")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_RENAME, 28, "RENAME")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_COMMENT, 29, "COMMENT")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_AUDIT_OBJECT, 30, "AUDIT OBJECT")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_NOAUDIT_OBJECT, 31, "NOAUDIT OBJECT")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_DATABASE_LINK, 32, "CREATE DATABASE LINK")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DROP_DATABASE_LINK, 33, "DROP DATABASE LINK")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_DATABASE, 34, "CREATE DATABASE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ALTER_DATABASE, 35, "ALTER DATABASE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_ROLLBACK_SEG, 36, "CREATE ROLLBACK SEG")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ALTER_ROLLBACK_SEG, 37, "ALTER ROLLBACK SEG")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DROP_ROLLBACK_SEG, 38, "DROP ROLLBACK SEG")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_TABLESPACE, 39, "CREATE TABLESPACE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ALTER_TABLESPACE, 40, "ALTER TABLESPACE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DROP_TABLESPACE, 41, "DROP TABLESPACE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ALTER_SESSION, 42, "ALTER SESSION")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ALTER_USER, 43, "ALTER USER")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_COMMIT, 44, "COMMIT")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ROLLBACK, 45, "ROLLBACK")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_SAVEPOINT, 46, "SAVEPOINT")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_PL_SQL_EXECUTE, 47, "PL/SQL_EXECUTE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_SET_TRANSACTION, 48, "SET TRANSACTION")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ALTER_SYSTEM, 49, "ALTER SYSTEM")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_EXPLAIN, 50, "EXPLAIN")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_USER, 51, "CREATE USER")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_ROLE, 52, "CREATE ROLE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DROP_USER, 53, "DROP USER")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DROP_ROLE, 54, "DROP ROLE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_SET_ROLE, 55, "SET ROLE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_SCHEMA, 56, "CREATE SCHEMA")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_CONTROL_FILE, 57, "CREATE CONTROL FILE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ALTER_TRACING, 58, "ALTER TRACING")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_TRIGGER, 59, "CREATE TRIGGER")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ALTER_TRIGGER, 60, "ALTER TRIGGER")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DROP_TRIGGER, 61, "DROP TRIGGER")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ANALYZE_TABLE, 62, "ANALYZE TABLE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ANALYZE_INDEX, 63, "ANALYZE INDEX")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ANALYZE_CLUSTER, 64, "ANALYZE CLUSTER")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_PROFILE, 65, "CREATE PROFILE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DROP_PROFILE, 66, "DROP PROFILE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ALTER_PROFILE, 67, "ALTER PROFILE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DROP_PROCEDURE, 68, "DROP PROCEDURE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ALTER_RESOURCE_COST, 70, "ALTER RESOURCE COST")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_MATERIALIZED_VIEW_LOG, 71, "CREATE MATERIALIZED VIEW LOG")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ALTER_MATERIALIZED_VIEW_LOG, 72, "ALTER MATERIALIZED VIEW LOG")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DROP_MATERIALIZED_VIEW_LOG, 73, "DROP MATERIALIZED VIEW LOG")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_MATERIALIZED_VIEW, 74, "CREATE MATERIALIZED VIEW")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ALTER_MATERIALIZED_VIEW, 75, "ALTER MATERIALIZED VIEW")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DROP_MATERIALIZED_VIEW, 76, "DROP MATERIALIZED VIEW")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_TYPE, 77, "CREATE TYPE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DROP_TYPE, 78, "DROP TYPE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ALTER_ROLE, 79, "ALTER ROLE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ALTER_TYPE, 80, "ALTER TYPE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_TYPE_BODY, 81, "CREATE TYPE BODY")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ALTER_TYPE_BODY, 82, "ALTER TYPE BODY")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DROP_TYPE_BODY, 83, "DROP TYPE BODY")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DROP_LIBRARY, 84, "DROP LIBRARY")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_TRUNCATE_TABLE, 85, "TRUNCATE TABLE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_TRUNCATE_CLUSTER, 86, "TRUNCATE CLUSTER")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ALTER_VIEW, 88, "ALTER VIEW")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_SET_CONSTRAINTS, 90, "SET CONSTRAINTS")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_FUNCTION, 91, "CREATE FUNCTION")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ALTER_FUNCTION, 92, "ALTER FUNCTION")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DROP_FUNCTION, 93, "DROP FUNCTION")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_PACKAGE, 94, "CREATE PACKAGE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ALTER_PACKAGE, 95, "ALTER PACKAGE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DROP_PACKAGE, 96, "DROP PACKAGE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_PACKAGE_BODY, 97, "CREATE PACKAGE BODY")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ALTER_PACKAGE_BODY, 98, "ALTER PACKAGE BODY")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DROP_PACKAGE_BODY, 99, "DROP PACKAGE BODY")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_LOGON, 100, "LOGON")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_LOGOFF, 101, "LOGOFF")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_LOGOFF_BY_CLEANUP, 102, "LOGOFF BY CLEANUP")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_SESSION_REC, 103, "SESSION REC")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_SYSTEM_AUDIT, 104, "SYSTEM AUDIT")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_SYSTEM_NOAUDIT, 105, "SYSTEM NOAUDIT")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_AUDIT_DEFAULT, 106, "AUDIT DEFAULT")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_NOAUDIT_DEFAULT, 107, "NOAUDIT DEFAULT")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_SYSTEM_GRANT, 108, "SYSTEM GRANT")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_SYSTEM_REVOKE, 109, "SYSTEM REVOKE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_PUBLIC_SYNONYM, 110, "CREATE PUBLIC SYNONYM")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DROP_PUBLIC_SYNONYM, 111, "DROP PUBLIC SYNONYM")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_PUBLIC_DATABASE_LINK, 112, "CREATE PUBLIC DATABASE LINK")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DROP_PUBLIC_DATABASE_LINK, 113, "DROP PUBLIC DATABASE LINK")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_GRANT_ROLE, 114, "GRANT ROLE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_REVOKE_ROLE, 115, "REVOKE ROLE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_EXECUTE_PROCEDURE, 116, "EXECUTE PROCEDURE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_USER_COMMENT, 117, "USER COMMENT")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ENABLE_TRIGGER, 118, "ENABLE TRIGGER")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DISABLE_TRIGGER, 119, "DISABLE TRIGGER")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ENABLE_ALL_TRIGGERS, 120, "ENABLE ALL TRIGGERS")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DISABLE_ALL_TRIGGERS, 121, "DISABLE ALL TRIGGERS")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_NETWORK_ERROR, 122, "NETWORK ERROR")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_EXECUTE_TYPE, 123, "EXECUTE TYPE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_READ_DIRECTORY, 125, "READ DIRECTORY")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_WRITE_DIRECTORY, 126, "WRITE DIRECTORY")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_FLASHBACK, 128, "FLASHBACK")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_BECOME_USER, 129, "BECOME USER")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ALTER_MINING_MODEL, 130, "ALTER MINING MODEL")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_SELECT_MINING_MODEL, 131, "SELECT MINING MODEL")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_MINING_MODEL, 133, "CREATE MINING MODEL")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ALTER_PUBLIC_SYNONYM, 134, "ALTER PUBLIC SYNONYM")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_EXECUTE_DIRECTORY, 135, "EXECUTE DIRECTORY")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_SQL_LOADER_DIRECT_PATH_LOAD, 136, "SQL*LOADER DIRECT PATH LOAD")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DATAPUMP_DIRECT_PATH_UNLOAD, 137, "DATAPUMP DIRECT PATH UNLOAD")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DATABASE_STARTUP, 138, "DATABASE STARTUP")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DATABASE_SHUTDOWN, 139, "DATABASE SHUTDOWN")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_SQL_TXLN_PROFILE, 140, "CREATE SQL TXLN PROFILE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ALTER_SQL_TXLN_PROFILE, 141, "ALTER SQL TXLN PROFILE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_USE_SQL_TXLN_PROFILE, 142, "USE SQL TXLN PROFILE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DROP_SQL_TXLN_PROFILE, 143, "DROP SQL TXLN PROFILE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_MEASURE_FOLDER, 144, "CREATE MEASURE FOLDER")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ALTER_MEASURE_FOLDER, 145, "ALTER MEASURE FOLDER")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DROP_MEASURE_FOLDER, 146, "DROP MEASURE FOLDER")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_CUBE_BUILD_PROCESS, 147, "CREATE CUBE BUILD PROCESS")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ALTER_CUBE_BUILD_PROCESS, 148, "ALTER CUBE BUILD PROCESS")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DROP_CUBE_BUILD_PROCESS, 149, "DROP CUBE BUILD PROCESS")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_CUBE, 150, "CREATE CUBE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ALTER_CUBE, 151, "ALTER CUBE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DROP_CUBE, 152, "DROP CUBE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_CUBE_DIMENSION, 153, "CREATE CUBE DIMENSION")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ALTER_CUBE_DIMENSION, 154, "ALTER CUBE DIMENSION")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DROP_CUBE_DIMENSION, 155, "DROP CUBE DIMENSION")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_DIRECTORY, 157, "CREATE DIRECTORY")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DROP_DIRECTORY, 158, "DROP DIRECTORY")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_LIBRARY, 159, "CREATE LIBRARY")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_JAVA, 160, "CREATE JAVA")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ALTER_JAVA, 161, "ALTER JAVA")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DROP_JAVA, 162, "DROP JAVA")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_OPERATOR, 163, "CREATE OPERATOR")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_INDEXTYPE, 164, "CREATE INDEXTYPE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DROP_INDEXTYPE, 165, "DROP INDEXTYPE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ALTER_INDEXTYPE, 166, "ALTER INDEXTYPE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DROP_OPERATOR, 167, "DROP OPERATOR")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ASSOCIATE_STATISTICS, 168, "ASSOCIATE STATISTICS")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DISASSOCIATE_STATISTICS, 169, "DISASSOCIATE STATISTICS")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CALL_METHOD, 170, "CALL METHOD")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_SUMMARY, 171, "CREATE SUMMARY")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ALTER_SUMMARY, 172, "ALTER SUMMARY")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DROP_SUMMARY, 173, "DROP SUMMARY")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_DIMENSION, 174, "CREATE DIMENSION")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ALTER_DIMENSION, 175, "ALTER DIMENSION")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DROP_DIMENSION, 176, "DROP DIMENSION")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_CONTEXT, 177, "CREATE CONTEXT")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DROP_CONTEXT, 178, "DROP CONTEXT")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ALTER_OUTLINE, 179, "ALTER OUTLINE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_OUTLINE, 180, "CREATE OUTLINE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DROP_OUTLINE, 181, "DROP OUTLINE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_UPDATE_INDEXES, 182, "UPDATE INDEXES")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ALTER_OPERATOR, 183, "ALTER OPERATOR")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_SPFILE, 187, "CREATE SPFILE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_PFILE, 188, "CREATE PFILE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_MERGE, 189, "MERGE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_PASSWORD_CHANGE, 190, "PASSWORD CHANGE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ALTER_SYNONYM, 192, "ALTER SYNONYM")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ALTER_DISKGROUP, 193, "ALTER DISKGROUP")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_DISKGROUP, 194, "CREATE DISKGROUP")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DROP_DISKGROUP, 195, "DROP DISKGROUP")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_PURGE_USER_RECYCLEBIN, 197, "PURGE USER_RECYCLEBIN")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_PURGE_DBA_RECYCLEBIN, 198, "PURGE DBA_RECYCLEBIN")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_PURGE_TABLESPACE, 199, "PURGE TABLESPACE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_PURGE_TABLE, 200, "PURGE TABLE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_PURGE_INDEX, 201, "PURGE INDEX")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_UNDROP_OBJECT, 202, "UNDROP OBJECT")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DROP_DATABASE, 203, "DROP DATABASE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_FLASHBACK_DATABASE, 204, "FLASHBACK DATABASE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_FLASHBACK_TABLE, 205, "FLASHBACK TABLE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_RESTORE_POINT, 206, "CREATE RESTORE POINT")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DROP_RESTORE_POINT, 207, "DROP RESTORE POINT")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_PROXY_AUTHENTICATION_ONLY, 208, "PROXY AUTHENTICATION ONLY")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DECLARE_REWRITE_EQUIVALENCE, 209, "DECLARE REWRITE EQUIVALENCE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ALTER_REWRITE_EQUIVALENCE, 210, "ALTER REWRITE EQUIVALENCE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DROP_REWRITE_EQUIVALENCE, 211, "DROP REWRITE EQUIVALENCE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_EDITION, 212, "CREATE EDITION")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ALTER_EDITION, 213, "ALTER EDITION")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DROP_EDITION, 214, "DROP EDITION")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DROP_ASSEMBLY, 215, "DROP ASSEMBLY")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_ASSEMBLY, 216, "CREATE ASSEMBLY")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ALTER_ASSEMBLY, 217, "ALTER ASSEMBLY")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_FLASHBACK_ARCHIVE, 218, "CREATE FLASHBACK ARCHIVE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ALTER_FLASHBACK_ARCHIVE, 219, "ALTER FLASHBACK ARCHIVE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DROP_FLASHBACK_ARCHIVE, 220, "DROP FLASHBACK ARCHIVE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DEBUG_CONNECT, 221, "DEBUG CONNECT")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DEBUG_PROCEDURE, 223, "DEBUG PROCEDURE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ALTER_DATABASE_LINK, 225, "ALTER DATABASE LINK")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_PLUGGABLE_DATABASE, 226, "CREATE PLUGGABLE DATABASE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ALTER_PLUGGABLE_DATABASE, 227, "ALTER PLUGGABLE DATABASE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DROP_PLUGGABLE_DATABASE, 228, "DROP PLUGGABLE DATABASE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_AUDIT_POLICY, 229, "CREATE AUDIT POLICY")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ALTER_AUDIT_POLICY, 230, "ALTER AUDIT POLICY")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DROP_AUDIT_POLICY, 231, "DROP AUDIT POLICY")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CODE_BASED_GRANT, 232, "CODE-BASED GRANT")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CODE_BASED_REVOKE, 233, "CODE-BASED REVOKE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_LOCKDOWN_PROFILE, 234, "CREATE LOCKDOWN PROFILE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DROP_LOCKDOWN_PROFILE, 235, "DROP LOCKDOWN PROFILE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ALTER_LOCKDOWN_PROFILE, 236, "ALTER LOCKDOWN PROFILE")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_TRANSLATE_SQL, 237, "TRANSLATE SQL")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ADMINISTER_KEY_MANAGEMENT, 238, "ADMINISTER KEY MANAGEMENT")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_MATERIALIZED_ZONEMAP, 239, "CREATE MATERIALIZED ZONEMAP")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ALTER_MATERIALIZED_ZONEMAP, 240, "ALTER MATERIALIZED ZONEMAP")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DROP_MATERIALIZED_ZONEMAP, 241, "DROP MATERIALIZED ZONEMAP")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DROP_MINING_MODEL, 242, "DROP MINING MODEL")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_ATTRIBUTE_DIMENSION, 243, "CREATE ATTRIBUTE DIMENSION")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ALTER_ATTRIBUTE_DIMENSION, 244, "ALTER ATTRIBUTE DIMENSION")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DROP_ATTRIBUTE_DIMENSION, 245, "DROP ATTRIBUTE DIMENSION")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_HIERARCHY, 246, "CREATE HIERARCHY")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ALTER_HIERARCHY, 247, "ALTER HIERARCHY")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DROP_HIERARCHY, 248, "DROP HIERARCHY")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_CREATE_ANALYTIC_VIEW, 249, "CREATE ANALYTIC VIEW")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ALTER_ANALYTIC_VIEW, 250, "ALTER ANALYTIC VIEW")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_DROP_ANALYTIC_VIEW, 251, "DROP ANALYTIC VIEW")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_ALTER_PUBLIC_DATABASE_LINK, 305, "ALTER PUBLIC DATABASE LINK")
|
||||
|
||||
// the subsequence action types will not be exposed to user
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_GUARD, 400, "UNUSED")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_OB_CREATE_SYNONYM, 401, "INTERNAL USED")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_OB_DROP_SYNONYM, 402, "INTERNAL USED")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_OB_CREATE_ROUTINE, 403, "INTERNAL USED")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_OB_DROP_ROUTINE, 404, "INTERNAL USED")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_OB_AUDIT, 405, "INTERNAL USED")
|
||||
OB_AUDIT_ACTION_TYPE_DEF(ACTION_TYPE_MAX, 500, "UNUSED")
|
||||
#endif
|
||||
|
||||
#ifndef OCEANBASE_SQL_OB_AUDIT_ACTION_TYPE_H_
|
||||
#define OCEANBASE_SQL_OB_AUDIT_ACTION_TYPE_H_
|
||||
|
||||
namespace oceanbase {
|
||||
namespace sql {
|
||||
namespace audit {
|
||||
|
||||
enum AuditActionType : int32_t
|
||||
{
|
||||
#define OB_AUDIT_ACTION_TYPE_DEF(action_type, action_id, action_name) action_type = action_id,
|
||||
#include "sql/monitor/ob_audit_action_type.h"
|
||||
#undef OB_AUDIT_ACTION_TYPE_DEF
|
||||
};
|
||||
|
||||
struct AuditActionTypeIndex
|
||||
{
|
||||
public:
|
||||
AuditActionTypeIndex()
|
||||
: audit_action_type_idx_()
|
||||
{
|
||||
int i = 0;
|
||||
for (int j = 0; j < ARRAYSIZEOF(audit_action_type_idx_); j++) {
|
||||
audit_action_type_idx_[j] = -1;
|
||||
}
|
||||
#define OB_AUDIT_ACTION_TYPE_DEF(action_type, action_id, action_name) audit_action_type_idx_[action_type] = i++;
|
||||
#include "sql/monitor/ob_audit_action_type.h"
|
||||
#undef OB_AUDIT_ACTION_TYPE_DEF
|
||||
}
|
||||
int32_t audit_action_type_idx_[ACTION_TYPE_MAX + 1];
|
||||
};
|
||||
|
||||
inline int32_t get_audit_action_type_idx(AuditActionType type)
|
||||
{
|
||||
static AuditActionTypeIndex inst;
|
||||
return inst.audit_action_type_idx_[type];
|
||||
}
|
||||
|
||||
} // namespace audit
|
||||
} // namespace sql
|
||||
} // namespace oceanbase
|
||||
|
||||
#endif /* OCEANBASE_SQL_OB_AUDIT_ACTION_TYPE_H */
|
||||
@ -27,8 +27,6 @@ EVENT_INFO(RPC_PACKET_OUT, rpc_packet_out)
|
||||
EVENT_INFO(RPC_PACKET_OUT_BYTES, rpc_packet_out_bytes)
|
||||
EVENT_INFO(ROW_CACHE_HIT, row_cache_hit)
|
||||
EVENT_INFO(ROW_CACHE_MISS, row_cache_miss)
|
||||
EVENT_INFO(BLOCK_INDEX_CACHE_HIT, block_index_cache_hit)
|
||||
EVENT_INFO(BLOCK_INDEX_CACHE_MISS, block_index_cache_miss)
|
||||
EVENT_INFO(BLOCK_CACHE_HIT, block_cache_hit)
|
||||
EVENT_INFO(BLOCK_CACHE_MISS, block_cache_miss)
|
||||
EVENT_INFO(BLOOM_FILTER_FILTS, bloom_filter_filts)
|
||||
@ -44,6 +42,13 @@ EVENT_INFO(TRANS_COMMIT_LOG_SUBMIT_COUNT, trans_commit_log_submit_count)
|
||||
EVENT_INFO(TRANS_COMMIT_TIME, trans_commit_time)
|
||||
EVENT_INFO(MEMSTORE_READ_ROW_COUNT, memstore_read_row_count)
|
||||
EVENT_INFO(SSSTORE_READ_ROW_COUNT, ssstore_read_row_count)
|
||||
EVENT_INFO(DATA_BLOCK_READ_CNT, data_block_read_cnt)
|
||||
EVENT_INFO(DATA_BLOCK_CACHE_HIT, data_block_cache_hit)
|
||||
EVENT_INFO(INDEX_BLOCK_READ_CNT, index_block_read_cnt)
|
||||
EVENT_INFO(INDEX_BLOCK_CACHE_HIT, index_block_cache_hit)
|
||||
EVENT_INFO(BLOCKSCAN_BLOCK_CNT, blockscan_block_cnt)
|
||||
EVENT_INFO(BLOCKSCAN_ROW_CNT, blockscan_row_cnt)
|
||||
EVENT_INFO(PUSHDOWN_STORAGE_FILTER_ROW_CNT, pushdown_storage_filter_row_cnt)
|
||||
EVENT_INFO(FUSE_ROW_CACHE_HIT, fuse_row_cache_hit)
|
||||
EVENT_INFO(FUSE_ROW_CACHE_MISS, fuse_row_cache_miss)
|
||||
#endif
|
||||
@ -56,16 +61,18 @@ EVENT_INFO(FUSE_ROW_CACHE_MISS, fuse_row_cache_miss)
|
||||
#include "lib/net/ob_addr.h"
|
||||
#include "sql/ob_sql_define.h"
|
||||
#include "sql/plan_cache/ob_plan_cache_util.h"
|
||||
#include "observer/virtual_table/ob_information_query_response_time.h"
|
||||
namespace oceanbase {
|
||||
namespace sql {
|
||||
struct ObExecRecord {
|
||||
// max wait event during sql exec
|
||||
namespace oceanbase
|
||||
{
|
||||
namespace sql
|
||||
{
|
||||
struct ObExecRecord
|
||||
{
|
||||
//max wait event during sql exec
|
||||
common::ObWaitEventDesc max_wait_event_;
|
||||
|
||||
#define EVENT_INFO(def, name) \
|
||||
int64_t name##_start_; \
|
||||
int64_t name##_end_; \
|
||||
int64_t name##_start_; \
|
||||
int64_t name##_end_;\
|
||||
int64_t name##_;
|
||||
#include "ob_exec_stat.h"
|
||||
#undef EVENT_INFO
|
||||
@ -75,97 +82,66 @@ struct ObExecRecord {
|
||||
MEMSET(this, 0, sizeof(*this));
|
||||
}
|
||||
|
||||
#define EVENT_INFO(def, name) \
|
||||
int64_t get_##name() const \
|
||||
{ \
|
||||
return name##_end_ - name##_start_; \
|
||||
}
|
||||
#define EVENT_INFO(def, name) \
|
||||
int64_t get_##name() const { return name##_end_ - name##_start_; }
|
||||
#include "ob_exec_stat.h"
|
||||
#undef EVENT_INFO
|
||||
|
||||
#define RECORD(se, di) \
|
||||
do { \
|
||||
oceanbase::common::ObDiagnoseSessionInfo* diag_session_info = \
|
||||
(NULL != di) ? di : oceanbase::common::ObDiagnoseSessionInfo::get_local_diagnose_info(); \
|
||||
if (NULL != diag_session_info) { \
|
||||
io_read_count_##se##_ = EVENT_GET(ObStatEventIds::IO_READ_COUNT, diag_session_info); \
|
||||
io_write_count_##se##_ = EVENT_GET(ObStatEventIds::IO_WRITE_COUNT, diag_session_info); \
|
||||
block_cache_hit_##se##_ = EVENT_GET(ObStatEventIds::BLOCK_CACHE_HIT, diag_session_info); \
|
||||
io_read_bytes_##se##_ = EVENT_GET(ObStatEventIds::IO_READ_BYTES, diag_session_info); \
|
||||
io_write_bytes_##se##_ = EVENT_GET(ObStatEventIds::IO_WRITE_BYTES, diag_session_info); \
|
||||
rpc_packet_in_##se##_ = EVENT_GET(ObStatEventIds::RPC_PACKET_IN, diag_session_info); \
|
||||
rpc_packet_in_bytes_##se##_ = EVENT_GET(ObStatEventIds::RPC_PACKET_IN_BYTES, diag_session_info); \
|
||||
rpc_packet_out_##se##_ = EVENT_GET(ObStatEventIds::RPC_PACKET_OUT, diag_session_info); \
|
||||
rpc_packet_out_bytes_##se##_ = EVENT_GET(ObStatEventIds::RPC_PACKET_OUT_BYTES, diag_session_info); \
|
||||
trans_commit_log_sync_time_##se##_ = EVENT_GET(ObStatEventIds::TRANS_COMMIT_LOG_SYNC_TIME, diag_session_info); \
|
||||
row_cache_hit_##se##_ = EVENT_GET(ObStatEventIds::ROW_CACHE_HIT, diag_session_info); \
|
||||
row_cache_miss_##se##_ = EVENT_GET(ObStatEventIds::ROW_CACHE_MISS, diag_session_info); \
|
||||
block_index_cache_hit_##se##_ = EVENT_GET(ObStatEventIds::BLOCK_INDEX_CACHE_HIT, diag_session_info); \
|
||||
block_index_cache_miss_##se##_ = EVENT_GET(ObStatEventIds::BLOCK_INDEX_CACHE_MISS, diag_session_info); \
|
||||
block_cache_hit_##se##_ = EVENT_GET(ObStatEventIds::BLOCK_CACHE_HIT, diag_session_info); \
|
||||
block_cache_miss_##se##_ = EVENT_GET(ObStatEventIds::BLOCK_CACHE_MISS, diag_session_info); \
|
||||
bloom_filter_filts_##se##_ = EVENT_GET(ObStatEventIds::BLOOM_FILTER_FILTS, diag_session_info); \
|
||||
location_cache_hit_##se##_ = EVENT_GET(ObStatEventIds::LOCATION_CACHE_HIT, diag_session_info); \
|
||||
location_cache_miss_##se##_ = EVENT_GET(ObStatEventIds::LOCATION_CACHE_MISS, diag_session_info); \
|
||||
memstore_read_lock_succ_count_##se##_ = \
|
||||
EVENT_GET(ObStatEventIds::MEMSTORE_READ_LOCK_SUCC_COUNT, diag_session_info); \
|
||||
memstore_write_lock_succ_count_##se##_ = \
|
||||
EVENT_GET(ObStatEventIds::MEMSTORE_WRITE_LOCK_SUCC_COUNT, diag_session_info); \
|
||||
memstore_wait_read_lock_time_##se##_ = \
|
||||
EVENT_GET(ObStatEventIds::MEMSTORE_WAIT_READ_LOCK_TIME, diag_session_info); \
|
||||
memstore_wait_write_lock_time_##se##_ = \
|
||||
EVENT_GET(ObStatEventIds::MEMSTORE_WAIT_WRITE_LOCK_TIME, diag_session_info); \
|
||||
memstore_read_row_count_##se##_ = EVENT_GET(ObStatEventIds::MEMSTORE_READ_ROW_COUNT, diag_session_info); \
|
||||
ssstore_read_row_count_##se##_ = EVENT_GET(ObStatEventIds::SSSTORE_READ_ROW_COUNT, diag_session_info); \
|
||||
fuse_row_cache_hit_##se##_ = EVENT_GET(ObStatEventIds::FUSE_ROW_CACHE_HIT, diag_session_info); \
|
||||
fuse_row_cache_miss_##se##_ = EVENT_GET(ObStatEventIds::FUSE_ROW_CACHE_MISS, diag_session_info); \
|
||||
for (int i = 0; i < oceanbase::common::ObWaitEventIds::WAIT_EVENT_END; ++i) { \
|
||||
if (NULL != diag_session_info->get_event_stats().get(i)) { \
|
||||
uint64_t time = diag_session_info->get_event_stats().get(i)->time_waited_; \
|
||||
switch (oceanbase::common::OB_WAIT_EVENTS[i].wait_class_) { \
|
||||
case oceanbase::common::ObWaitClassIds::USER_IO: { \
|
||||
user_io_time_##se##_ += time; \
|
||||
break; \
|
||||
} \
|
||||
case oceanbase::common::ObWaitClassIds::SCHEDULER: { \
|
||||
sched_time_##se##_ += time; \
|
||||
break; \
|
||||
} \
|
||||
case oceanbase::common::ObWaitClassIds::CONCURRENCY: { \
|
||||
concurrency_time_##se##_ += time; \
|
||||
break; \
|
||||
} \
|
||||
case oceanbase::common::ObWaitClassIds::APPLICATION: { \
|
||||
application_time_##se##_ += time; \
|
||||
break; \
|
||||
} \
|
||||
default: { \
|
||||
/*do nothing*/ \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
} /*for end */ \
|
||||
} \
|
||||
} while (0);
|
||||
|
||||
#define UPDATE_EVENT(event) \
|
||||
do { \
|
||||
#define RECORD(se, di) \
|
||||
do { \
|
||||
oceanbase::common::ObDiagnoseSessionInfo *diag_session_info = (NULL != di) ? di : oceanbase::common::ObDiagnoseSessionInfo::get_local_diagnose_info(); \
|
||||
if (NULL != diag_session_info) { \
|
||||
io_read_count_##se##_= EVENT_GET(ObStatEventIds::IO_READ_COUNT, diag_session_info); \
|
||||
io_write_count_##se##_ = EVENT_GET(ObStatEventIds::IO_WRITE_COUNT, diag_session_info); \
|
||||
block_cache_hit_##se##_= EVENT_GET(ObStatEventIds::BLOCK_CACHE_HIT, diag_session_info); \
|
||||
io_read_bytes_##se##_= EVENT_GET(ObStatEventIds::IO_READ_BYTES, diag_session_info); \
|
||||
io_write_bytes_##se##_= EVENT_GET(ObStatEventIds::IO_WRITE_BYTES, diag_session_info); \
|
||||
rpc_packet_in_##se##_= EVENT_GET(ObStatEventIds::RPC_PACKET_IN, diag_session_info); \
|
||||
rpc_packet_in_bytes_##se##_= EVENT_GET(ObStatEventIds::RPC_PACKET_IN_BYTES, diag_session_info); \
|
||||
rpc_packet_out_##se##_= EVENT_GET(ObStatEventIds::RPC_PACKET_OUT, diag_session_info); \
|
||||
rpc_packet_out_bytes_##se##_= EVENT_GET(ObStatEventIds::RPC_PACKET_OUT_BYTES, diag_session_info); \
|
||||
trans_commit_log_sync_time_##se##_= EVENT_GET(ObStatEventIds::TRANS_COMMIT_LOG_SYNC_TIME, diag_session_info); \
|
||||
row_cache_hit_##se##_= EVENT_GET(ObStatEventIds::ROW_CACHE_HIT, diag_session_info); \
|
||||
row_cache_miss_##se##_= EVENT_GET(ObStatEventIds::ROW_CACHE_MISS, diag_session_info); \
|
||||
block_cache_hit_##se##_= EVENT_GET(ObStatEventIds::BLOCK_CACHE_HIT, diag_session_info); \
|
||||
block_cache_miss_##se##_= EVENT_GET(ObStatEventIds::BLOCK_CACHE_MISS, diag_session_info); \
|
||||
bloom_filter_filts_##se##_ = EVENT_GET(ObStatEventIds::BLOOM_FILTER_FILTS, diag_session_info); \
|
||||
location_cache_hit_##se##_= EVENT_GET(ObStatEventIds::LOCATION_CACHE_HIT, diag_session_info); \
|
||||
location_cache_miss_##se##_= EVENT_GET(ObStatEventIds::LOCATION_CACHE_MISS, diag_session_info); \
|
||||
memstore_read_lock_succ_count_##se##_= EVENT_GET(ObStatEventIds::MEMSTORE_READ_LOCK_SUCC_COUNT, diag_session_info); \
|
||||
memstore_write_lock_succ_count_##se##_= EVENT_GET(ObStatEventIds::MEMSTORE_WRITE_LOCK_SUCC_COUNT, diag_session_info); \
|
||||
memstore_wait_read_lock_time_##se##_= EVENT_GET(ObStatEventIds::MEMSTORE_WAIT_READ_LOCK_TIME, diag_session_info); \
|
||||
memstore_wait_write_lock_time_##se##_= EVENT_GET(ObStatEventIds::MEMSTORE_WAIT_WRITE_LOCK_TIME, diag_session_info); \
|
||||
memstore_read_row_count_##se##_ = EVENT_GET(ObStatEventIds::MEMSTORE_READ_ROW_COUNT, diag_session_info); \
|
||||
ssstore_read_row_count_##se##_ = EVENT_GET(ObStatEventIds::SSSTORE_READ_ROW_COUNT, diag_session_info); \
|
||||
data_block_read_cnt_##se##_ = EVENT_GET(ObStatEventIds::DATA_BLOCK_READ_CNT, diag_session_info); \
|
||||
data_block_cache_hit_##se##_ = EVENT_GET(ObStatEventIds::DATA_BLOCK_CACHE_HIT, diag_session_info); \
|
||||
index_block_read_cnt_##se##_ = EVENT_GET(ObStatEventIds::INDEX_BLOCK_READ_CNT, diag_session_info); \
|
||||
index_block_cache_hit_##se##_ = EVENT_GET(ObStatEventIds::INDEX_BLOCK_CACHE_HIT, diag_session_info); \
|
||||
blockscan_block_cnt_##se##_ = EVENT_GET(ObStatEventIds::BLOCKSCAN_BLOCK_CNT, diag_session_info); \
|
||||
blockscan_row_cnt_##se##_ = EVENT_GET(ObStatEventIds::BLOCKSCAN_ROW_CNT, diag_session_info); \
|
||||
pushdown_storage_filter_row_cnt_##se##_ = EVENT_GET(ObStatEventIds::PUSHDOWN_STORAGE_FILTER_ROW_CNT, diag_session_info); \
|
||||
fuse_row_cache_hit_##se##_= EVENT_GET(ObStatEventIds::FUSE_ROW_CACHE_HIT, diag_session_info); \
|
||||
fuse_row_cache_miss_##se##_= EVENT_GET(ObStatEventIds::FUSE_ROW_CACHE_MISS, diag_session_info); \
|
||||
} \
|
||||
} while(0);
|
||||
|
||||
#define UPDATE_EVENT(event) \
|
||||
do \
|
||||
{ \
|
||||
event##_ += event##_end_ - event##_start_; \
|
||||
} while (0);
|
||||
} while(0);
|
||||
|
||||
void record_start(common::ObDiagnoseSessionInfo* di = NULL)
|
||||
{
|
||||
void record_start(common::ObDiagnoseSessionInfo *di = NULL) {
|
||||
RECORD(start, di);
|
||||
}
|
||||
|
||||
void record_end(common::ObDiagnoseSessionInfo* di = NULL)
|
||||
{
|
||||
void record_end(common::ObDiagnoseSessionInfo *di = NULL) {
|
||||
RECORD(end, di);
|
||||
}
|
||||
|
||||
void update_stat()
|
||||
{
|
||||
void update_stat() {
|
||||
UPDATE_EVENT(wait_time);
|
||||
UPDATE_EVENT(wait_count);
|
||||
UPDATE_EVENT(io_read_count);
|
||||
@ -180,8 +156,6 @@ struct ObExecRecord {
|
||||
UPDATE_EVENT(trans_commit_log_sync_time);
|
||||
UPDATE_EVENT(row_cache_hit);
|
||||
UPDATE_EVENT(row_cache_miss);
|
||||
UPDATE_EVENT(block_index_cache_hit);
|
||||
UPDATE_EVENT(block_index_cache_miss);
|
||||
UPDATE_EVENT(bloom_filter_filts);
|
||||
UPDATE_EVENT(location_cache_hit);
|
||||
UPDATE_EVENT(location_cache_miss);
|
||||
@ -195,12 +169,29 @@ struct ObExecRecord {
|
||||
UPDATE_EVENT(application_time);
|
||||
UPDATE_EVENT(memstore_read_row_count);
|
||||
UPDATE_EVENT(ssstore_read_row_count);
|
||||
UPDATE_EVENT(data_block_read_cnt);
|
||||
UPDATE_EVENT(data_block_cache_hit);
|
||||
UPDATE_EVENT(index_block_read_cnt);
|
||||
UPDATE_EVENT(index_block_cache_hit);
|
||||
UPDATE_EVENT(blockscan_block_cnt);
|
||||
UPDATE_EVENT(blockscan_row_cnt);
|
||||
UPDATE_EVENT(pushdown_storage_filter_row_cnt);
|
||||
}
|
||||
};
|
||||
|
||||
enum ExecType { InvalidType = 0, MpQuery, InnerSql, RpcProcessor, PLSql };
|
||||
enum ExecType {
|
||||
InvalidType = 0,
|
||||
MpQuery,
|
||||
InnerSql,
|
||||
RpcProcessor,
|
||||
PLSql,
|
||||
PSCursor,
|
||||
DbmsCursor,
|
||||
CursorFetch
|
||||
};
|
||||
|
||||
struct ObReqTimestamp {
|
||||
struct ObReqTimestamp
|
||||
{
|
||||
ObReqTimestamp()
|
||||
{
|
||||
MEMSET(this, 0, sizeof(*this));
|
||||
@ -216,61 +207,69 @@ struct ObExecTimestamp {
|
||||
MEMSET(this, 0, sizeof(*this));
|
||||
}
|
||||
ExecType exec_type_;
|
||||
|
||||
int64_t rpc_send_ts_; // Send rpc timestamp
|
||||
int64_t receive_ts_; // The timestamp of the received request, followed by the net wait time
|
||||
//***The timestamp below needs to be updated after each retry***
|
||||
int64_t enter_queue_ts_; // Enter the queue timestamp
|
||||
int64_t run_ts_; // The timestamp of the start of the run, followed by the decode time
|
||||
int64_t before_process_ts_; // The timestamp of the beginning of the before process
|
||||
int64_t single_process_ts_; // Start timestamp of a single sql do process
|
||||
int64_t process_executor_ts_; // The time stamp when the plan started executing
|
||||
int64_t executor_end_ts_; // The timestamp of the end of plan execution
|
||||
int64_t rpc_send_ts_; //发送rpc的时间戳
|
||||
int64_t receive_ts_; //接收请求的时间戳, 其后面是net wait时间
|
||||
//***下面的时间戳在每次重试后需要更新***
|
||||
int64_t enter_queue_ts_;//进入队列时间戳
|
||||
int64_t run_ts_; //开始run的时间戳, 其后面是decode时间
|
||||
int64_t before_process_ts_; //before process 开始的时间戳
|
||||
int64_t single_process_ts_; //单条sql do process的开始时间戳
|
||||
int64_t process_executor_ts_; //plan开始执行的时间戳
|
||||
int64_t executor_end_ts_; // plan执行结束的时间戳
|
||||
//*** 下面时间戳是特殊场景所需要用的***
|
||||
int64_t multistmt_start_ts_; // multistmt 场景下拆分后各个子 sql 开始执行时间戳
|
||||
|
||||
int64_t elapsed_t_;
|
||||
//**** The following records only time-consuming during the first execution**
|
||||
//**** 下面只记录在第一次执行过程中耗时**
|
||||
int64_t net_t_;
|
||||
int64_t net_wait_t_;
|
||||
//***** The following records are the cumulative time ***
|
||||
//***** 下面记录的是累计耗时 ***
|
||||
int64_t queue_t_;
|
||||
int64_t decode_t_;
|
||||
int64_t get_plan_t_;
|
||||
int64_t executor_t_;
|
||||
|
||||
// Time accumulates when there is a retry
|
||||
void update_stage_time()
|
||||
{
|
||||
elapsed_t_ = executor_end_ts_ - receive_ts_; // Retry does not need to accumulate
|
||||
queue_t_ += run_ts_ - enter_queue_ts_;
|
||||
decode_t_ += before_process_ts_ - run_ts_;
|
||||
//出现重试时时间累加
|
||||
void update_stage_time() {
|
||||
// elapsed_t_ 重试不需要累加,其他重试需要累加,且在 multistmt 场景下计算方式更改
|
||||
// multistmt 场景特殊处理,第二个及之后的 sql 的 queue_t_、decode_t_ 均为 0
|
||||
if (multistmt_start_ts_ > 0) {
|
||||
queue_t_ = 0;
|
||||
decode_t_ = 0;
|
||||
elapsed_t_ = executor_end_ts_ - multistmt_start_ts_;
|
||||
} else {
|
||||
queue_t_ += run_ts_ - enter_queue_ts_;
|
||||
decode_t_ += before_process_ts_ - run_ts_;
|
||||
elapsed_t_ = executor_end_ts_ - receive_ts_;
|
||||
}
|
||||
get_plan_t_ += process_executor_ts_ - single_process_ts_;
|
||||
executor_t_ += executor_end_ts_ - process_executor_ts_;
|
||||
}
|
||||
};
|
||||
|
||||
class ObSchedInfo {
|
||||
class ObSchedInfo
|
||||
{
|
||||
public:
|
||||
ObSchedInfo() : sched_info_(NULL), sched_info_len_(0)
|
||||
{}
|
||||
void reset()
|
||||
ObSchedInfo() : sched_info_(NULL), sched_info_len_(0) {}
|
||||
void reset()
|
||||
{
|
||||
MEMSET(this, 0, sizeof(*this));
|
||||
MEMSET(this, 0 , sizeof(*this));
|
||||
}
|
||||
inline void assign(char* sched_info, int64_t info_len)
|
||||
inline void assign(char *sched_info, int64_t info_len)
|
||||
{
|
||||
sched_info_ = sched_info;
|
||||
sched_info_len_ = info_len;
|
||||
}
|
||||
int append(common::ObIAllocator& allocator, const char* sched_info, int64_t info_len)
|
||||
int append(common::ObIAllocator &allocator, const char *sched_info, int64_t info_len)
|
||||
{
|
||||
int ret = common::OB_SUCCESS;
|
||||
if (sched_info_len_ >= 0 && info_len > 0 && sched_info_len_ + info_len <= common::OB_MAX_SCHED_INFO_LENGTH) {
|
||||
void* ptr = NULL;
|
||||
void *ptr = NULL;
|
||||
if (OB_UNLIKELY(NULL == (ptr = allocator.alloc(info_len + sched_info_len_)))) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
SQL_MONITOR_LOG(WARN, "fail to alloc sched info", K(ret));
|
||||
} else {
|
||||
char* str = static_cast<char*>(ptr);
|
||||
char *str = static_cast<char *>(ptr);
|
||||
if (sched_info_ != NULL && sched_info_len_ > 0) {
|
||||
MEMCPY(str, sched_info_, sched_info_len_);
|
||||
}
|
||||
@ -283,45 +282,49 @@ public:
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
inline const char* get_ptr() const
|
||||
{
|
||||
return sched_info_;
|
||||
}
|
||||
inline int64_t get_len() const
|
||||
{
|
||||
return sched_info_len_;
|
||||
}
|
||||
|
||||
inline const char *get_ptr() const { return sched_info_; }
|
||||
inline int64_t get_len() const { return sched_info_len_; }
|
||||
private:
|
||||
char* sched_info_;
|
||||
char *sched_info_;
|
||||
int64_t sched_info_len_;
|
||||
};
|
||||
|
||||
struct ObAuditRecordData {
|
||||
ObAuditRecordData() : sched_info_()
|
||||
ObAuditRecordData()
|
||||
{
|
||||
reset();
|
||||
}
|
||||
~ObAuditRecordData()
|
||||
{
|
||||
sched_info_.reset();
|
||||
}
|
||||
|
||||
int assign(const ObAuditRecordData &from)
|
||||
{
|
||||
MEMCPY((void*)this, (void*)&from, sizeof(from));
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
void reset()
|
||||
{
|
||||
MEMSET(this, 0, sizeof(*this));
|
||||
MEMSET((void*)this, 0, sizeof(*this));
|
||||
consistency_level_ = common::INVALID_CONSISTENCY;
|
||||
ps_stmt_id_ = OB_INVALID_STMT_ID;
|
||||
trans_hash_ = 0;
|
||||
ps_inner_stmt_id_ = OB_INVALID_STMT_ID;
|
||||
trans_id_ = 0;
|
||||
request_type_ = EXECUTE_INVALID;
|
||||
is_batched_multi_stmt_ = false;
|
||||
plan_hash_ = 0;
|
||||
trx_lock_for_read_elapse_ = 0;
|
||||
params_value_len_ = 0;
|
||||
}
|
||||
|
||||
int64_t get_elapsed_time() const
|
||||
{
|
||||
return exec_timestamp_.executor_end_ts_ - exec_timestamp_.receive_ts_;
|
||||
int64_t elapsed_time = 0;
|
||||
if (OB_UNLIKELY(exec_timestamp_.multistmt_start_ts_ > 0)) {
|
||||
elapsed_time = exec_timestamp_.executor_end_ts_ - exec_timestamp_.multistmt_start_ts_;
|
||||
} else {
|
||||
elapsed_time = exec_timestamp_.executor_end_ts_ - exec_timestamp_.receive_ts_;
|
||||
}
|
||||
return elapsed_time;
|
||||
}
|
||||
|
||||
int64_t get_process_time() const
|
||||
@ -335,7 +338,7 @@ struct ObAuditRecordData {
|
||||
exec_record_.update_stat();
|
||||
const int64_t cpu_time = MAX(exec_timestamp_.elapsed_t_ - exec_record_.wait_time_, 0);
|
||||
const int64_t elapsed_time = MAX(exec_timestamp_.elapsed_t_, 0);
|
||||
if (is_inner_sql_) {
|
||||
if(is_inner_sql_) {
|
||||
EVENT_ADD(SYS_TIME_MODEL_DB_INNER_TIME, elapsed_time);
|
||||
EVENT_ADD(SYS_TIME_MODEL_DB_INNER_CPU, cpu_time);
|
||||
} else {
|
||||
@ -344,9 +347,9 @@ struct ObAuditRecordData {
|
||||
}
|
||||
}
|
||||
|
||||
bool is_timeout() const
|
||||
{
|
||||
return common::OB_TIMEOUT == status_ || common::OB_TRANS_STMT_TIMEOUT == status_;
|
||||
bool is_timeout() const {
|
||||
return common::OB_TIMEOUT == status_
|
||||
|| common::OB_TRANS_STMT_TIMEOUT == status_;
|
||||
}
|
||||
|
||||
int64_t get_extra_size() const
|
||||
@ -354,13 +357,23 @@ struct ObAuditRecordData {
|
||||
return sql_len_ + tenant_name_len_ + user_name_len_ + db_name_len_;
|
||||
}
|
||||
|
||||
int16_t seq_; // packet->get_packet_header().seq_; always 0 currently
|
||||
int status_; // error code
|
||||
uint64_t trace_id_[2];
|
||||
int64_t request_id_; // set by request_manager automatic when add record
|
||||
int64_t execution_id_; // used to jion v$sql_plan_monitor
|
||||
int64_t get_snapshot_version() const
|
||||
{
|
||||
return snapshot_.version_;
|
||||
}
|
||||
|
||||
ObString get_snapshot_source() const
|
||||
{
|
||||
return ObString(snapshot_.source_);
|
||||
}
|
||||
|
||||
int16_t seq_; //packet->get_packet_header().seq_; always 0 currently
|
||||
int status_; //error code
|
||||
common::ObCurTraceId::TraceId trace_id_;
|
||||
int64_t request_id_; //set by request_manager automatic when add record
|
||||
int64_t execution_id_; //used to jion v$sql_plan_monitor
|
||||
uint64_t session_id_;
|
||||
uint64_t qc_id_;
|
||||
uint64_t qc_id_; //px框架下id
|
||||
int64_t dfo_id_;
|
||||
int64_t sqc_id_;
|
||||
int64_t worker_id_;
|
||||
@ -369,47 +382,56 @@ struct ObAuditRecordData {
|
||||
common::ObAddr user_client_addr_;
|
||||
int64_t tenant_id_;
|
||||
int64_t effective_tenant_id_;
|
||||
char* tenant_name_;
|
||||
char *tenant_name_;
|
||||
int64_t tenant_name_len_;
|
||||
int64_t user_id_;
|
||||
char* user_name_;
|
||||
char *user_name_;
|
||||
int64_t user_name_len_;
|
||||
int user_group_; // The cgroup id that the user belongs to, only displayed on the main thread
|
||||
int user_group_; // user 所属 cgroup id,仅主线程展示
|
||||
uint64_t db_id_;
|
||||
char* db_name_;
|
||||
char *db_name_;
|
||||
int64_t db_name_len_;
|
||||
char sql_id_[common::OB_MAX_SQL_ID_LENGTH + 1];
|
||||
char* sql_; // The memory is allocated by allocate_ and released when the record is eliminated;
|
||||
char *sql_; //该内存由allocate_分配, 在record被淘汰时释放;
|
||||
int64_t sql_len_;
|
||||
common::ObCollationType sql_cs_type_;
|
||||
int64_t plan_id_;
|
||||
int64_t affected_rows_; // The number of rows affected by delete, update, insert, and the number of rows selected by
|
||||
// select
|
||||
int64_t affected_rows_;//delete,update,insert影响的行数,及select选出的行数
|
||||
int64_t return_rows_;
|
||||
int64_t partition_cnt_; // The number of partitions involved in the request
|
||||
int64_t expected_worker_cnt_; // px expected number of threads allocated
|
||||
int64_t used_worker_cnt_; // px actual number of threads allocated
|
||||
int64_t try_cnt_; // Number of attempts to execute
|
||||
int64_t partition_cnt_;//该请求涉及的所以parttion个数
|
||||
int64_t expected_worker_cnt_; // px 预期分配线程数
|
||||
int64_t used_worker_cnt_; // px 实际分配线程数
|
||||
int64_t try_cnt_; //尝试执行次数
|
||||
ObPhyPlanType plan_type_;
|
||||
bool is_executor_rpc_;
|
||||
bool is_inner_sql_;
|
||||
bool is_hit_plan_cache_;
|
||||
bool is_multi_stmt_; // Is it multi sql
|
||||
bool is_multi_stmt_; //是否是multi sql
|
||||
bool table_scan_;
|
||||
common::ObConsistencyLevel consistency_level_;
|
||||
int64_t request_memory_used_;
|
||||
ObExecTimestamp exec_timestamp_;
|
||||
ObExecRecord exec_record_;
|
||||
ObTableScanStat table_scan_stat_;
|
||||
ObSchedInfo sched_info_; // px sched info
|
||||
int64_t ps_stmt_id_;
|
||||
int64_t ps_inner_stmt_id_;
|
||||
int64_t request_type_;
|
||||
uint64_t trans_hash_;
|
||||
int64_t trans_id_;
|
||||
bool is_batched_multi_stmt_;
|
||||
ObString ob_trace_info_;
|
||||
uint64_t plan_hash_;
|
||||
int64_t trx_lock_for_read_elapse_;
|
||||
int64_t params_value_len_;
|
||||
char *params_value_;
|
||||
struct StmtSnapshot {
|
||||
int64_t version_; // snapshot version
|
||||
int64_t tx_id_; // snapshot inner which txn
|
||||
int64_t scn_; // snapshot's position in the txn
|
||||
char const* source_; // snapshot's acquire source
|
||||
} snapshot_; // stmt's tx snapshot
|
||||
};
|
||||
|
||||
} // namespace sql
|
||||
} // namespace oceanbase
|
||||
} //namespace sql
|
||||
} //namespace oceanbase
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@ -15,22 +15,24 @@
|
||||
#include "sql/monitor/ob_phy_operator_monitor_info.h"
|
||||
#include "sql/monitor/ob_phy_plan_monitor_info.h"
|
||||
#include "sql/engine/ob_exec_context.h"
|
||||
#include "sql/engine/ob_phy_operator.h"
|
||||
#include "sql/engine/ob_physical_plan.h"
|
||||
#include "observer/ob_inner_sql_result.h"
|
||||
#include "sql/ob_sql.h"
|
||||
using namespace oceanbase::common;
|
||||
using namespace oceanbase::observer;
|
||||
namespace oceanbase {
|
||||
namespace sql {
|
||||
template <class T>
|
||||
int ObExecStatCollector::add_stat(const T* value)
|
||||
namespace oceanbase
|
||||
{
|
||||
namespace sql
|
||||
{
|
||||
template<class T>
|
||||
int ObExecStatCollector::add_stat(const T *value)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_ISNULL(value)) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argument", K(ret), K(value));
|
||||
} else if (OB_FAIL(serialization::encode_vi32(extend_buf_, MAX_STAT_BUF_COUNT, length_, value->get_type()))) {
|
||||
} else if (OB_FAIL(serialization::encode_vi32(
|
||||
extend_buf_, MAX_STAT_BUF_COUNT, length_, value->get_type()))) {
|
||||
LOG_WARN("fail to encode type", K(ret), K(value));
|
||||
} else if (OB_FAIL(value->serialize(extend_buf_, MAX_STAT_BUF_COUNT, length_))) {
|
||||
LOG_WARN("fail to serialize value", K(ret), K(value));
|
||||
@ -38,12 +40,12 @@ int ObExecStatCollector::add_stat(const T* value)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObExecStatCollector::add_raw_stat(const common::ObString& str)
|
||||
int ObExecStatCollector::add_raw_stat(const common::ObString &str)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (length_ + str.length() >= MAX_STAT_BUF_COUNT) {
|
||||
ret = OB_BUF_NOT_ENOUGH;
|
||||
LOG_DEBUG("buffer size not enough", K(ret), K(length_), K(str.length()));
|
||||
LOG_DEBUG("buffer size not enough", K(ret),K(length_), K(str.length()));
|
||||
} else {
|
||||
MEMCPY(extend_buf_ + length_, str.ptr(), str.length());
|
||||
length_ += str.length();
|
||||
@ -51,7 +53,7 @@ int ObExecStatCollector::add_raw_stat(const common::ObString& str)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObExecStatCollector::get_extend_info(ObIAllocator& allocator, ObString& str)
|
||||
int ObExecStatCollector::get_extend_info(ObIAllocator &allocator, ObString &str)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
const ObString tmp_str(length_, extend_buf_);
|
||||
@ -65,15 +67,16 @@ void ObExecStatCollector::reset()
|
||||
length_ = 0;
|
||||
}
|
||||
|
||||
int ObExecStatCollector::collect_plan_monitor_info(
|
||||
uint64_t job_id, uint64_t task_id, ObPhyPlanMonitorInfo* monitor_info)
|
||||
int ObExecStatCollector::collect_plan_monitor_info(uint64_t job_id,
|
||||
uint64_t task_id,
|
||||
ObPhyPlanMonitorInfo *monitor_info)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_ISNULL(monitor_info)) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
SQL_MONITOR_LOG(WARN, "invalid argument", K(ret), K(monitor_info));
|
||||
} else {
|
||||
ObPhyOperatorMonitorInfo* op_info = NULL;
|
||||
ObPhyOperatorMonitorInfo *op_info = NULL;
|
||||
for (int64_t i = 0; i < monitor_info->get_operator_count() && OB_SUCC(ret); i++) {
|
||||
if (OB_FAIL(monitor_info->get_operator_info_by_index(i, op_info))) {
|
||||
SQL_MONITOR_LOG(WARN, "fail to get operator info by index", K(ret), K(i));
|
||||
@ -93,7 +96,9 @@ int ObExecStatCollector::collect_plan_monitor_info(
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObExecStatCollector::collect_monitor_info(uint64_t job_id, uint64_t task_id, ObPhyOperatorMonitorInfo& op_info)
|
||||
int ObExecStatCollector::collect_monitor_info(uint64_t job_id,
|
||||
uint64_t task_id,
|
||||
ObPhyOperatorMonitorInfo &op_info)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_FAIL(op_info.set_job_id(job_id))) {
|
||||
@ -108,34 +113,38 @@ int ObExecStatCollector::collect_monitor_info(uint64_t job_id, uint64_t task_id,
|
||||
return ret;
|
||||
}
|
||||
//////////////////////////////////////
|
||||
int ObExecStatDispatch::set_extend_info(const ObString& stat_buf)
|
||||
int ObExecStatDispatch::set_extend_info(const ObString &stat_buf)
|
||||
{
|
||||
stat_str_.assign_ptr(stat_buf.ptr(), stat_buf.length());
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
int ObExecStatDispatch::dispatch(
|
||||
bool need_add_monitor, ObPhyPlanMonitorInfo* monitor_info, bool need_update_plan, ObPhysicalPlan* plan)
|
||||
int ObExecStatDispatch::dispatch(bool need_add_monitor,
|
||||
ObPhyPlanMonitorInfo *monitor_info,
|
||||
bool need_update_plan,
|
||||
ObPhysicalPlan *plan)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
StatType type = OB_INVALID_STAT_TYPE;
|
||||
if ((need_add_monitor && OB_ISNULL(monitor_info)) || OB_ISNULL(plan)) {
|
||||
if ((need_add_monitor && OB_ISNULL(monitor_info))
|
||||
|| OB_ISNULL(plan)) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argument", K(ret), K(monitor_info), K(plan));
|
||||
}
|
||||
while (OB_SUCC(ret) && OB_SUCC(get_next_type(type))) {
|
||||
switch (type) {
|
||||
case PLAN_MONITOR_INFO: {
|
||||
ObPhyOperatorMonitorInfo op_info;
|
||||
if (OB_FAIL(get_value<ObPhyOperatorMonitorInfo>(&op_info))) {
|
||||
LOG_WARN("fail to get value", K(ret));
|
||||
} else if (need_add_monitor && OB_FAIL(monitor_info->add_operator_info(op_info))) {
|
||||
LOG_WARN("fail to add operator info", K(ret), K(op_info));
|
||||
} else if (need_update_plan && OB_FAIL(plan->op_stats_.add_op_stat(op_info))) {
|
||||
LOG_WARN("fail to add operatgor info", K(ret), K(op_info));
|
||||
case PLAN_MONITOR_INFO:
|
||||
{
|
||||
ObPhyOperatorMonitorInfo op_info;
|
||||
if (OB_FAIL(get_value<ObPhyOperatorMonitorInfo>(&op_info))) {
|
||||
LOG_WARN("fail to get value", K(ret));
|
||||
} else if (need_add_monitor && OB_FAIL(monitor_info->add_operator_info(op_info))) {
|
||||
LOG_WARN("fail to add operator info", K(ret), K(op_info));
|
||||
} else if (need_update_plan && OB_FAIL(plan->op_stats_.add_op_stat(op_info))) {
|
||||
LOG_WARN("fail to add operatgor info", K(ret), K(op_info));
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
ret = OB_UNKNOWN_OBJ;
|
||||
LOG_WARN("unknown type", K(ret), K(type));
|
||||
@ -148,7 +157,7 @@ int ObExecStatDispatch::dispatch(
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObExecStatDispatch::get_next_type(StatType& type)
|
||||
int ObExecStatDispatch::get_next_type(StatType &type)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int32_t type_value = 0;
|
||||
@ -161,8 +170,8 @@ int ObExecStatDispatch::get_next_type(StatType& type)
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
template <class T>
|
||||
int ObExecStatDispatch::get_value(T* value)
|
||||
template<class T>
|
||||
int ObExecStatDispatch::get_value(T *value)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_ISNULL(value)) {
|
||||
@ -174,5 +183,5 @@ int ObExecStatDispatch::get_value(T* value)
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // namespace sql
|
||||
} // namespace oceanbase
|
||||
}/* ns sql*/
|
||||
}/* ns oceanbase */
|
||||
|
||||
@ -19,33 +19,38 @@
|
||||
#include "sql/monitor/ob_phy_operator_monitor_info.h"
|
||||
#include "sql/monitor/ob_exec_stat.h"
|
||||
#include "lib/net/ob_addr.h"
|
||||
namespace oceanbase {
|
||||
namespace observer {
|
||||
namespace oceanbase
|
||||
{
|
||||
namespace observer
|
||||
{
|
||||
class ObInnerSQLResult;
|
||||
}
|
||||
namespace sql {
|
||||
namespace sql
|
||||
{
|
||||
class ObExecContext;
|
||||
class ObPhyPlanMonitorInfo;
|
||||
class ObPhyOperatorMonitorInfo;
|
||||
class ObSql;
|
||||
class ObPhysicalPlan;
|
||||
class ObSQLSessionInfo;
|
||||
class ObExecStatCollector {
|
||||
class ObExecStatCollector
|
||||
{
|
||||
public:
|
||||
ObExecStatCollector() : length_(0)
|
||||
{}
|
||||
~ObExecStatCollector()
|
||||
{}
|
||||
int collect_monitor_info(uint64_t job_id, uint64_t task_id, ObPhyOperatorMonitorInfo& op_info);
|
||||
ObExecStatCollector() : length_(0) {}
|
||||
~ObExecStatCollector() {}
|
||||
int collect_monitor_info(uint64_t job_id,
|
||||
uint64_t task_id,
|
||||
ObPhyOperatorMonitorInfo &op_info);
|
||||
|
||||
int collect_plan_monitor_info(uint64_t job_id, uint64_t task_id, ObPhyPlanMonitorInfo* monitor_info);
|
||||
int add_raw_stat(const common::ObString& str);
|
||||
int get_extend_info(common::ObIAllocator& allocator, common::ObString& str);
|
||||
int collect_plan_monitor_info(uint64_t job_id,
|
||||
uint64_t task_id,
|
||||
ObPhyPlanMonitorInfo *monitor_info);
|
||||
int add_raw_stat(const common::ObString &str);
|
||||
int get_extend_info(common::ObIAllocator &allocator, common::ObString &str);
|
||||
void reset();
|
||||
|
||||
private:
|
||||
template <class T>
|
||||
int add_stat(const T* value);
|
||||
template<class T>
|
||||
int add_stat(const T *value);
|
||||
|
||||
/* functions */
|
||||
DISALLOW_COPY_AND_ASSIGN(ObExecStatCollector);
|
||||
@ -54,17 +59,21 @@ private:
|
||||
int64_t length_;
|
||||
};
|
||||
|
||||
class ObExecStatDispatch {
|
||||
class ObExecStatDispatch
|
||||
{
|
||||
public:
|
||||
ObExecStatDispatch() : stat_str_(), pos_(0){};
|
||||
~ObExecStatDispatch(){};
|
||||
int set_extend_info(const common::ObString& str);
|
||||
int dispatch(bool need_add_monitor, ObPhyPlanMonitorInfo* monitor_info, bool need_update_plan, ObPhysicalPlan* plan);
|
||||
|
||||
~ObExecStatDispatch() {};
|
||||
int set_extend_info(const common::ObString &str);
|
||||
//负责将字符串解析成正常数据结构;
|
||||
int dispatch(bool need_add_monitor,
|
||||
ObPhyPlanMonitorInfo *monitor_info,
|
||||
bool need_update_plan,
|
||||
ObPhysicalPlan *plan);
|
||||
private:
|
||||
int get_next_type(StatType& type);
|
||||
template <class T>
|
||||
int get_value(T* value);
|
||||
int get_next_type(StatType &type);
|
||||
template<class T>
|
||||
int get_value(T *value);
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ObExecStatDispatch);
|
||||
@ -72,38 +81,37 @@ private:
|
||||
int64_t pos_;
|
||||
};
|
||||
|
||||
class ObExecStatUtils {
|
||||
class ObExecStatUtils
|
||||
{
|
||||
public:
|
||||
template <class T>
|
||||
OB_INLINE static void record_exec_timestamp(const T& process,
|
||||
bool is_first, // fir execution, not retry
|
||||
ObExecTimestamp& exec_timestamp)
|
||||
{
|
||||
exec_timestamp.rpc_send_ts_ = process.get_send_timestamp();
|
||||
exec_timestamp.receive_ts_ = process.get_receive_timestamp();
|
||||
exec_timestamp.enter_queue_ts_ = process.get_enqueue_timestamp();
|
||||
exec_timestamp.run_ts_ = process.get_run_timestamp();
|
||||
exec_timestamp.before_process_ts_ = process.get_process_timestamp();
|
||||
exec_timestamp.single_process_ts_ = process.get_single_process_timestamp();
|
||||
exec_timestamp.process_executor_ts_ = process.get_exec_start_timestamp();
|
||||
exec_timestamp.executor_end_ts_ = process.get_exec_end_timestamp();
|
||||
OB_INLINE static void record_exec_timestamp(const T &process,
|
||||
bool is_first, //是否是第一次执行时记录,而不是retry
|
||||
ObExecTimestamp &exec_timestamp)
|
||||
{
|
||||
exec_timestamp.rpc_send_ts_ = process.get_send_timestamp();
|
||||
exec_timestamp.receive_ts_ = process.get_receive_timestamp();
|
||||
exec_timestamp.enter_queue_ts_ = process.get_enqueue_timestamp();
|
||||
exec_timestamp.run_ts_ = process.get_run_timestamp();
|
||||
exec_timestamp.before_process_ts_ = process.get_process_timestamp();
|
||||
exec_timestamp.single_process_ts_ = process.get_single_process_timestamp();
|
||||
exec_timestamp.process_executor_ts_ = process.get_exec_start_timestamp();
|
||||
exec_timestamp.executor_end_ts_ = process.get_exec_end_timestamp();
|
||||
|
||||
if (is_first) {
|
||||
/* packet event order:
|
||||
* send -> receive -> enter_queue -> run -> before_process -> single process -> executor
|
||||
*/
|
||||
exec_timestamp.net_t_ = exec_timestamp.receive_ts_ - exec_timestamp.rpc_send_ts_;
|
||||
exec_timestamp.net_wait_t_ = exec_timestamp.enter_queue_ts_ - exec_timestamp.receive_ts_;
|
||||
}
|
||||
// SQL_MONITOR_LOG(DEBUG, "set exec timestamp", K(exec_timestamp.exec_type_),
|
||||
// K(exec_timestamp.before_process_ts_),
|
||||
// K(exec_timestamp.process_executor_ts_),
|
||||
// K(exec_timestamp.executor_end_ts_),
|
||||
// K(exec_timestamp.receive_ts_),
|
||||
// K(exec_timestamp.enter_queue_ts_),
|
||||
// K(exec_timestamp.run_ts_),
|
||||
// K(exec_timestamp.single_process_ts_));
|
||||
}
|
||||
if (is_first) {
|
||||
/* packet 遇见的事件顺序:
|
||||
* send -> receive -> enter_queue -> run -> before_process -> single_process -> executor_start -> executor_end
|
||||
* multistmt 场景特殊处理,第二个及之后的 sql 的 net_t、net_wait_ 均为 0
|
||||
*/
|
||||
if (OB_UNLIKELY(exec_timestamp.multistmt_start_ts_ > 0)) {
|
||||
exec_timestamp.net_t_ = 0;
|
||||
exec_timestamp.net_wait_t_ = 0;
|
||||
} else {
|
||||
exec_timestamp.net_t_ = exec_timestamp.receive_ts_ - exec_timestamp.rpc_send_ts_;
|
||||
exec_timestamp.net_wait_t_ = exec_timestamp.enter_queue_ts_ - exec_timestamp.receive_ts_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ObExecStatUtils);
|
||||
@ -111,7 +119,7 @@ private:
|
||||
~ObExecStatUtils();
|
||||
};
|
||||
|
||||
} // namespace sql
|
||||
} // namespace oceanbase
|
||||
}
|
||||
}
|
||||
#endif /* OCEANBASE_COMMON_STAT_OB_EXEC_STAT_COLLECTOR_H_ */
|
||||
//// end of header file
|
||||
|
||||
@ -12,26 +12,27 @@
|
||||
|
||||
#ifndef OCEANBASE_SQL_OB_I_COLLECT_VALUE_H
|
||||
#define OCEANBASE_SQL_OB_I_COLLECT_VALUE_H
|
||||
namespace oceanbase {
|
||||
namespace sql {
|
||||
enum StatType { OB_INVALID_STAT_TYPE = 0, PLAN_MONITOR_INFO };
|
||||
namespace oceanbase
|
||||
{
|
||||
namespace sql
|
||||
{
|
||||
enum StatType
|
||||
{
|
||||
OB_INVALID_STAT_TYPE = 0,
|
||||
PLAN_MONITOR_INFO
|
||||
};
|
||||
|
||||
class ObIValue {
|
||||
class ObIValue
|
||||
{
|
||||
public:
|
||||
explicit ObIValue(StatType type)
|
||||
{
|
||||
value_type_ = type;
|
||||
}
|
||||
virtual ~ObIValue()
|
||||
{}
|
||||
StatType get_type() const
|
||||
{
|
||||
return value_type_;
|
||||
}
|
||||
|
||||
explicit ObIValue(StatType type) { value_type_ = type; }
|
||||
virtual ~ObIValue() {}
|
||||
StatType get_type()const { return value_type_; }
|
||||
protected:
|
||||
StatType value_type_;
|
||||
};
|
||||
} // namespace sql
|
||||
} // namespace oceanbase
|
||||
} //namespace sql
|
||||
} //namespace oceanbase
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@ -12,9 +12,11 @@
|
||||
|
||||
#include "sql/monitor/ob_monitor_info_elimination_task.h"
|
||||
#include "sql/monitor/ob_monitor_info_manager.h"
|
||||
namespace oceanbase {
|
||||
namespace sql {
|
||||
int ObMonitorInfoEliminationTask::init(ObMonitorInfoManager* info)
|
||||
namespace oceanbase
|
||||
{
|
||||
namespace sql
|
||||
{
|
||||
int ObMonitorInfoEliminationTask::init(ObMonitorInfoManager *info)
|
||||
{
|
||||
int ret = common::OB_SUCCESS;
|
||||
if (OB_ISNULL(info)) {
|
||||
@ -34,5 +36,7 @@ void ObMonitorInfoEliminationTask::runTimerTask()
|
||||
monitor_info_->gc();
|
||||
}
|
||||
}
|
||||
} // namespace sql
|
||||
} // namespace oceanbase
|
||||
} //namespace sql
|
||||
} //namespace oceanbase
|
||||
|
||||
|
||||
|
||||
@ -13,25 +13,26 @@
|
||||
#ifndef OCEANBASE_SQL_OB_MONITOR_INFO_ELIMINATION_TASK_H
|
||||
#define OCEANBASE_SQL_OB_MONITOR_INFO_ELIMINATION_TASK_H
|
||||
#include "lib/task/ob_timer.h"
|
||||
namespace oceanbase {
|
||||
namespace sql {
|
||||
namespace oceanbase
|
||||
{
|
||||
namespace sql
|
||||
{
|
||||
class ObMonitorInfoManager;
|
||||
class ObMonitorInfoEliminationTask : public common::ObTimerTask {
|
||||
class ObMonitorInfoEliminationTask : public common::ObTimerTask
|
||||
{
|
||||
public:
|
||||
ObMonitorInfoEliminationTask() : monitor_info_(NULL)
|
||||
{}
|
||||
~ObMonitorInfoEliminationTask()
|
||||
{}
|
||||
int init(ObMonitorInfoManager* monitor_info);
|
||||
ObMonitorInfoEliminationTask() : monitor_info_(NULL) {}
|
||||
~ObMonitorInfoEliminationTask() {}
|
||||
int init(ObMonitorInfoManager *monitor_info);
|
||||
virtual void runTimerTask();
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ObMonitorInfoEliminationTask);
|
||||
|
||||
private:
|
||||
ObMonitorInfoManager* monitor_info_;
|
||||
ObMonitorInfoManager *monitor_info_;
|
||||
};
|
||||
|
||||
} // namespace sql
|
||||
} // namespace oceanbase
|
||||
} //namespace sql
|
||||
} //namespace oceanbase
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@ -14,19 +14,18 @@
|
||||
#include "sql/monitor/ob_monitor_info_manager.h"
|
||||
#include "sql/monitor/ob_phy_plan_monitor_info.h"
|
||||
using namespace oceanbase::common;
|
||||
namespace oceanbase {
|
||||
namespace sql {
|
||||
namespace oceanbase
|
||||
{
|
||||
namespace sql
|
||||
{
|
||||
ObMonitorInfoManager::ObMonitorInfoManager()
|
||||
: allocator_(),
|
||||
slow_query_queue_(),
|
||||
timer_(),
|
||||
elimination_task_(),
|
||||
plan_execution_time_map_(),
|
||||
max_push_interval_(OB_MAX_PUSH_INTERVAL),
|
||||
operator_info_size_(0)
|
||||
: allocator_(), slow_query_queue_(), timer_(), elimination_task_(),
|
||||
plan_execution_time_map_(), max_push_interval_(OB_MAX_PUSH_INTERVAL),
|
||||
operator_info_size_(0)
|
||||
{
|
||||
memory_limit_ = min(
|
||||
MAX_MEMORY_SIZE, static_cast<int64_t>(static_cast<double>(GCONF.get_server_memory_avail()) * MONITOR_MEM_FACTOR));
|
||||
MAX_MEMORY_SIZE,
|
||||
static_cast<int64_t>(static_cast<double>(GCONF.get_server_memory_avail()) * MONITOR_MEM_FACTOR));
|
||||
}
|
||||
|
||||
ObMonitorInfoManager::~ObMonitorInfoManager()
|
||||
@ -44,7 +43,7 @@ int ObMonitorInfoManager::init()
|
||||
LOG_WARN("fail to init history info", K(ret));
|
||||
} else if (OB_FAIL(timer_.init("MonInfoEvict"))) {
|
||||
LOG_WARN("fail to init timer", K(ret));
|
||||
} else if (OB_FAIL(elimination_task_.init(this))) {
|
||||
} else if (OB_FAIL(elimination_task_.init(this))){
|
||||
LOG_WARN("fail to init elimination task", K(ret));
|
||||
} else if (OB_FAIL(plan_execution_time_map_.init(ObModIds::OB_SQL_PLAN_MONITOR))) {
|
||||
LOG_WARN("fail to init plan execution time map", K(ret));
|
||||
@ -66,8 +65,10 @@ void ObMonitorInfoManager::destroy()
|
||||
allocator_.destroy();
|
||||
}
|
||||
|
||||
int ObMonitorInfoManager::get_by_request_id(
|
||||
int64_t request_id, int64_t& index, ObPhyPlanMonitorInfo*& plan_info, Ref* ref)
|
||||
int ObMonitorInfoManager::get_by_request_id(int64_t request_id,
|
||||
int64_t &index,
|
||||
ObPhyPlanMonitorInfo *&plan_info,
|
||||
Ref* ref)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
index = -1;
|
||||
@ -77,7 +78,7 @@ int ObMonitorInfoManager::get_by_request_id(
|
||||
} else {
|
||||
int64_t start_idx = slow_query_queue_.get_pop_idx();
|
||||
int64_t end_idx = slow_query_queue_.get_push_idx();
|
||||
void* tmp_info = NULL;
|
||||
void *tmp_info = NULL;
|
||||
ret = OB_ERROR;
|
||||
for (int64_t i = start_idx; i <= end_idx && OB_ERROR == ret; i++) {
|
||||
if (NULL == (tmp_info = slow_query_queue_.get(i, ref))) {
|
||||
@ -96,7 +97,9 @@ int ObMonitorInfoManager::get_by_request_id(
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObMonitorInfoManager::get_by_index(int64_t index, ObPhyPlanMonitorInfo*& plan_info, Ref* ref)
|
||||
int ObMonitorInfoManager::get_by_index(int64_t index,
|
||||
ObPhyPlanMonitorInfo *&plan_info,
|
||||
Ref* ref)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
plan_info = NULL;
|
||||
@ -111,7 +114,7 @@ int ObMonitorInfoManager::get_by_index(int64_t index, ObPhyPlanMonitorInfo*& pla
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObMonitorInfoManager::is_info_nearly_duplicated(const ObAddr& addr, int64_t plan_id, bool& is_duplicated)
|
||||
int ObMonitorInfoManager::is_info_nearly_duplicated(const ObAddr &addr, int64_t plan_id, bool &is_duplicated)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
is_duplicated = false;
|
||||
@ -136,7 +139,7 @@ int ObMonitorInfoManager::is_info_nearly_duplicated(const ObAddr& addr, int64_t
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObMonitorInfoManager::add_monitor_info(ObPhyPlanMonitorInfo* info)
|
||||
int ObMonitorInfoManager::add_monitor_info(ObPhyPlanMonitorInfo *info)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_ISNULL(info)) {
|
||||
@ -145,7 +148,7 @@ int ObMonitorInfoManager::add_monitor_info(ObPhyPlanMonitorInfo* info)
|
||||
} else {
|
||||
int64_t retry_times = 3;
|
||||
while (retry_times > 0) {
|
||||
retry_times--;
|
||||
retry_times --;
|
||||
int64_t req_id = 0;
|
||||
if (OB_FAIL(slow_query_queue_.push((void*)info, req_id))) {
|
||||
if (OB_SIZE_OVERFLOW == ret) {
|
||||
@ -169,31 +172,32 @@ int ObMonitorInfoManager::add_monitor_info(ObPhyPlanMonitorInfo* info)
|
||||
void ObMonitorInfoManager::clear_queue(int64_t limit)
|
||||
{
|
||||
int64_t pop_cnt = 0;
|
||||
ObPhyPlanMonitorInfo* poped = NULL;
|
||||
while (pop_cnt++ < limit && NULL != (poped = (ObPhyPlanMonitorInfo*)slow_query_queue_.pop())) {
|
||||
ObPhyPlanMonitorInfo *poped = NULL;
|
||||
while(pop_cnt++ < limit && NULL != (poped = (ObPhyPlanMonitorInfo*)slow_query_queue_.pop())) {
|
||||
operator_info_size_ -= poped->get_operator_info_memory_size();
|
||||
poped->destroy();
|
||||
}
|
||||
}
|
||||
|
||||
int ObMonitorInfoManager::alloc(int64_t request_id, ObPhyPlanMonitorInfo*& info)
|
||||
int ObMonitorInfoManager::alloc(int64_t request_id,
|
||||
ObPhyPlanMonitorInfo *&info)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
void* ptr = NULL;
|
||||
void *ptr = NULL;
|
||||
if (OB_UNLIKELY(request_id < 0)) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid agument", K(ret), K(request_id));
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid agument", K(ret), K(request_id));
|
||||
} else if (OB_ISNULL(ptr = allocator_.alloc(sizeof(ObPhyPlanMonitorInfo)))) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_ERROR("fail to alloc memory", K(ret), K(request_id), K(allocator_.allocated()), K_(memory_limit));
|
||||
} else {
|
||||
info = new (ptr) ObPhyPlanMonitorInfo(allocator_);
|
||||
info = new(ptr) ObPhyPlanMonitorInfo(allocator_);
|
||||
info->set_request_id(request_id);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObMonitorInfoManager::free(ObPhyPlanMonitorInfo*& info)
|
||||
int ObMonitorInfoManager::free(ObPhyPlanMonitorInfo *&info)
|
||||
{
|
||||
if (OB_ISNULL(info)) {
|
||||
} else {
|
||||
@ -224,7 +228,7 @@ int ObMonitorInfoManager::gc()
|
||||
int64_t pop_count = 3;
|
||||
while (mem_limit / 2 < allocator_.allocated() + operator_info_size_ && pop_count > 0) {
|
||||
clear_queue(OB_BATCH_GC_COUNT);
|
||||
pop_count--;
|
||||
pop_count --;
|
||||
}
|
||||
}
|
||||
if (OB_FAIL(reclain_map())) {
|
||||
@ -232,5 +236,7 @@ int ObMonitorInfoManager::gc()
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
} // namespace sql
|
||||
} // namespace oceanbase
|
||||
} //namespace sql
|
||||
} //namespace oceanbase
|
||||
|
||||
|
||||
|
||||
@ -18,33 +18,36 @@
|
||||
#include "lib/allocator/ob_concurrent_fifo_allocator.h"
|
||||
#include "sql/monitor/ob_monitor_info_elimination_task.h"
|
||||
#include "observer/mysql/ob_mysql_request_manager.h"
|
||||
namespace oceanbase {
|
||||
namespace sql {
|
||||
struct PlanKey {
|
||||
namespace oceanbase
|
||||
{
|
||||
namespace sql
|
||||
{
|
||||
struct PlanKey
|
||||
{
|
||||
uint64_t hash() const
|
||||
{
|
||||
uint64_t value = 0;
|
||||
value = murmurhash(&plan_id_, sizeof(plan_id_), value);
|
||||
value = murmurhash(&addr_, sizeof(addr_), value);
|
||||
value = murmurhash(&plan_id_, sizeof(plan_id_), value);
|
||||
value = murmurhash(&addr_, sizeof(addr_), value);
|
||||
return value;
|
||||
}
|
||||
bool operator==(const PlanKey& other) const
|
||||
{
|
||||
return (plan_id_ == other.plan_id_) && (addr_ == other.addr_);
|
||||
}
|
||||
bool operator==(const PlanKey &other) const { return (plan_id_ == other.plan_id_) && (addr_ == other.addr_); }
|
||||
int64_t plan_id_;
|
||||
common::ObAddr addr_;
|
||||
};
|
||||
class ObMonitorInfoManager {
|
||||
class ObMonitorInfoManager
|
||||
{
|
||||
friend class TestMonitorInfoManager_tets_duplicated_Test;
|
||||
struct ReclainCond {
|
||||
public:
|
||||
ReclainCond(int64_t curr_timestamp, int64_t max_remain_interval)
|
||||
: curr_timestamp_(curr_timestamp), max_remain_interval_(max_remain_interval)
|
||||
ReclainCond(int64_t curr_timestamp,
|
||||
int64_t max_remain_interval)
|
||||
: curr_timestamp_(curr_timestamp),
|
||||
max_remain_interval_(max_remain_interval)
|
||||
{}
|
||||
int64_t curr_timestamp_;
|
||||
int64_t max_remain_interval_;
|
||||
bool operator()(const PlanKey& plan_id, int64_t& execution_time)
|
||||
bool operator()(const PlanKey &plan_id, int64_t &execution_time)
|
||||
{
|
||||
UNUSED(plan_id);
|
||||
bool bret = false;
|
||||
@ -56,44 +59,32 @@ class ObMonitorInfoManager {
|
||||
}
|
||||
};
|
||||
typedef common::ObRaQueue::Ref Ref;
|
||||
|
||||
public:
|
||||
ObMonitorInfoManager();
|
||||
~ObMonitorInfoManager();
|
||||
int init();
|
||||
void destroy();
|
||||
int get_by_request_id(int64_t request_id, int64_t& index, ObPhyPlanMonitorInfo*& plan_info, Ref* ref);
|
||||
int get_by_index(int64_t index, ObPhyPlanMonitorInfo*& plan_info, Ref* ref);
|
||||
int get_by_request_id(int64_t request_id, int64_t &index, ObPhyPlanMonitorInfo *&plan_info, Ref* ref);
|
||||
int get_by_index(int64_t index, ObPhyPlanMonitorInfo *&plan_info, Ref* ref);
|
||||
int revert(Ref* req)
|
||||
{
|
||||
slow_query_queue_.revert(req);
|
||||
return common::OB_SUCCESS;
|
||||
}
|
||||
int add_monitor_info(ObPhyPlanMonitorInfo* plan_info);
|
||||
int alloc(int64_t request_id, ObPhyPlanMonitorInfo*& plan_info);
|
||||
int free(ObPhyPlanMonitorInfo*& plan_info);
|
||||
int64_t get_start_index()
|
||||
{
|
||||
return slow_query_queue_.get_pop_idx();
|
||||
}
|
||||
int64_t get_size()
|
||||
{
|
||||
return slow_query_queue_.get_size();
|
||||
}
|
||||
int64_t get_count()
|
||||
{
|
||||
return slow_query_queue_.get_size();
|
||||
}
|
||||
int is_info_nearly_duplicated(const common::ObAddr& addr, int64_t plan_id, bool& is_duplicated);
|
||||
int add_monitor_info(ObPhyPlanMonitorInfo *plan_info);
|
||||
int alloc(int64_t request_id, ObPhyPlanMonitorInfo *&plan_info);
|
||||
int free(ObPhyPlanMonitorInfo *&plan_info);
|
||||
int64_t get_start_index() { return slow_query_queue_.get_pop_idx(); }
|
||||
int64_t get_size() { return slow_query_queue_.get_size(); }
|
||||
int64_t get_count() { return slow_query_queue_.get_size(); }
|
||||
int is_info_nearly_duplicated(const common::ObAddr &addr, int64_t plan_id, bool &is_duplicated);
|
||||
void print_memory_size()
|
||||
{
|
||||
SQL_MONITOR_LOG(INFO,
|
||||
"print memory size, ",
|
||||
K(get_start_index()),
|
||||
K(get_size()),
|
||||
K(allocator_.allocated()),
|
||||
K(allocator_.hold()),
|
||||
K(operator_info_size_));
|
||||
SQL_MONITOR_LOG(INFO, "print memory size, ", K(get_start_index()),
|
||||
K(get_size()),
|
||||
K(allocator_. allocated()),
|
||||
K(allocator_.hold()),
|
||||
K(operator_info_size_));
|
||||
}
|
||||
int gc();
|
||||
static const int64_t OB_MAX_QUEUE_SIZE = 100000;
|
||||
@ -101,28 +92,24 @@ public:
|
||||
static const int64_t PAGE_SIZE = common::OB_MALLOC_BIG_BLOCK_SIZE;
|
||||
static const int64_t OB_BATCH_GC_COUNT = 2000;
|
||||
static const int64_t OB_MAX_PUSH_INTERVAL = 10 * 1000 * 1000;
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ObMonitorInfoManager);
|
||||
void clear_queue(int64_t limit);
|
||||
int reclain_map();
|
||||
void set_max_push_interval(int64_t time)
|
||||
{
|
||||
max_push_interval_ = time;
|
||||
}
|
||||
|
||||
void set_max_push_interval(int64_t time) { max_push_interval_ = time; }
|
||||
private:
|
||||
common::ObConcurrentFIFOAllocator allocator_;
|
||||
common::ObRaQueue slow_query_queue_;
|
||||
common::ObTimer timer_; // for timing task for cleaning data.
|
||||
common::ObTimer timer_; //定时器,启动定时任务淘汰旧数据;
|
||||
ObMonitorInfoEliminationTask elimination_task_;
|
||||
common::ObLinearHashMap<PlanKey, int64_t> plan_execution_time_map_; // last execution time of plan.
|
||||
common::ObLinearHashMap<PlanKey, int64_t> plan_execution_time_map_; //记录每个plan最近一次执行的时间戳
|
||||
int64_t max_push_interval_;
|
||||
int64_t memory_limit_;
|
||||
int64_t operator_info_size_; // the memory of operator_infos_ need stat separately,
|
||||
// because it is not alloced from allocator.
|
||||
int64_t operator_info_size_; // ObPhyPlanMonitorInfo中operator_infos_的内存不在allocator中,单独统计
|
||||
};
|
||||
|
||||
} // namespace sql
|
||||
} // namespace oceanbase
|
||||
} //namespace sql
|
||||
} //namespace oceanbase
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@ -18,16 +18,22 @@
|
||||
|
||||
using namespace oceanbase::common;
|
||||
using namespace oceanbase::share;
|
||||
namespace oceanbase {
|
||||
namespace sql {
|
||||
ObPhyOperatorMonitorInfo::ObPhyOperatorMonitorInfo()
|
||||
: ObIValue(PLAN_MONITOR_INFO), op_id_(-1), job_id_(0), task_id_(0), op_type_(PHY_INVALID)
|
||||
namespace oceanbase
|
||||
{
|
||||
memset(info_array_, 0, OB_MAX_INFORMATION_COUNT * sizeof(int64_t));
|
||||
namespace sql
|
||||
{
|
||||
ObPhyOperatorMonitorInfo::ObPhyOperatorMonitorInfo() : ObIValue(PLAN_MONITOR_INFO),
|
||||
op_id_(-1),
|
||||
job_id_(0),
|
||||
task_id_(0),
|
||||
op_type_(PHY_INVALID)
|
||||
{
|
||||
memset(info_array_, 0, OB_MAX_INFORMATION_COUNT * sizeof(int64_t));
|
||||
}
|
||||
|
||||
ObPhyOperatorMonitorInfo::~ObPhyOperatorMonitorInfo()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
int ObPhyOperatorMonitorInfo::set_operator_id(int64_t op_id)
|
||||
{
|
||||
@ -65,7 +71,7 @@ int ObPhyOperatorMonitorInfo::set_task_id(int64_t task_id)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObPhyOperatorMonitorInfo::assign(const ObPhyOperatorMonitorInfo& other)
|
||||
int ObPhyOperatorMonitorInfo::assign(const ObPhyOperatorMonitorInfo &other)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
op_id_ = other.op_id_;
|
||||
@ -78,30 +84,30 @@ int ObPhyOperatorMonitorInfo::assign(const ObPhyOperatorMonitorInfo& other)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ObPhyOperatorMonitorInfo::operator=(const ObPhyOperatorMonitorInfo& other)
|
||||
void ObPhyOperatorMonitorInfo::operator=(const ObPhyOperatorMonitorInfo &other)
|
||||
{
|
||||
if (OB_SUCCESS != assign(other)) {
|
||||
LOG_ERROR("fail to assign", K(&other));
|
||||
}
|
||||
}
|
||||
|
||||
ObPhyOperatorMonitorInfo::ObPhyOperatorMonitorInfo(const ObPhyOperatorMonitorInfo& other)
|
||||
: ObIValue(PLAN_MONITOR_INFO),
|
||||
op_id_(other.op_id_),
|
||||
job_id_(other.job_id_),
|
||||
task_id_(other.task_id_),
|
||||
op_type_(other.op_type_)
|
||||
ObPhyOperatorMonitorInfo::ObPhyOperatorMonitorInfo(const ObPhyOperatorMonitorInfo &other)
|
||||
: ObIValue(PLAN_MONITOR_INFO), op_id_(other.op_id_),
|
||||
job_id_(other.job_id_), task_id_(other.task_id_), op_type_(other.op_type_)
|
||||
{
|
||||
for (int64_t i = 0; i < OB_MAX_INFORMATION_COUNT; i++) {
|
||||
info_array_[i] = other.info_array_[i];
|
||||
}
|
||||
}
|
||||
|
||||
int64_t ObPhyOperatorMonitorInfo::to_string(char* buf, int64_t buf_len) const
|
||||
int64_t ObPhyOperatorMonitorInfo::to_string(char *buf, int64_t buf_len) const
|
||||
{
|
||||
int64_t pos = 0;
|
||||
J_OBJ_START();
|
||||
J_KV(N_OP_ID, op_id_, N_JOB_ID, job_id_, N_TASK_ID, task_id_, N_OP, op_type_);
|
||||
J_KV(N_OP_ID, op_id_,
|
||||
N_JOB_ID, job_id_,
|
||||
N_TASK_ID, task_id_,
|
||||
N_OP, op_type_);
|
||||
for (int64_t i = 0; i < OB_MAX_INFORMATION_COUNT; i++) {
|
||||
if (info_array_[i] != 0 && NULL != OB_OPERATOR_MONITOR_INFOS[i].info_name_) {
|
||||
J_OBJ_START();
|
||||
@ -117,7 +123,10 @@ int64_t ObPhyOperatorMonitorInfo::to_string(char* buf, int64_t buf_len) const
|
||||
bool ObPhyOperatorMonitorInfo::is_timestamp(int64_t i) const
|
||||
{
|
||||
bool bret = false;
|
||||
if (OPEN_TIME == i || FIRST_ROW_TIME == i || LAST_ROW_TIME == i || CLOSE_TIME == i) {
|
||||
if (OPEN_TIME == i
|
||||
|| FIRST_ROW_TIME == i
|
||||
|| LAST_ROW_TIME == i
|
||||
|| CLOSE_TIME == i) {
|
||||
bret = true;
|
||||
}
|
||||
return bret;
|
||||
@ -166,6 +175,7 @@ void ObPhyOperatorMonitorInfo::set_value(ObOperatorMonitorInfoIds index, int64_t
|
||||
} else {
|
||||
LOG_WARN("invalid index", K(index), K(value));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ObPhyOperatorMonitorInfo::increase_value(ObOperatorMonitorInfoIds index)
|
||||
@ -177,7 +187,7 @@ void ObPhyOperatorMonitorInfo::increase_value(ObOperatorMonitorInfoIds index)
|
||||
}
|
||||
}
|
||||
|
||||
void ObPhyOperatorMonitorInfo::get_value(ObOperatorMonitorInfoIds index, int64_t& value)
|
||||
void ObPhyOperatorMonitorInfo::get_value(ObOperatorMonitorInfoIds index, int64_t &value)
|
||||
{
|
||||
if (index >= 0 && index < OB_MAX_INFORMATION_COUNT) {
|
||||
value = info_array_[index];
|
||||
@ -191,7 +201,7 @@ int64_t ObPhyOperatorMonitorInfo::get_valid_info_count() const
|
||||
int64_t count = 0;
|
||||
for (int64_t i = 0; i < OB_MAX_INFORMATION_COUNT; i++) {
|
||||
if (info_array_[i] != 0) {
|
||||
count++;
|
||||
count ++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
@ -235,6 +245,7 @@ OB_DEF_DESERIALIZE(ObPhyOperatorMonitorInfo)
|
||||
LOG_WARN("fail to decode value", K(ret), K(pos));
|
||||
} else {
|
||||
if (index >= OB_MAX_INFORMATION_COUNT) {
|
||||
//nothing to do, 也许收到一个新版本的统计信息
|
||||
} else if (index < 0) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_ERROR("invalid index", K(index), K(i), K(value), K(ret));
|
||||
@ -264,5 +275,5 @@ OB_DEF_SERIALIZE_SIZE(ObPhyOperatorMonitorInfo)
|
||||
return len;
|
||||
}
|
||||
|
||||
} // namespace sql
|
||||
} // namespace oceanbase
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,74 +29,62 @@ OPERATOR_MONITOR_INFO_DEF(MONITOR_INFO_END, monitor_end)
|
||||
#include "lib/utility/ob_unify_serialize.h"
|
||||
#include "sql/monitor/ob_i_collect_value.h"
|
||||
#include "sql/engine/ob_phy_operator_type.h"
|
||||
namespace oceanbase {
|
||||
namespace sql {
|
||||
struct MonitorName {
|
||||
namespace oceanbase
|
||||
{
|
||||
namespace sql
|
||||
{
|
||||
struct MonitorName
|
||||
{
|
||||
int64_t id_;
|
||||
const char* const info_name_;
|
||||
const char * const info_name_;
|
||||
};
|
||||
enum ObOperatorMonitorInfoIds {
|
||||
enum ObOperatorMonitorInfoIds
|
||||
{
|
||||
#define OPERATOR_MONITOR_INFO_DEF(def, name) def,
|
||||
#include "ob_phy_operator_monitor_info.h"
|
||||
#undef OPERATOR_MONITOR_INFO_DEF
|
||||
};
|
||||
static const MonitorName OB_OPERATOR_MONITOR_INFOS[] = {
|
||||
#define OPERATOR_MONITOR_INFO_DEF(def, name) {def, #name},
|
||||
#define OPERATOR_MONITOR_INFO_DEF(def, name) \
|
||||
{def, #name},
|
||||
#include "ob_phy_operator_monitor_info.h"
|
||||
#undef OPERATOR_MONITOR_INFO_DEF
|
||||
};
|
||||
|
||||
class ObPhyOperatorMonitorInfo : public ObIValue {
|
||||
class ObPhyOperatorMonitorInfo : public ObIValue
|
||||
{
|
||||
OB_UNIS_VERSION(1);
|
||||
|
||||
public:
|
||||
ObPhyOperatorMonitorInfo();
|
||||
virtual ~ObPhyOperatorMonitorInfo();
|
||||
int set_operator_id(int64_t op_id);
|
||||
int set_job_id(int64_t job_id);
|
||||
int set_task_id(int64_t task_id);
|
||||
void set_operator_type(ObPhyOperatorType type)
|
||||
{
|
||||
op_type_ = type;
|
||||
}
|
||||
int64_t get_op_id() const
|
||||
{
|
||||
return op_id_;
|
||||
}
|
||||
int64_t get_job_id() const
|
||||
{
|
||||
return job_id_;
|
||||
}
|
||||
int64_t get_task_id() const
|
||||
{
|
||||
return task_id_;
|
||||
}
|
||||
ObPhyOperatorType get_operator_type() const
|
||||
{
|
||||
return op_type_;
|
||||
}
|
||||
int assign(const ObPhyOperatorMonitorInfo& info);
|
||||
void operator=(const ObPhyOperatorMonitorInfo& other);
|
||||
ObPhyOperatorMonitorInfo(const ObPhyOperatorMonitorInfo& other);
|
||||
int64_t to_string(char* buf, int64_t buf_len) const;
|
||||
virtual int64_t print_info(char* buf, int64_t buf_len) const;
|
||||
void set_operator_type(ObPhyOperatorType type) { op_type_ = type; }
|
||||
int64_t get_op_id() const { return op_id_; }
|
||||
int64_t get_job_id() const { return job_id_; }
|
||||
int64_t get_task_id() const { return task_id_; }
|
||||
ObPhyOperatorType get_operator_type() const { return op_type_; }
|
||||
int assign(const ObPhyOperatorMonitorInfo &info);
|
||||
void operator= (const ObPhyOperatorMonitorInfo&other);
|
||||
ObPhyOperatorMonitorInfo(const ObPhyOperatorMonitorInfo &other);
|
||||
int64_t to_string(char *buf, int64_t buf_len) const;
|
||||
virtual int64_t print_info(char *buf, int64_t buf_len) const;
|
||||
void set_value(ObOperatorMonitorInfoIds index, int64_t value);
|
||||
void get_value(ObOperatorMonitorInfoIds index, int64_t& value);
|
||||
void get_value(ObOperatorMonitorInfoIds index, int64_t &value);
|
||||
void increase_value(ObOperatorMonitorInfoIds index);
|
||||
static const int64_t OB_MAX_INFORMATION_COUNT = MONITOR_INFO_END;
|
||||
|
||||
private:
|
||||
int64_t get_valid_info_count() const;
|
||||
virtual bool is_timestamp(int64_t index) const;
|
||||
|
||||
protected:
|
||||
int64_t op_id_;
|
||||
int64_t job_id_; // Effective in distributed execution plan
|
||||
int64_t task_id_; // Effective in distributed execution plan
|
||||
int64_t job_id_; //在分布式执行计划时有效
|
||||
int64_t task_id_; //在分布式执行计划时有效
|
||||
private:
|
||||
ObPhyOperatorType op_type_;
|
||||
uint64_t info_array_[OB_MAX_INFORMATION_COUNT];
|
||||
};
|
||||
} // namespace sql
|
||||
} // namespace oceanbase
|
||||
} //namespace sql
|
||||
} //namespace oceanbase
|
||||
#endif
|
||||
|
||||
@ -19,22 +19,26 @@
|
||||
#include "lib/atomic/ob_atomic.h"
|
||||
#include "lib/utility/utility.h"
|
||||
using namespace oceanbase::common;
|
||||
namespace oceanbase {
|
||||
namespace sql {
|
||||
int ObPhyOperatorStats::init(ObIAllocator* alloc, int64_t op_count)
|
||||
namespace oceanbase
|
||||
{
|
||||
namespace sql
|
||||
{
|
||||
int ObPhyOperatorStats::init(ObIAllocator *alloc, int64_t op_count)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
void* ptr = NULL;
|
||||
void *ptr = NULL;
|
||||
if (OB_ISNULL(alloc) || OB_UNLIKELY(op_count < 0)) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argument", K(ret), K(alloc), K(op_count));
|
||||
LOG_WARN("invalid argument", K(ret),K(alloc), K(op_count));
|
||||
} else {
|
||||
array_size_ = op_count * StatId::MAX_STAT * COPY_COUNT;
|
||||
//2是为了保存plan_id 和operation_id
|
||||
//没有必须要存operation id , 可以通过下标计算出来
|
||||
if (OB_ISNULL(ptr = alloc->alloc(sizeof(int64_t) * array_size_))) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_ERROR("fail to alloc memory for aray", K(ret), K_(array_size));
|
||||
} else {
|
||||
op_stats_array_ = static_cast<int64_t*>(ptr);
|
||||
op_stats_array_ = static_cast<int64_t *>(ptr);
|
||||
memset(op_stats_array_, 0, sizeof(int64_t) * array_size_);
|
||||
op_count_ = op_count;
|
||||
}
|
||||
@ -57,7 +61,7 @@ int ObPhyOperatorStats::init(ObIAllocator* alloc, int64_t op_count)
|
||||
* COPY = 10
|
||||
*/
|
||||
|
||||
int ObPhyOperatorStats::add_op_stat(ObPhyOperatorMonitorInfo& info)
|
||||
int ObPhyOperatorStats::add_op_stat(ObPhyOperatorMonitorInfo &info)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
const int64_t COPY_SIZE = op_count_ * StatId::MAX_STAT;
|
||||
@ -80,7 +84,9 @@ int ObPhyOperatorStats::add_op_stat(ObPhyOperatorMonitorInfo& info)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObPhyOperatorStats::get_op_stat_accumulation(ObPhysicalPlan* plan, int64_t op_id, ObOperatorStat& stat)
|
||||
int ObPhyOperatorStats::get_op_stat_accumulation(ObPhysicalPlan *plan,
|
||||
int64_t op_id,
|
||||
ObOperatorStat &stat)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_ISNULL(plan)) {
|
||||
@ -101,14 +107,15 @@ int ObPhyOperatorStats::get_op_stat_accumulation(ObPhysicalPlan* plan, int64_t o
|
||||
exec_times = ATOMIC_LOAD(&(execution_times_));
|
||||
stat.init();
|
||||
stat.execute_times_ = exec_times;
|
||||
retry_times--;
|
||||
retry_times --;
|
||||
for (int64_t i = 0; i < COPY_COUNT; i++) {
|
||||
copy_start_index = op_first_index + i * COPY_SIZE;
|
||||
stat.input_rows_ += ATOMIC_LOAD(&(op_stats_array_[copy_start_index + StatId::INPUT_ROWS]));
|
||||
stat.rescan_times_ += ATOMIC_LOAD(&(op_stats_array_[copy_start_index + StatId::RESCAN_TIMES]));
|
||||
stat.rescan_times_ += ATOMIC_LOAD(&(op_stats_array_[copy_start_index +StatId::RESCAN_TIMES]));
|
||||
stat.output_rows_ += ATOMIC_LOAD(&(op_stats_array_[copy_start_index + StatId::OUTPUT_ROWS]));
|
||||
}
|
||||
} while (exec_times != ATOMIC_LOAD(&(execution_times_)) && retry_times > 0);
|
||||
} while (exec_times != ATOMIC_LOAD(&(execution_times_))
|
||||
&& retry_times > 0);
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
stat.operation_id_ = op_id;
|
||||
@ -117,5 +124,5 @@ int ObPhyOperatorStats::get_op_stat_accumulation(ObPhysicalPlan* plan, int64_t o
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
} // namespace sql
|
||||
} // namespace oceanbase
|
||||
} //namespace sql
|
||||
} //namespace oceanbase
|
||||
|
||||
@ -15,50 +15,50 @@
|
||||
#include "share/ob_define.h"
|
||||
#include "lib/atomic/ob_atomic.h"
|
||||
#include "lib/utility/ob_macro_utils.h"
|
||||
namespace oceanbase {
|
||||
namespace common {
|
||||
namespace oceanbase
|
||||
{
|
||||
namespace common
|
||||
{
|
||||
class ObIAllocator;
|
||||
}
|
||||
namespace sql {
|
||||
namespace sql
|
||||
{
|
||||
class ObPhyOperatorMonitorInfo;
|
||||
class ObOperatorStat;
|
||||
struct ObOperatorStat;
|
||||
class ObPhysicalPlan;
|
||||
namespace StatId {
|
||||
enum StatId { INPUT_ROWS = 0, RESCAN_TIMES, OUTPUT_ROWS, MAX_STAT };
|
||||
namespace StatId
|
||||
{
|
||||
enum StatId{
|
||||
INPUT_ROWS = 0,
|
||||
RESCAN_TIMES,
|
||||
OUTPUT_ROWS,
|
||||
MAX_STAT
|
||||
};
|
||||
}
|
||||
class ObPhyOperatorStats {
|
||||
class ObPhyOperatorStats
|
||||
{
|
||||
public:
|
||||
friend class TestPhyOperatorStats_init_Test;
|
||||
friend class TestPhyOperatorStats_test_add_Test;
|
||||
friend class TestPhyOperatorStats_test_accumulation_Test;
|
||||
ObPhyOperatorStats() : op_stats_array_(NULL), op_count_(0), array_size_(0), execution_times_(0)
|
||||
ObPhyOperatorStats() : op_stats_array_(NULL),
|
||||
op_count_(0), array_size_(0), execution_times_(0)
|
||||
{}
|
||||
~ObPhyOperatorStats()
|
||||
{}
|
||||
int init(common::ObIAllocator* alloc, int64_t op_count);
|
||||
int add_op_stat(ObPhyOperatorMonitorInfo& info);
|
||||
int get_op_stat_accumulation(ObPhysicalPlan* plan, int64_t op_id, ObOperatorStat& stat);
|
||||
~ObPhyOperatorStats() {}
|
||||
int init(common::ObIAllocator *alloc, int64_t op_count);
|
||||
int add_op_stat(ObPhyOperatorMonitorInfo &info);
|
||||
int get_op_stat_accumulation(ObPhysicalPlan *plan, int64_t op_id, ObOperatorStat &stat);
|
||||
static const int64_t COPY_COUNT = 10;
|
||||
int64_t count()
|
||||
{
|
||||
return op_count_;
|
||||
}
|
||||
void inc_execution_times()
|
||||
{
|
||||
ATOMIC_INC(&execution_times_);
|
||||
}
|
||||
int64_t get_execution_times() const
|
||||
{
|
||||
return execution_times_;
|
||||
}
|
||||
|
||||
int64_t count() { return op_count_; }
|
||||
void inc_execution_times() { ATOMIC_INC(&execution_times_); }
|
||||
int64_t get_execution_times() const { return execution_times_; }
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ObPhyOperatorStats);
|
||||
int64_t* op_stats_array_;
|
||||
int64_t *op_stats_array_;
|
||||
int64_t op_count_;
|
||||
int64_t array_size_;
|
||||
int64_t execution_times_;
|
||||
};
|
||||
} // namespace sql
|
||||
} // namespace oceanbase
|
||||
} //namespace sql
|
||||
} //namespace oceanbase
|
||||
#endif
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
PLAN_MONITOR_INFO_DEF(QUERY_TYPE, query_type)
|
||||
PLAN_MONITOR_INFO_DEF(TOTAL_WAIT_TIME, total_wait_time)
|
||||
PLAN_MONITOR_INFO_DEF(TOTAL_WAIT_COUNT, total_wait_count)
|
||||
// timestamp
|
||||
//timestamp
|
||||
PLAN_MONITOR_INFO_DEF(RPC_SEND_TIME, rpc_send_time)
|
||||
PLAN_MONITOR_INFO_DEF(RECEIVE_TIME, receive_time)
|
||||
PLAN_MONITOR_INFO_DEF(ENTER_QUEUE_TIME, enter_queue_time)
|
||||
@ -30,16 +30,19 @@ PLAN_MONITOR_INFO_DEF(EXECUTOR_END_TIME, executor_end_time)
|
||||
#include "share/ob_time_utility2.h"
|
||||
#include "sql/monitor/ob_phy_operator_monitor_info.h"
|
||||
#include "sql/monitor/ob_exec_stat.h"
|
||||
namespace oceanbase {
|
||||
namespace sql {
|
||||
enum ObPlanMonitorInfoIds {
|
||||
namespace oceanbase
|
||||
{
|
||||
namespace sql
|
||||
{
|
||||
enum ObPlanMonitorInfoIds
|
||||
{
|
||||
#define PLAN_MONITOR_INFO_DEF(def, name) def,
|
||||
#include "ob_phy_plan_exec_info.h"
|
||||
#undef PLAN_MONITOR_INFO_DEF
|
||||
#define EVENT_INFO(def, name) def,
|
||||
#include "ob_exec_stat.h"
|
||||
#undef EVENT_INFO
|
||||
MAX_EVENT_ID
|
||||
MAX_EVENT_ID
|
||||
};
|
||||
|
||||
static const MonitorName OB_PLAN_MONITOR_INFOS[] = {
|
||||
@ -49,20 +52,20 @@ static const MonitorName OB_PLAN_MONITOR_INFOS[] = {
|
||||
#define EVENT_INFO(def, name) {def, #name},
|
||||
#include "ob_exec_stat.h"
|
||||
#undef EVENT_INFO
|
||||
{MAX_EVENT_ID, "max_event"}};
|
||||
{MAX_EVENT_ID, "max_event"}
|
||||
};
|
||||
|
||||
class ObPhyPlanExecInfo final : public ObPhyOperatorMonitorInfo {
|
||||
class ObPhyPlanExecInfo final : public ObPhyOperatorMonitorInfo
|
||||
{
|
||||
public:
|
||||
ObPhyPlanExecInfo()
|
||||
{}
|
||||
inline virtual int64_t print_info(char* buf, int64_t buf_len) const;
|
||||
inline int add_exec_record(const ObExecRecord& exec_record);
|
||||
inline int add_exec_timestamp(const ObExecTimestamp& exec_timestamp);
|
||||
int64_t to_string(char* buf, int64_t buf_len) const
|
||||
ObPhyPlanExecInfo() {}
|
||||
inline virtual int64_t print_info(char *buf, int64_t buf_len) const;
|
||||
inline int add_exec_record(const ObExecRecord &exec_record);
|
||||
inline int add_exec_timestamp(const ObExecTimestamp &exec_timestamp);
|
||||
int64_t to_string(char *buf, int64_t buf_len) const
|
||||
{
|
||||
return print_info(buf, buf_len);
|
||||
}
|
||||
|
||||
private:
|
||||
void set_value(ObPlanMonitorInfoIds index, int64_t value)
|
||||
{
|
||||
@ -73,13 +76,12 @@ private:
|
||||
return (index >= RPC_SEND_TIME) && (index <= EXECUTOR_END_TIME);
|
||||
}
|
||||
DISALLOW_COPY_AND_ASSIGN(ObPhyPlanExecInfo);
|
||||
|
||||
private:
|
||||
common::ObWaitEventDesc max_wait_event_;
|
||||
int64_t plan_info_array_[MAX_EVENT_ID];
|
||||
};
|
||||
|
||||
int64_t ObPhyPlanExecInfo::print_info(char* buf, int64_t buf_len) const
|
||||
int64_t ObPhyPlanExecInfo::print_info(char *buf, int64_t buf_len) const
|
||||
{
|
||||
int64_t pos = 0;
|
||||
const int64_t time_buf_len = 128;
|
||||
@ -101,8 +103,7 @@ int64_t ObPhyPlanExecInfo::print_info(char* buf, int64_t buf_len) const
|
||||
}
|
||||
J_OBJ_START();
|
||||
if (is_timestamp(i)) {
|
||||
if (common::OB_SUCCESS !=
|
||||
share::ObTimeUtility2::usec_to_str(plan_info_array_[i], timebuf, time_buf_len, time_buf_pos)) {
|
||||
if (common::OB_SUCCESS != share::ObTimeUtility2::usec_to_str(plan_info_array_[i], timebuf, time_buf_len, time_buf_pos)) {
|
||||
SQL_MONITOR_LOG(WARN, "fail to print time as str", K(i));
|
||||
J_KV(OB_PLAN_MONITOR_INFOS[i].info_name_, plan_info_array_[i]);
|
||||
} else {
|
||||
@ -119,7 +120,7 @@ int64_t ObPhyPlanExecInfo::print_info(char* buf, int64_t buf_len) const
|
||||
return pos;
|
||||
}
|
||||
|
||||
int ObPhyPlanExecInfo::add_exec_record(const ObExecRecord& exec_record)
|
||||
int ObPhyPlanExecInfo::add_exec_record(const ObExecRecord &exec_record)
|
||||
{
|
||||
int ret = common::OB_SUCCESS;
|
||||
op_id_ = -1;
|
||||
@ -129,24 +130,23 @@ int ObPhyPlanExecInfo::add_exec_record(const ObExecRecord& exec_record)
|
||||
set_value(TOTAL_WAIT_TIME, exec_record.wait_time_end_);
|
||||
set_value(TOTAL_WAIT_COUNT, exec_record.wait_count_end_);
|
||||
|
||||
#define EVENT_INFO(def, name) set_value(def, exec_record.get_##name());
|
||||
#define EVENT_INFO(def, name) \
|
||||
set_value(def, exec_record.get_##name());
|
||||
#include "ob_exec_stat.h"
|
||||
#undef EVENT_INFO
|
||||
return ret;
|
||||
}
|
||||
int ObPhyPlanExecInfo::add_exec_timestamp(const ObExecTimestamp& exec_timestamp)
|
||||
int ObPhyPlanExecInfo::add_exec_timestamp(const ObExecTimestamp &exec_timestamp)
|
||||
{
|
||||
int ret = common::OB_SUCCESS;
|
||||
SQL_MONITOR_LOG(DEBUG,
|
||||
"add exec timestamp",
|
||||
K(exec_timestamp.exec_type_),
|
||||
K(exec_timestamp.before_process_ts_),
|
||||
K(exec_timestamp.process_executor_ts_),
|
||||
K(exec_timestamp.executor_end_ts_),
|
||||
K(exec_timestamp.receive_ts_),
|
||||
K(exec_timestamp.enter_queue_ts_),
|
||||
K(exec_timestamp.run_ts_),
|
||||
K(exec_timestamp.single_process_ts_));
|
||||
SQL_MONITOR_LOG(DEBUG, "add exec timestamp", K(exec_timestamp.exec_type_),
|
||||
K(exec_timestamp.before_process_ts_),
|
||||
K(exec_timestamp.process_executor_ts_),
|
||||
K(exec_timestamp.executor_end_ts_),
|
||||
K(exec_timestamp.receive_ts_),
|
||||
K(exec_timestamp.enter_queue_ts_),
|
||||
K(exec_timestamp.run_ts_),
|
||||
K(exec_timestamp.single_process_ts_));
|
||||
set_value(QUERY_TYPE, exec_timestamp.exec_type_);
|
||||
set_value(BEFORE_PROCESS_TIME, exec_timestamp.before_process_ts_);
|
||||
set_value(PROCESS_EXECUTOR_TIME, exec_timestamp.process_executor_ts_);
|
||||
@ -156,7 +156,10 @@ int ObPhyPlanExecInfo::add_exec_timestamp(const ObExecTimestamp& exec_timestamp)
|
||||
set_value(ENTER_QUEUE_TIME, exec_timestamp.enter_queue_ts_);
|
||||
set_value(RUN_TIME, exec_timestamp.run_ts_);
|
||||
}
|
||||
if (MpQuery == exec_timestamp.exec_type_) {
|
||||
if (MpQuery == exec_timestamp.exec_type_
|
||||
|| PSCursor == exec_timestamp.exec_type_
|
||||
|| DbmsCursor == exec_timestamp.exec_type_
|
||||
|| CursorFetch == exec_timestamp.exec_type_) {
|
||||
set_value(SINGLE_PROCESS_TIME, exec_timestamp.single_process_ts_);
|
||||
}
|
||||
if (RpcProcessor == exec_timestamp.exec_type_) {
|
||||
@ -164,6 +167,6 @@ int ObPhyPlanExecInfo::add_exec_timestamp(const ObExecTimestamp& exec_timestamp)
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
} // namespace sql
|
||||
} // namespace oceanbase
|
||||
} //namespace sql
|
||||
} //namespace oceanbase
|
||||
#endif
|
||||
|
||||
@ -13,30 +13,32 @@
|
||||
#define USING_LOG_PREFIX SQL_MONITOR
|
||||
#include "sql/monitor/ob_phy_plan_monitor_info.h"
|
||||
using namespace oceanbase::common;
|
||||
namespace oceanbase {
|
||||
namespace sql {
|
||||
namespace oceanbase
|
||||
{
|
||||
namespace sql
|
||||
{
|
||||
OB_SERIALIZE_MEMBER(ObPhyPlanMonitorInfo, request_id_, plan_id_, plan_info_, operator_infos_, execution_time_);
|
||||
|
||||
ObPhyPlanMonitorInfo::ObPhyPlanMonitorInfo(common::ObConcurrentFIFOAllocator& allocator)
|
||||
: allocator_(allocator),
|
||||
request_id_(OB_INVALID_ID),
|
||||
scheduler_addr_(),
|
||||
plan_id_(OB_INVALID_ID),
|
||||
execution_time_(0),
|
||||
operator_infos_(OB_MALLOC_NORMAL_BLOCK_SIZE),
|
||||
exec_trace_(false, ObLatchIds::TRACE_RECORDER_LOCK)
|
||||
{}
|
||||
ObPhyPlanMonitorInfo::ObPhyPlanMonitorInfo(common::ObConcurrentFIFOAllocator &allocator)
|
||||
:allocator_(allocator),
|
||||
request_id_(OB_INVALID_ID),
|
||||
scheduler_addr_(),
|
||||
plan_id_(OB_INVALID_ID),
|
||||
execution_time_(0),
|
||||
operator_infos_(OB_MALLOC_NORMAL_BLOCK_SIZE),
|
||||
exec_trace_(false, ObLatchIds::TRACE_RECORDER_LOCK)
|
||||
{
|
||||
}
|
||||
|
||||
int ObPhyPlanMonitorInfo::add_operator_info(const ObPhyOperatorMonitorInfo& info)
|
||||
int ObPhyPlanMonitorInfo::add_operator_info(const ObPhyOperatorMonitorInfo &info)
|
||||
{
|
||||
return operator_infos_.push_back(info);
|
||||
}
|
||||
|
||||
int ObPhyPlanMonitorInfo::get_operator_info(int64_t op_id, ObPhyOperatorMonitorInfo& info) const
|
||||
int ObPhyPlanMonitorInfo::get_operator_info(int64_t op_id, ObPhyOperatorMonitorInfo &info) const
|
||||
{
|
||||
int ret = OB_ENTRY_NOT_EXIST;
|
||||
ARRAY_FOREACH_NORET(operator_infos_, idx)
|
||||
{
|
||||
ARRAY_FOREACH_NORET(operator_infos_, idx) {
|
||||
if (operator_infos_.at(idx).get_op_id() == op_id) {
|
||||
if (OB_FAIL(info.assign(operator_infos_.at(idx)))) {
|
||||
LOG_WARN("fail to assgin to phy_operator info", K(ret));
|
||||
@ -49,7 +51,8 @@ int ObPhyPlanMonitorInfo::get_operator_info(int64_t op_id, ObPhyOperatorMonitorI
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObPhyPlanMonitorInfo::get_operator_info_by_index(int64_t index, ObPhyOperatorMonitorInfo*& info)
|
||||
int ObPhyPlanMonitorInfo::get_operator_info_by_index(int64_t index,
|
||||
ObPhyOperatorMonitorInfo *&info)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (0 > index) {
|
||||
@ -64,14 +67,14 @@ int ObPhyPlanMonitorInfo::get_operator_info_by_index(int64_t index, ObPhyOperato
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObPhyPlanMonitorInfo::set_plan_exec_record(const ObExecRecord& exec_record)
|
||||
int ObPhyPlanMonitorInfo::set_plan_exec_record(const ObExecRecord &exec_record)
|
||||
{
|
||||
return plan_info_.add_exec_record(exec_record);
|
||||
}
|
||||
int ObPhyPlanMonitorInfo::set_plan_exec_timestamp(const ObExecTimestamp& exec_timestamp)
|
||||
int ObPhyPlanMonitorInfo::set_plan_exec_timestamp(const ObExecTimestamp &exec_timestamp)
|
||||
{
|
||||
execution_time_ = exec_timestamp.run_ts_;
|
||||
return plan_info_.add_exec_timestamp(exec_timestamp);
|
||||
}
|
||||
} // namespace sql
|
||||
} // namespace oceanbase
|
||||
} //namespace sql
|
||||
} //namespace oceanbase
|
||||
|
||||
@ -18,15 +18,17 @@
|
||||
#include "sql/monitor/ob_phy_plan_exec_info.h"
|
||||
#include "observer/mysql/ob_mysql_request_manager.h"
|
||||
#include "lib/trace/ob_trace_event.h"
|
||||
namespace oceanbase {
|
||||
namespace sql {
|
||||
class ObPhyPlanMonitorInfo final {
|
||||
namespace oceanbase
|
||||
{
|
||||
namespace sql
|
||||
{
|
||||
class ObPhyPlanMonitorInfo final
|
||||
{
|
||||
public:
|
||||
OB_UNIS_VERSION(1);
|
||||
|
||||
public:
|
||||
const static int OPERATOR_LOCAL_COUNT = 8;
|
||||
explicit ObPhyPlanMonitorInfo(common::ObConcurrentFIFOAllocator& allocator);
|
||||
explicit ObPhyPlanMonitorInfo(common::ObConcurrentFIFOAllocator &allocator);
|
||||
virtual void destroy()
|
||||
{
|
||||
reset();
|
||||
@ -37,29 +39,19 @@ public:
|
||||
operator_infos_.reset();
|
||||
}
|
||||
|
||||
int add_operator_info(const ObPhyOperatorMonitorInfo& info);
|
||||
int64_t get_operator_count()
|
||||
{
|
||||
return operator_infos_.count();
|
||||
}
|
||||
int set_plan_exec_record(const ObExecRecord& exec_record);
|
||||
int set_plan_exec_timestamp(const ObExecTimestamp& exec_timestamp);
|
||||
int get_operator_info(int64_t op_id, ObPhyOperatorMonitorInfo& info) const;
|
||||
int get_operator_info_by_index(int64_t index, ObPhyOperatorMonitorInfo*& info);
|
||||
int get_plan_info(ObPhyPlanExecInfo*& info)
|
||||
{
|
||||
info = &plan_info_;
|
||||
return common::OB_SUCCESS;
|
||||
}
|
||||
int set_trace(const common::ObTraceEventRecorder& trace)
|
||||
{
|
||||
return exec_trace_.assign(trace);
|
||||
}
|
||||
const common::ObTraceEventRecorder& get_trace() const
|
||||
{
|
||||
return exec_trace_;
|
||||
}
|
||||
int64_t to_string(char* buf, int64_t buf_len) const
|
||||
int add_operator_info(const ObPhyOperatorMonitorInfo &info);
|
||||
int64_t get_operator_count() { return operator_infos_.count(); }
|
||||
int set_plan_exec_record(const ObExecRecord &exec_record);
|
||||
int set_plan_exec_timestamp(const ObExecTimestamp &exec_timestamp);
|
||||
int get_operator_info(int64_t op_id,
|
||||
ObPhyOperatorMonitorInfo &info) const;
|
||||
int get_operator_info_by_index(int64_t index,
|
||||
ObPhyOperatorMonitorInfo *&info);
|
||||
int get_plan_info(ObPhyPlanExecInfo *&info)
|
||||
{ info = &plan_info_; return common::OB_SUCCESS; }
|
||||
int set_trace(const common::ObTraceEventRecorder &trace) { return exec_trace_.assign(trace); }
|
||||
const common::ObTraceEventRecorder &get_trace() const { return exec_trace_; }
|
||||
int64_t to_string(char *buf, int64_t buf_len) const
|
||||
{
|
||||
int64_t pos = 0;
|
||||
J_OBJ_START();
|
||||
@ -68,50 +60,27 @@ public:
|
||||
J_KV(N_EXECUTION_TIME, execution_time_);
|
||||
J_KV(N_PLAN_MONITOR_INFO, plan_info_);
|
||||
for (int64_t i = 0; i < operator_infos_.count(); i++) {
|
||||
J_KV(N_OPERATOR_MONITOR_INFO, operator_infos_.at(i));
|
||||
J_KV(N_OPERATOR_MONITOR_INFO, operator_infos_.at(i));
|
||||
}
|
||||
J_OBJ_END();
|
||||
return pos;
|
||||
}
|
||||
int64_t get_operator_info_memory_size()
|
||||
{
|
||||
// Local info memory is counted in alloctor_, so only non-local memory needs to be calculated
|
||||
// 本地info内存统计在alloctor_里面,因此只需要计算非本地的内存
|
||||
return operator_infos_.count() < OPERATOR_LOCAL_COUNT ? 0 : operator_infos_.get_data_size();
|
||||
}
|
||||
void set_request_id(int64_t request_id)
|
||||
{
|
||||
request_id_ = request_id;
|
||||
}
|
||||
void set_plan_id(int64_t plan_id)
|
||||
{
|
||||
plan_id_ = plan_id;
|
||||
}
|
||||
int64_t get_request_id() const
|
||||
{
|
||||
return request_id_;
|
||||
}
|
||||
int64_t get_plan_id() const
|
||||
{
|
||||
return plan_id_;
|
||||
}
|
||||
int64_t get_execution_time() const
|
||||
{
|
||||
return execution_time_;
|
||||
}
|
||||
void set_address(common::ObAddr addr)
|
||||
{
|
||||
scheduler_addr_ = addr;
|
||||
}
|
||||
common::ObAddr get_address() const
|
||||
{
|
||||
return scheduler_addr_;
|
||||
}
|
||||
|
||||
void set_request_id(int64_t request_id) { request_id_ = request_id; }
|
||||
void set_plan_id(int64_t plan_id) {plan_id_ = plan_id; }
|
||||
int64_t get_request_id() const { return request_id_; }
|
||||
int64_t get_plan_id() const { return plan_id_; }
|
||||
int64_t get_execution_time() const { return execution_time_; }
|
||||
void set_address(common::ObAddr addr) { scheduler_addr_ = addr; }
|
||||
common::ObAddr get_address() const { return scheduler_addr_; }
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ObPhyPlanMonitorInfo);
|
||||
|
||||
private:
|
||||
common::ObConcurrentFIFOAllocator& allocator_;
|
||||
common::ObConcurrentFIFOAllocator &allocator_;
|
||||
int64_t request_id_;
|
||||
common::ObAddr scheduler_addr_;
|
||||
int64_t plan_id_;
|
||||
@ -120,6 +89,6 @@ private:
|
||||
ObPhyPlanExecInfo plan_info_;
|
||||
common::ObTraceEventRecorder exec_trace_;
|
||||
};
|
||||
} // namespace sql
|
||||
} // namespace oceanbase
|
||||
} //namespace sql
|
||||
} //namespace oceanbase
|
||||
#endif
|
||||
|
||||
30
src/sql/monitor/ob_security_audit.h
Normal file
30
src/sql/monitor/ob_security_audit.h
Normal file
@ -0,0 +1,30 @@
|
||||
/**
|
||||
* Copyright (c) 2021 OceanBase
|
||||
* OceanBase CE is licensed under Mulan PubL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||
* You may obtain a copy of Mulan PubL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PubL v2 for more details.
|
||||
*/
|
||||
|
||||
#ifndef OCEANBASE_SQL_SECURITY_AUDIT_H
|
||||
#define OCEANBASE_SQL_SECURITY_AUDIT_H
|
||||
#include "lib/string/ob_string.h"
|
||||
#include "lib/utility/ob_macro_utils.h"
|
||||
#include "lib/net/ob_addr.h"
|
||||
#include "lib/oblog/ob_log.h"
|
||||
#include "sql/ob_sql_define.h"
|
||||
#include "storage/tx/ob_trans_define.h"
|
||||
|
||||
namespace oceanbase
|
||||
{
|
||||
namespace sql
|
||||
{
|
||||
} //namespace sql
|
||||
} //namespace oceanbase
|
||||
#endif
|
||||
|
||||
|
||||
52
src/sql/monitor/ob_security_audit_utils.h
Normal file
52
src/sql/monitor/ob_security_audit_utils.h
Normal file
@ -0,0 +1,52 @@
|
||||
/**
|
||||
* Copyright (c) 2021 OceanBase
|
||||
* OceanBase CE is licensed under Mulan PubL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||
* You may obtain a copy of Mulan PubL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PubL v2 for more details.
|
||||
*/
|
||||
|
||||
#ifndef OCEANBASE_SQL_SECURITY_AUDIT_UTILS_H
|
||||
#define OCEANBASE_SQL_SECURITY_AUDIT_UTILS_H
|
||||
|
||||
#include "lib/string/ob_string.h"
|
||||
#include "lib/container/ob_iarray.h"
|
||||
#include "sql/monitor/ob_audit_action_type.h"
|
||||
#include "sql/resolver/ob_stmt_type.h"
|
||||
#include "sql/resolver/dml/ob_dml_stmt.h"
|
||||
|
||||
namespace oceanbase
|
||||
{
|
||||
namespace sql
|
||||
{
|
||||
enum class ObAuditTrailType{
|
||||
INVALID = 0,
|
||||
NONE,
|
||||
};
|
||||
|
||||
ObAuditTrailType get_audit_trail_type_from_string(const common::ObString &string);
|
||||
|
||||
struct ObAuditUnit
|
||||
{
|
||||
ObAuditUnit() {}
|
||||
~ObAuditUnit() {}
|
||||
TO_STRING_KV(K(""));
|
||||
};
|
||||
|
||||
class ObSecurityAuditUtils final
|
||||
{
|
||||
public:
|
||||
static int check_allow_audit(ObSQLSessionInfo &session, ObAuditTrailType &at_type);
|
||||
static int get_audit_file_name(char *buf,
|
||||
const int64_t buf_len,
|
||||
int64_t &pos);
|
||||
};
|
||||
}
|
||||
} //namespace oceanbase
|
||||
#endif
|
||||
|
||||
|
||||
53
src/sql/monitor/ob_security_audit_utils_os.cpp
Normal file
53
src/sql/monitor/ob_security_audit_utils_os.cpp
Normal file
@ -0,0 +1,53 @@
|
||||
/**
|
||||
* Copyright (c) 2021 OceanBase
|
||||
* OceanBase CE is licensed under Mulan PubL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||
* You may obtain a copy of Mulan PubL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PubL v2 for more details.
|
||||
*/
|
||||
|
||||
#define USING_LOG_PREFIX SQL_MONITOR
|
||||
|
||||
#include "sql/monitor/ob_security_audit_utils.h"
|
||||
|
||||
namespace oceanbase
|
||||
{
|
||||
namespace sql
|
||||
{
|
||||
|
||||
ObAuditTrailType get_audit_trail_type_from_string(const common::ObString &string)
|
||||
{
|
||||
ObAuditTrailType ret_type = ObAuditTrailType::INVALID;
|
||||
return ret_type;
|
||||
}
|
||||
|
||||
int ObSecurityAuditUtils::check_allow_audit(ObSQLSessionInfo &session, ObAuditTrailType &at_type)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
at_type = ObAuditTrailType::NONE;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObSecurityAuditUtils::get_audit_file_name(char *buf, const int64_t buf_len, int64_t &pos)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
time_t t = 0;
|
||||
time(&t);
|
||||
struct tm tm;
|
||||
::localtime_r(&t, &tm);
|
||||
if (OB_FAIL(databuff_printf(buf, buf_len, pos, OB_LOGGER.SECURITY_AUDIT_FILE_NAME_FORMAT,
|
||||
getpid(), tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
|
||||
tm.tm_hour, tm.tm_min, tm.tm_sec))) {
|
||||
SERVER_LOG(WARN, "databuff_printf failed", K(ret), K(pos), K(buf_len));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
} //namespace sql
|
||||
} //namespace oceanbase
|
||||
|
||||
|
||||
Reference in New Issue
Block a user