From e44e4b0bbe96e81467d84d46558cfc037c2eb8c8 Mon Sep 17 00:00:00 2001 From: raywill Date: Fri, 24 Feb 2023 13:35:58 +0000 Subject: [PATCH] explain statement should not be throttled by PxAdmission module --- src/sql/engine/px/ob_px_admission.cpp | 12 ++++++++++-- src/sql/engine/px/ob_px_admission.h | 3 +++ src/sql/ob_result_set.cpp | 4 +++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/sql/engine/px/ob_px_admission.cpp b/src/sql/engine/px/ob_px_admission.cpp index ef2eab2e59..45977457bf 100644 --- a/src/sql/engine/px/ob_px_admission.cpp +++ b/src/sql/engine/px/ob_px_admission.cpp @@ -95,12 +95,16 @@ int64_t ObPxAdmission::admit(ObSQLSessionInfo &session, ObExecContext &exec_ctx, int ObPxAdmission::enter_query_admission(ObSQLSessionInfo &session, ObExecContext &exec_ctx, + sql::stmt::StmtType stmt_type, ObPhysicalPlan &plan) { int ret = OB_SUCCESS; // 对于只有dop=1 的场景跳过检查,因为这种场景走 RPC 线程,不消耗 PX 线程 // https://yuque.antfin-inc.com/ob/sql/xzrw9m - if (plan.is_use_px() && 1 != plan.get_px_dop() && plan.get_expected_worker_count() > 0) { + if (stmt::T_EXPLAIN != stmt_type + && plan.is_use_px() + && 1 != plan.get_px_dop() + && plan.get_expected_worker_count() > 0) { // use for appointment const ObHashMap &req_px_worker_map = plan.get_expected_worker_map(); ObHashMap &acl_px_worker_map = exec_ctx.get_admission_addr_map(); @@ -167,9 +171,13 @@ int ObPxAdmission::enter_query_admission(ObSQLSessionInfo &session, void ObPxAdmission::exit_query_admission(ObSQLSessionInfo &session, ObExecContext &exec_ctx, + sql::stmt::StmtType stmt_type, ObPhysicalPlan &plan) { - if (plan.is_use_px() && 1 != plan.get_px_dop() && exec_ctx.get_admission_version() != UINT64_MAX) { + if (stmt::T_EXPLAIN != stmt_type + && plan.is_use_px() + && 1 != plan.get_px_dop() + && exec_ctx.get_admission_version() != UINT64_MAX) { int ret = OB_SUCCESS; uint64_t tenant_id = session.get_effective_tenant_id(); hash::ObHashMap &addr_map = exec_ctx.get_admission_addr_map(); diff --git a/src/sql/engine/px/ob_px_admission.h b/src/sql/engine/px/ob_px_admission.h index 5d305a8fbd..48b1044854 100644 --- a/src/sql/engine/px/ob_px_admission.h +++ b/src/sql/engine/px/ob_px_admission.h @@ -20,6 +20,7 @@ #include "lib/lock/mutex.h" #include "lib/rc/ob_rc.h" #include "lib/hash/ob_hashset.h" +#include "sql/resolver/ob_stmt_type.h" namespace oceanbase { @@ -44,9 +45,11 @@ public: int64_t req_cnt, int64_t &admit_cnt); static int enter_query_admission(sql::ObSQLSessionInfo &session, sql::ObExecContext &exec_ctx, + sql::stmt::StmtType stmt_type, sql::ObPhysicalPlan &plan); static void exit_query_admission(sql::ObSQLSessionInfo &session, sql::ObExecContext &exec_ctx, + sql::stmt::StmtType stmt_type, sql::ObPhysicalPlan &plan); private: static int get_parallel_session_target(sql::ObSQLSessionInfo &session, diff --git a/src/sql/ob_result_set.cpp b/src/sql/ob_result_set.cpp index 83ea088a28..6a9c012494 100644 --- a/src/sql/ob_result_set.cpp +++ b/src/sql/ob_result_set.cpp @@ -114,8 +114,10 @@ OB_INLINE int ObResultSet::open_plan() if (OB_SUCC(ret)) { if (OB_FAIL(ObPxAdmission::enter_query_admission(my_session_, get_exec_context(), + get_stmt_type(), *get_physical_plan()))) { // query is not admitted to run + // Note: explain statement's phy plan is target query's plan, don't enable admission test LOG_DEBUG("Query is not admitted to run, try again", K(ret)); } else if (THIS_WORKER.is_timeout()) { // packet有可能在队列里面呆的时间过长,到这里已经超时, @@ -717,7 +719,7 @@ OB_INLINE int ObResultSet::do_close_plan(int errcode, ObExecContext &ctx) SQL_LOG(WARN, "fail to close executor", K(ret), K(close_ret)); } - ObPxAdmission::exit_query_admission(my_session_, get_exec_context(), *get_physical_plan()); + ObPxAdmission::exit_query_admission(my_session_, get_exec_context(), get_stmt_type(), *get_physical_plan()); // Finishing direct-insert must be executed after ObPxTargetMgr::release_target() if ((OB_SUCCESS == close_ret) && (OB_SUCCESS == errcode || OB_ITER_END == errcode)