[CP] [to #46479597] use hint query_timeout to fill_cursor

This commit is contained in:
LiuYoung00 2024-03-14 02:50:29 +00:00 committed by ob-robot
parent 126c1d5744
commit 702989b21d
3 changed files with 19 additions and 7 deletions

View File

@ -1628,7 +1628,7 @@ int ObPLDbmsSql::fill_dbms_cursor(ObSQLSessionInfo *session,
// 2.* fill row store
if (cursor->is_streaming()) {
// we can't reopen the cursor, so if fill cursor has error. we will report to client.
OZ (ObSPIService::fill_cursor(*(cursor->get_cursor_handler()->get_result_set()), spi_cursor));
OZ (ObSPIService::fill_cursor(*(cursor->get_cursor_handler()->get_result_set()), spi_cursor, 0));
} else {
ObSPICursor *orig_spi_cursor = cursor->get_spi_cursor();
for (int64_t i = 0; OB_SUCC(ret) && i < orig_spi_cursor->fields_.count(); ++i) {

View File

@ -3677,7 +3677,8 @@ int ObSPIService::spi_cursor_open(ObPLExecCtx *ctx,
OZ (spi_result.start_nested_stmt_if_need(ctx, sqlstr, static_cast<stmt::StmtType>(type), for_update));
int64_t old_query_start_time = session_info->get_query_start_time();
// query_start_time_ set to 0 in begin_nested_session, here we reset it.
session_info->set_query_start_time(ObTimeUtility::current_time());
int64_t new_query_start_time = ObTimeUtility::current_time();
session_info->set_query_start_time(new_query_start_time);
if (OB_SUCC(ret)) {
ObQueryRetryCtrl retry_ctrl;
int64_t tenant_version = 0;
@ -3728,7 +3729,7 @@ int ObSPIService::spi_cursor_open(ObPLExecCtx *ctx,
spi_result.get_result_set()->get_field_columns(),
spi_cursor->fields_));
//}
OZ (fill_cursor(*spi_result.get_result_set(), spi_cursor));
OZ (fill_cursor(*spi_result.get_result_set(), spi_cursor, new_query_start_time));
if (OB_FAIL(ret) && OB_NOT_NULL(spi_result.get_result_set())) {
int cli_ret = OB_SUCCESS;
retry_ctrl.test_and_save_retry_state(GCTX,
@ -3987,7 +3988,8 @@ int ObSPIService::dbms_cursor_open(ObPLExecCtx *ctx,
int64_t sys_version = 0;
int64_t retry_cnt = 0;
int64_t old_query_start_time = session->get_query_start_time();
session->set_query_start_time(ObTimeUtility::current_time());
int64_t new_query_start_time = ObTimeUtility::current_time();
session->set_query_start_time(new_query_start_time);
do {
ret = OB_SUCCESS;
if (retry_cnt > 0) {
@ -4018,7 +4020,7 @@ int ObSPIService::dbms_cursor_open(ObPLExecCtx *ctx,
cursor.set_packed(plan->is_packed());
}
}
OZ (fill_cursor(*spi_result.get_result_set(), spi_cursor));
OZ (fill_cursor(*spi_result.get_result_set(), spi_cursor, new_query_start_time));
if (OB_FAIL(ret) && OB_NOT_NULL(spi_result.get_result_set())) {
int cli_ret = OB_SUCCESS;
retry_ctrl.test_and_save_retry_state(GCTX,
@ -8123,9 +8125,10 @@ int ObSPIService::store_datum(int64_t &current_addr, const ObObj &obj, ObSQLSess
return ret;
}
int ObSPIService::fill_cursor(ObResultSet &result_set, ObSPICursor *cursor)
int ObSPIService::fill_cursor(ObResultSet &result_set, ObSPICursor *cursor, int64_t new_query_start_time)
{
int ret = OB_SUCCESS;
int64_t old_time_out_ts = THIS_WORKER.get_timeout_ts();
if (OB_ISNULL(cursor) || OB_ISNULL(cursor->allocator_)) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("Argument passed in is NULL", K(cursor), K(ret));
@ -8136,6 +8139,14 @@ int ObSPIService::fill_cursor(ObResultSet &result_set, ObSPICursor *cursor)
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid argument", K(ret));
}
if (OB_NOT_NULL(result_set.get_physical_plan()) && new_query_start_time > 0) {
// fill_dbms_cursor do not need check hint , so only new_query_start_time > 0 will check hint timeout
ObPhysicalPlan *plan = result_set.get_physical_plan();
if (plan->get_phy_plan_hint().query_timeout_ > 0) {
old_time_out_ts = THIS_WORKER.get_timeout_ts();
THIS_WORKER.set_timeout_ts(new_query_start_time + plan->get_phy_plan_hint().query_timeout_);
}
}
for (int64_t i = 0; OB_SUCC(ret) && i < fields->count(); ++i) {
ObDataType type;
type.set_meta_type(fields->at(i).type_.get_meta());
@ -8176,6 +8187,7 @@ int ObSPIService::fill_cursor(ObResultSet &result_set, ObSPICursor *cursor)
LOG_WARN("read result error", K(ret));
}
}
THIS_WORKER.set_timeout_ts(old_time_out_ts);
return ret;
}

View File

@ -739,7 +739,7 @@ public:
ObSPIOutParams &out_params);
static void adjust_pl_status_for_xa(sql::ObExecContext &ctx, int &result);
static int fill_cursor(ObResultSet &result_set, ObSPICursor *cursor);
static int fill_cursor(ObResultSet &result_set, ObSPICursor *cursor, int64_t new_query_start_time);
#ifdef OB_BUILD_ORACLE_PL
static int spi_execute_dblink(pl::ObPLExecCtx *ctx,