[CP] to issue<55748018>:fix memory leak about anonymous array when inject error

This commit is contained in:
hanr881
2024-04-08 09:16:18 +00:00
committed by ob-robot
parent fbf6fdf06b
commit 445c9dfc31
3 changed files with 17 additions and 7 deletions

View File

@ -331,17 +331,18 @@ int ObMPStmtExecute::construct_execute_param_for_arraybinding(int64_t pos)
return ret;
}
void ObMPStmtExecute::reset_complex_param_memory(ParamStore *params, ObSQLSessionInfo &session_info)
void ObMPStmtExecute::reset_complex_param_memory(ParamStore *params, ObSQLSessionInfo *session_info)
{
if (OB_NOT_NULL(params)) {
for (int64_t i = 0; i < params->count(); ++i) {
ObObjParam &obj = params->at(i);
if (obj.is_pl_extend()) {
int ret = ObUserDefinedType::destruct_obj(obj, &session_info);
int ret = ObUserDefinedType::destruct_obj(obj, session_info);
if (OB_SUCCESS != ret) {
LOG_WARN("fail to destruct obj", K(ret), K(i));
}
}
obj.set_null();
}
}
}
@ -581,6 +582,17 @@ int ObMPStmtExecute::before_process()
return ret;
}
int ObMPStmtExecute::after_process(int error_code)
{
int ret = OB_SUCCESS;
reset_complex_param_memory(arraybinding_params_);
reset_complex_param_memory(params_);
if (OB_FAIL(ObMPBase::after_process(error_code))) {
LOG_WARN("after process fail", K(ret));
}
return ret;
}
int ObMPStmtExecute::store_params_value_to_str(ObIAllocator &alloc, sql::ObSQLSessionInfo &session)
{
return store_params_value_to_str(alloc, session, params_, params_value_, params_value_len_);
@ -1747,7 +1759,7 @@ int ObMPStmtExecute::process_execute_stmt(const ObMultiStmtItem &multi_stmt_item
}
}
// 释放数组内存避免内存泄漏
reset_complex_param_memory(arraybinding_params_, session);
OZ (response_result_for_arraybinding(session, exception_array));
} else {
need_response_error = false;
@ -1773,7 +1785,6 @@ int ObMPStmtExecute::process_execute_stmt(const ObMultiStmtItem &multi_stmt_item
}
ret = OB_SUCC(bak_ret) ? ret : bak_ret;
}
reset_complex_param_memory(params_, session);
}
if (enable_trace_log) {
ObThreadLogLevelUtils::clear();

View File

@ -250,7 +250,7 @@ private:
sql::ObSQLSessionInfo *session_info, sql::ParamTypeInfoArray &param_type_infos);
int check_param_value_for_arraybinding(ObObjParam &param);
int construct_execute_param_for_arraybinding(int64_t pos);
void reset_complex_param_memory(ParamStore *params, sql::ObSQLSessionInfo &session_info);
void reset_complex_param_memory(ParamStore *params, sql::ObSQLSessionInfo *session_info = nullptr);
int save_exception_for_arraybinding(
int64_t pos, int error_code, ObIArray<ObSavedException> &exception_array);
//int after_do_process_for_arraybinding(ObMySQLResultSet &result);
@ -331,6 +331,7 @@ private:
bool is_contain_complex_element(const sql::ParamTypeArray &param_types) const;
virtual int before_process();
virtual int after_process(int error_code);
int response_query_header(sql::ObSQLSessionInfo &session, pl::ObDbmsCursorInfo &cursor);
//重载response,在response中不去调用flush_buffer(true);flush_buffer(true)在需要回包时显示调用

View File

@ -107,8 +107,6 @@ protected:
{ return OB_NOT_NULL(get_conn()) && get_conn()->need_send_extra_ok_packet(); }
virtual int response_packet(obmysql::ObMySQLPacket &pkt, sql::ObSQLSessionInfo* session)
{ return ObMPBase::response_packet(pkt, session); }
virtual int after_process(int error_code)
{ return ObMPBase::after_process(error_code); }
int send_prepare_packet(uint32_t statement_id,
uint16_t column_num,
uint16_t param_num,