[FEAT MERGE]

Co-authored-by: cqliang1995 <cq.liang@outlook.com>
Co-authored-by: qingsuijiu <642782632@qq.com>
Co-authored-by: yaojing624 <jingfeng.jf@oceanbase.com>
This commit is contained in:
obdev
2024-04-16 10:51:16 +00:00
committed by ob-robot
parent 49b1cfbe6b
commit 037fe7d9bb
89 changed files with 4987 additions and 1511 deletions

View File

@ -477,7 +477,8 @@ int ObBasicSessionInfo::reset_timezone()
}
ObObj tmp_obj2;
if (OB_FAIL(get_sys_variable(SYS_VAR_ERROR_ON_OVERLAP_TIME, tmp_obj2))) {
if (OB_FAIL(ret)) {
} else if (OB_FAIL(get_sys_variable(SYS_VAR_ERROR_ON_OVERLAP_TIME, tmp_obj2))) {
LOG_WARN("get sys var failed", K(ret));
} else if (OB_FAIL(process_session_overlap_time_value(tmp_obj2))) {
LOG_WARN("process session overlap time value failed", K(ret), K(tmp_obj2));
@ -5893,8 +5894,13 @@ int ObBasicSessionInfo::set_session_state_(ObSQLSessionState state)
LOG_WARN("session state is unknown", K(ret), K(sessid_), K(proxy_sessid_), K(state));
}
} else {
bool is_state_change = is_active_state_change(thread_data_.state_, state);
thread_data_.state_ = state;
thread_data_.cur_state_start_time_ = ::oceanbase::common::ObClockGenerator::getClock();
int64_t current_time = ::oceanbase::common::ObTimeUtility::current_time();
if (is_state_change) {
thread_data_.retry_active_time_ += (current_time - thread_data_.cur_state_start_time_);
}
thread_data_.cur_state_start_time_ = current_time;
}
return ret;
}
@ -5941,6 +5947,7 @@ int ObBasicSessionInfo::set_session_active(const ObString &sql,
thread_data_.cur_query_start_time_ = query_receive_ts;
thread_data_.mysql_cmd_ = cmd;
thread_data_.last_active_time_ = last_active_time_ts;
thread_data_.is_request_end_ = false;
ObActiveSessionGuard::setup_ash(ash_stat_);
}
return ret;
@ -5957,6 +5964,7 @@ int ObBasicSessionInfo::set_session_active(const ObString &label,
LOG_WARN("fail to set session state", K(ret));
} else {
thread_data_.mysql_cmd_ = cmd;
thread_data_.is_request_end_ = false;
ObActiveSessionGuard::setup_ash(ash_stat_);
}
return ret;

View File

@ -855,6 +855,18 @@ public:
bool get_is_in_retry_for_dup_tbl() {
return SESS_IN_RETRY_FOR_DUP_TBL == thread_data_.is_in_retry_;
}
void set_retry_active_time(int64_t time)
{
LockGuard lock_guard(thread_data_mutex_);
thread_data_.retry_active_time_ = time;
}
int64_t get_retry_active_time() const { return thread_data_.retry_active_time_; }
void set_is_request_end(bool is_request_end)
{
LockGuard lock_guard(thread_data_mutex_);
thread_data_.is_request_end_ = is_request_end;
}
bool get_is_request_end() const { return thread_data_.is_request_end_; }
obmysql::ObMySQLCmd get_mysql_cmd() const { return thread_data_.mysql_cmd_; }
char const *get_mysql_cmd_str() const { return obmysql::get_mysql_cmd_str(thread_data_.mysql_cmd_); }
int store_query_string(const common::ObString &stmt);
@ -1304,6 +1316,14 @@ public:
int get_sync_sys_vars_size(common::ObIArray<share::ObSysVarClassType> &sys_var_delta_ids, int64_t &len) const;
bool is_sync_sys_var(share::ObSysVarClassType sys_var_id) const;
bool is_exist_error_sync_var(share::ObSysVarClassType sys_var_id) const;
// record session state from active to anothe state. for record total_cpu_time.
bool is_active_state_change(ObSQLSessionState last_state, ObSQLSessionState curr_state) {
if (last_state == QUERY_ACTIVE && curr_state != QUERY_ACTIVE) {
return true;
} else {
return false;
}
}
// nested session and sql execute for foreign key.
bool is_nested_session() const { return nested_count_ > 0; }
@ -1495,7 +1515,9 @@ protected:
client_addr_port_(0),
is_mark_killed_(false),
proxy_user_name_(),
proxy_host_name_()
proxy_host_name_(),
retry_active_time_(0),
is_request_end_(true)
{
CHAR_CARRAY_INIT(database_name_);
}
@ -1536,6 +1558,8 @@ protected:
is_mark_killed_ = false;
proxy_user_name_.reset();
proxy_host_name_.reset();
retry_active_time_ = 0;
is_request_end_ = true;
}
~MultiThreadData ()
{
@ -1573,6 +1597,13 @@ protected:
bool is_mark_killed_; // Mark the current session as delayed kill
common::ObString proxy_user_name_;
common::ObString proxy_host_name_;
// In the retry scenario, record the cumulative active time except the current state,
// and use it to count the CPU time. For example, 1. The current request status is Sleep,
// waiting for retry, it will record the cumulative time of Active during previous execution.
// 2. The current request status is Active, and it is retrying. It will ignore the active time
// of the current status and record the cumulative time of Active during previous execution.
int64_t retry_active_time_;
bool is_request_end_; // This flag is used to distinguish whether the current request is over.
};
public: