From b50711c1bf7b34d803738c3c1befbfa903faa3df Mon Sep 17 00:00:00 2001 From: obdev Date: Wed, 7 Feb 2024 23:15:08 +0000 Subject: [PATCH] Plan Cache adds tracepoint and throws an error code when it fails. --- deps/oblib/src/lib/utility/ob_tracepoint.h | 1 + src/sql/ob_sql.cpp | 23 ++++++++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/deps/oblib/src/lib/utility/ob_tracepoint.h b/deps/oblib/src/lib/utility/ob_tracepoint.h index a9e261a1c0..510e22b523 100644 --- a/deps/oblib/src/lib/utility/ob_tracepoint.h +++ b/deps/oblib/src/lib/utility/ob_tracepoint.h @@ -754,6 +754,7 @@ class EventTable // sql parameterization 1170-1180 EN_SQL_PARAM_FP_NP_NOT_SAME_ERROR = 1170, EN_FLUSH_PC_NOT_CLEANUP_LEAK_MEM_ERROR = 1171, + EN_PC_NOT_SWALLOW_ERROR = 1172, // END OF sql parameterization 1170-1180 // session info verification diff --git a/src/sql/ob_sql.cpp b/src/sql/ob_sql.cpp index 2f2c2dc4e3..8e2649d1c3 100644 --- a/src/sql/ob_sql.cpp +++ b/src/sql/ob_sql.cpp @@ -3855,7 +3855,16 @@ int ObSql::pc_get_plan(ObPlanCacheCtx &pc_ctx, //inner sql不能丢入大查询队列, 因为有可能上层查询已有数据返回客户端 } else { get_plan_err = ret; - ret = OB_SUCCESS; //get plan出错, 覆盖错误码, 确保因plan cache的错误不影响正常执行路径 + int tmp_ret = OB_SUCCESS; + tmp_ret = OB_E(EventTable::EN_PC_NOT_SWALLOW_ERROR) OB_SUCCESS; + if (OB_SUCCESS != tmp_ret) { + // do nothing + if (OB_SQL_PC_NOT_EXIST == ret) { + ret = OB_SUCCESS; + } + } else { + ret = OB_SUCCESS; //get plan出错, 覆盖错误码, 确保因plan cache的错误不影响正常执行路径 + } } } else { //get plan 成功 plan_cache->inc_hit_and_access_cnt(); @@ -4340,6 +4349,8 @@ int ObSql::pc_add_plan(ObPlanCacheCtx &pc_ctx, ret = OB_REACH_MAX_CONCURRENT_NUM; } + int tmp_ret = OB_SUCCESS; + tmp_ret = OB_E(EventTable::EN_PC_NOT_SWALLOW_ERROR) OB_SUCCESS; if (is_batch_exec) { // Batch optimization cannot continue for errors other than OB_SQL_PC_PLAN_DUPLICATE. if (OB_SQL_PC_PLAN_DUPLICATE == ret) { @@ -4367,9 +4378,13 @@ int ObSql::pc_add_plan(ObPlanCacheCtx &pc_ctx, ret = OB_SUCCESS; LOG_DEBUG("plan cache don't support add this kind of plan now", K(phy_plan)); } else if (OB_FAIL(ret)) { - if (OB_REACH_MAX_CONCURRENT_NUM != ret) { //如果是达到限流上限, 则将错误码抛出去 - ret = OB_SUCCESS; //add plan出错, 覆盖错误码, 确保因plan cache失败不影响正常执行路径 - LOG_WARN("Failed to add plan to ObPlanCache", K(ret)); + if (OB_SUCCESS != tmp_ret) { + + } else { + if (OB_REACH_MAX_CONCURRENT_NUM != ret) { //如果是达到限流上限, 则将错误码抛出去 + ret = OB_SUCCESS; //add plan出错, 覆盖错误码, 确保因plan cache失败不影响正常执行路径 + LOG_WARN("Failed to add plan to ObPlanCache", K(ret)); + } } } else { pc_ctx.sql_ctx_.self_add_plan_ = true;