From aae19e1f3cded4c07e8bd62aa424772d3b5e483c Mon Sep 17 00:00:00 2001 From: obdev Date: Tue, 13 Sep 2022 09:33:55 +0000 Subject: [PATCH] [CP] [CP] Fix the core caused by accessing cur phy plan --- .../virtual_table/ob_virtual_open_cursor_table.cpp | 10 +++++++--- src/sql/session/ob_basic_session_info.cpp | 7 +------ src/sql/session/ob_basic_session_info.h | 2 -- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/observer/virtual_table/ob_virtual_open_cursor_table.cpp b/src/observer/virtual_table/ob_virtual_open_cursor_table.cpp index 2180a61d87..2840048a6d 100644 --- a/src/observer/virtual_table/ob_virtual_open_cursor_table.cpp +++ b/src/observer/virtual_table/ob_virtual_open_cursor_table.cpp @@ -59,13 +59,17 @@ bool ObVirtualOpenCursorTable::ObEachSessionId::operator()( CK(OB_NOT_NULL(sess_info)); CK(OB_NOT_NULL(allocator_)); if (OB_SUCC(ret)) { + char *sql_id = nullptr; sql::ObSQLSessionInfo::LockGuard lock_guard(sess_info->get_thread_data_lock()); - if (OB_NOT_NULL(sess_info->get_cur_phy_plan())) { - vsp.version = sess_info->get_version(); + if (OB_ISNULL(sql_id = reinterpret_cast(allocator_->alloc(common::OB_MAX_SQL_ID_LENGTH + 1)))) { + ret = OB_ALLOCATE_MEMORY_FAILED; + SERVER_LOG(WARN, "failed to alloc buf", K(ret)); + } else if (FALSE_IT(sess_info->get_cur_sql_id(sql_id, OB_MAX_SQL_ID_LENGTH + 1))) { + } else if (sql_id[0] != '\0') { vsp.id = sess_info->get_sessid(); vsp.addr = reinterpret_cast(sess_info); + vsp.sql_id.assign(sql_id, common::OB_MAX_SQL_ID_LENGTH); OZ(ob_write_string(*allocator_, sess_info->get_user_name(), vsp.user_name)); - OZ(ob_write_string(*allocator_, sess_info->get_cur_phy_plan()->stat_.sql_id_, vsp.sql_id)); if (vsp.is_valid()) { SessionInfoArray vsp_arr; OZ(sids_map_.get_refactored(vsp.sql_id, vsp_arr)); diff --git a/src/sql/session/ob_basic_session_info.cpp b/src/sql/session/ob_basic_session_info.cpp index 2c23510fc8..bd64ff61eb 100644 --- a/src/sql/session/ob_basic_session_info.cpp +++ b/src/sql/session/ob_basic_session_info.cpp @@ -1629,12 +1629,7 @@ int ObBasicSessionInfo::sys_variable_exists(const ObString& var, bool& is_exists return ret; } -ObPhysicalPlan* ObBasicSessionInfo::get_cur_phy_plan() const -{ - return cur_phy_plan_; -} - -int ObBasicSessionInfo::set_cur_phy_plan(ObPhysicalPlan* cur_phy_plan) +int ObBasicSessionInfo::set_cur_phy_plan(ObPhysicalPlan *cur_phy_plan) { int ret = OB_SUCCESS; if (OB_ISNULL(cur_phy_plan)) { diff --git a/src/sql/session/ob_basic_session_info.h b/src/sql/session/ob_basic_session_info.h index bb8897a4f0..7b21fdd2a5 100644 --- a/src/sql/session/ob_basic_session_info.h +++ b/src/sql/session/ob_basic_session_info.h @@ -1030,8 +1030,6 @@ public: int clean_all_sys_vars(); SysVarIncInfo sys_var_inc_info_; - // current executing physical plan - ObPhysicalPlan* get_cur_phy_plan() const; void get_cur_sql_id(char *sql_id_buf, int64_t sql_id_buf_size) const; int set_cur_phy_plan(ObPhysicalPlan *cur_phy_plan); void reset_cur_phy_plan_to_null(); -- GitLab