explain statement should not be throttled by PxAdmission module

This commit is contained in:
raywill
2023-02-24 13:35:58 +00:00
committed by ob-robot
parent 7d210c667b
commit e44e4b0bbe
3 changed files with 16 additions and 3 deletions

View File

@ -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<ObAddr, int64_t> &req_px_worker_map = plan.get_expected_worker_map();
ObHashMap<ObAddr, int64_t> &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<ObAddr, int64_t> &addr_map = exec_ctx.get_admission_addr_map();

View File

@ -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,

View File

@ -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)