[to #56534142] test: error injection for pr-exec protocol

This commit is contained in:
haohao022 2024-06-17 13:17:53 +00:00 committed by ob-robot
parent 0052ee98b6
commit 317ca7bb41
3 changed files with 31 additions and 28 deletions

View File

@ -543,4 +543,11 @@ GLOBAL_ERRSIM_POINT_DEF(2304, EN_TRACEPOINT_TEST, "For testing new versions of t
GLOBAL_ERRSIM_POINT_DEF(2400, EN_SQL_FORCE_DUMP, "For testing force dump once");
GLOBAL_ERRSIM_POINT_DEF(2401, EN_TEST_FOR_HASH_UNION, "Used to control whether to turn off the vectorization 2.0 hash set operator. It is turned on by default.");
// Protocol begin 2450 - 2500
// pr-exec protocol
GLOBAL_ERRSIM_POINT_DEF(2450, COM_STMT_PREXECUTE_PREPARE_ERROR, "inject error at prepare stage for pr-exec protocol");
GLOBAL_ERRSIM_POINT_DEF(2451, COM_STMT_PREXECUTE_PS_CURSOR_OPEN_ERROR, "inject error at cursor open stage for pr-exec protocol");
GLOBAL_ERRSIM_POINT_DEF(2452, COM_STMT_PREXECUTE_EXECUTE_ERROR, "inject error at execute stage for pr-exec protocol");
// Protocol end
#endif /*GLOBAL_ERRSIM_POINT_DEF*/

View File

@ -62,13 +62,6 @@ using namespace sql;
using namespace pl;
namespace observer
{
#ifdef ERRSIM
ERRSIM_POINT_DEF(COM_STMT_PREXECUTE_PREPARE_ERROR);
ERRSIM_POINT_DEF(COM_STMT_PREXECUTE_PS_CURSOR_OPEN_ERROR);
ERRSIM_POINT_DEF(COM_STMT_PREXECUTE_EXECUTE_ERROR);
#endif
ObMPStmtPrexecute::ObMPStmtPrexecute(const ObGlobalContext &gctx)
: ObMPStmtExecute(gctx),
sql_(),
@ -251,15 +244,10 @@ int ObMPStmtPrexecute::before_process()
LOG_WARN("fail to set session active", K(ret));
}
if (OB_SUCC(ret)) {
if (
#ifdef ERRSIM
OB_FAIL(COM_STMT_PREXECUTE_PREPARE_ERROR) ||
#endif
OB_FAIL(gctx_.sql_engine_->stmt_prepare(sql_,
if (OB_FAIL(gctx_.sql_engine_->stmt_prepare(sql_,
get_ctx(),
result,
false /*is_inner_sql*/))
) {
false /*is_inner_sql*/))) {
set_exec_start_timestamp(ObTimeUtility::current_time());
int cli_ret = OB_SUCCESS;
get_retry_ctrl().test_and_save_retry_state(gctx_,
@ -487,7 +475,7 @@ int ObMPStmtPrexecute::execute_response(ObSQLSessionInfo &session,
get_ctx().cur_sql_ = sql_;
if (
#ifdef ERRSIM
OB_FAIL(COM_STMT_PREXECUTE_PS_CURSOR_OPEN_ERROR) ||
OB_FAIL(common::EventTable::COM_STMT_PREXECUTE_PS_CURSOR_OPEN_ERROR) ||
#endif
OB_FAIL(ObSPIService::dbms_dynamic_open(&pl_ctx, *cursor))
) {
@ -617,17 +605,12 @@ int ObMPStmtPrexecute::execute_response(ObSQLSessionInfo &session,
ret = tmp_ret;
LOG_WARN("execute server cursor failed.", K(ret));
}
} else if (
#ifdef ERRSIM
OB_FAIL(COM_STMT_PREXECUTE_EXECUTE_ERROR) ||
#endif
OB_FAIL(gctx_.sql_engine_->stmt_execute(stmt_id_,
stmt_type_,
params,
ctx,
result,
false /* is_inner_sql */))
) {
} else if (OB_FAIL(gctx_.sql_engine_->stmt_execute(stmt_id_,
stmt_type_,
params,
ctx,
result,
false /* is_inner_sql */))) {
set_exec_start_timestamp(ObTimeUtility::current_time());
if (!THIS_WORKER.need_retry()) {
int cli_ret = OB_SUCCESS;

View File

@ -273,8 +273,14 @@ int ObSql::stmt_execute(const ObPsStmtId stmt_id,
LOG_WARN("failed to do sanity check", K(ret));
} else if (OB_FAIL(init_result_set(context, result))) {
LOG_WARN("failed to init result set", K(ret));
} else if (OB_FAIL(handle_ps_execute(stmt_id, stmt_type, params,
context, result, is_inner_sql))) {
} else if (
#ifdef ERRSIM
// inject error for pr-ex protocol only
// inject after `init_result_set` because retry test would check session ptr in the exec ctx,
// which is initialized by `init_result_set`.
OB_FAIL(EVENT_CALL(common::EventTable::COM_STMT_PREXECUTE_EXECUTE_ERROR, context.is_pre_execute_)) ||
#endif
OB_FAIL(handle_ps_execute(stmt_id, stmt_type, params, context, result, is_inner_sql))) {
if (OB_ERR_PROXY_REROUTE != ret) {
LOG_WARN("failed to handle ps execute", K(stmt_id), K(ret));
}
@ -1791,6 +1797,13 @@ int ObSql::handle_ps_prepare(const ObString &stmt,
LOG_WARN("failed to init result set", K(ret));
}
#ifdef ERRSIM
// inject error for pr-ex protocol only
if (OB_SUCC(ret)) {
ret = OB_E(common::EventTable::COM_STMT_PREXECUTE_PREPARE_ERROR, context.is_pre_execute_) OB_SUCCESS;
}
#endif
if (OB_SUCC(ret)) {
ObSQLSessionInfo &session = result.get_session();
ObPsCache *ps_cache = session.get_ps_cache();