From 9aa337ba9ee43d5a602bdb2271743d1a3dbb59b7 Mon Sep 17 00:00:00 2001 From: lf0 Date: Thu, 17 Mar 2022 15:10:54 +0800 Subject: [PATCH] Fix FastParserRes memory leak caused by remote plan --- src/sql/ob_sql.cpp | 11 +++++------ src/sql/plan_cache/ob_plan_cache_util.h | 11 +++++++---- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/sql/ob_sql.cpp b/src/sql/ob_sql.cpp index 417081b0f4..b82f5ce2ea 100644 --- a/src/sql/ob_sql.cpp +++ b/src/sql/ob_sql.cpp @@ -1071,6 +1071,9 @@ int ObSql::handle_remote_query(const ObRemoteSqlInfo &remote_sql_info, ObSqlCtx // is recorded on the control server, and there is no need to record it here // Otherwise it will cause repeated warning messages ob_reset_tsi_warning_buffer(); + if (NULL != pc_ctx) { + pc_ctx->~ObPlanCacheCtx(); + } return ret; } @@ -1216,12 +1219,8 @@ inline int ObSql::handle_text_query(const ObString &stmt, ObSqlCtx &context, ObR LOG_WARN("fail to handle after get plan", K(ret)); } } - // for inner sql, release the optimization memory - if (!THIS_WORKER.has_req_flag()) { - // only for inner sql - if (NULL != pc_ctx) { - pc_ctx->~ObPlanCacheCtx(); - } + if (NULL != pc_ctx) { + pc_ctx->~ObPlanCacheCtx(); } return ret; diff --git a/src/sql/plan_cache/ob_plan_cache_util.h b/src/sql/plan_cache/ob_plan_cache_util.h index 57065fde2f..3b89183bcc 100644 --- a/src/sql/plan_cache/ob_plan_cache_util.h +++ b/src/sql/plan_cache/ob_plan_cache_util.h @@ -385,14 +385,17 @@ struct ObPCParamEqualInfo { }; struct ObFastParserResult { +private: + common::ModulePageAllocator inner_alloc_; + +public: ObFastParserResult() : inner_alloc_("FastParserRes"), raw_params_(&inner_alloc_), ps_params_(&inner_alloc_), cache_params_(NULL) {} ObPlanCacheKey pc_key_; // plan cache key, parameterized by fast parser - common::ModulePageAllocator inner_alloc_; - common::ObFixedArray raw_params_; - common::ObFixedArray ps_params_; - ParamStore* cache_params_; + common::ObFixedArray raw_params_; + common::ObFixedArray ps_params_; + ParamStore *cache_params_; void reset() { pc_key_.reset(); -- GitLab