set dblink timeout

This commit is contained in:
obdev 2023-03-07 08:40:52 +00:00 committed by ob-robot
parent 29a5dd5a5f
commit f7714fcb55
2 changed files with 20 additions and 2 deletions

View File

@ -191,10 +191,24 @@ int ObLogLink::set_link_stmt(const ObDMLStmt* stmt)
ObObjPrintParams print_param;
print_param.for_dblink_ = 1;
ObOptimizerContext *opt_ctx = NULL;
ObQueryCtx *query_ctx = NULL;
ObSQLSessionInfo *session = NULL;
int64_t session_query_timeout_us = 0;
int64_t hint_query_timeout_us = 0;
if (OB_ISNULL(stmt) || OB_ISNULL(plan) ||
OB_ISNULL(opt_ctx = &get_plan()->get_optimizer_context())) {
OB_ISNULL(opt_ctx = &get_plan()->get_optimizer_context()) ||
OB_ISNULL(session = opt_ctx->get_session_info())) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("get unexpected null", KP(opt_ctx), KP(stmt), KP(plan), K(ret));
LOG_WARN("get unexpected null", KP(opt_ctx), KP(stmt), KP(session), KP(plan), K(ret));
} else if (NULL == (query_ctx = stmt->get_query_ctx())) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("get unexpected null", K(ret));
} else if (FALSE_IT(hint_query_timeout_us = query_ctx->get_query_hint_for_update().get_global_hint().query_timeout_)) {
} else if (OB_FAIL(session->get_query_timeout(session_query_timeout_us))) {
LOG_WARN("failed to get session query timeout", K(ret));
} else if (-1 == hint_query_timeout_us &&
FALSE_IT(query_ctx->get_query_hint_for_update().get_global_hint().merge_query_timeout_hint(session_query_timeout_us))) {
// do nothing
} else if (OB_FAIL(mark_exec_params(const_cast<ObDMLStmt*>(stmt)))) {
LOG_WARN("failed to mark exec params", K(ret));
} else if (OB_FAIL(ObSQLUtils::reconstruct_sql(plan->get_allocator(), stmt, sql, opt_ctx->get_schema_guard(), print_param))) {
@ -204,6 +218,9 @@ int ObLogLink::set_link_stmt(const ObDMLStmt* stmt)
stmt_fmt_len_ = sql.length();
LOG_DEBUG("loglink succ to reconstruct link sql", K(sql));
}
if (-1 == hint_query_timeout_us) { // restore query_timeout_hint
query_ctx->get_query_hint_for_update().get_global_hint().reset_query_timeout_hint();
}
return ret;
}

View File

@ -133,6 +133,7 @@ struct ObGlobalHint {
int merge_dop_hint(uint64_t dfo, uint64_t dop);
int merge_dop_hint(const ObIArray<ObDopHint> &dop_hints);
void merge_query_timeout_hint(int64_t hint_time);
void reset_query_timeout_hint() { query_timeout_ = -1; }
void merge_dblink_info_hint(int64_t tx_id, int64_t tm_sessid);
void reset_dblink_info_hint();
void merge_max_concurrent_hint(int64_t max_concurrent);