From 00672c3c730c3df6eef3b359eae548d8c2db5ea2 Mon Sep 17 00:00:00 2001 From: jh Date: Tue, 22 Jun 2021 20:29:47 +0800 Subject: [PATCH] fix plan cache memleak for add local plan route --- src/sql/plan_cache/ob_plan_set.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/sql/plan_cache/ob_plan_set.cpp b/src/sql/plan_cache/ob_plan_set.cpp index 2f94826b2..b99d46bcc 100644 --- a/src/sql/plan_cache/ob_plan_set.cpp +++ b/src/sql/plan_cache/ob_plan_set.cpp @@ -901,14 +901,18 @@ int ObSqlPlanSet::add_plan(ObPhysicalPlan& plan, ObPlanCacheCtx& pc_ctx, int64_t array_binding_plan_ = &plan; } } else { - local_plan_ = &plan; - local_phy_locations_.reset(); - if (OB_FAIL(init_phy_location(phy_locations.count()))) { - SQL_PC_LOG(WARN, "init phy location failed"); - } else if (OB_FAIL(local_phy_locations_.assign(phy_locations))) { - SQL_PC_LOG(WARN, "fail to assign phy locations"); + if (NULL != local_plan_) { + ret = OB_SQL_PC_PLAN_DUPLICATE; + } else { + local_plan_ = &plan; + local_phy_locations_.reset(); + if (OB_FAIL(init_phy_location(phy_locations.count()))) { + SQL_PC_LOG(WARN, "init phy location failed"); + } else if (OB_FAIL(local_phy_locations_.assign(phy_locations))) { + SQL_PC_LOG(WARN, "fail to assign phy locations"); + } + LOG_DEBUG("local phy locations", K(local_phy_locations_)); } - LOG_DEBUG("local phy locations", K(local_phy_locations_)); } } break; case OB_PHY_PLAN_REMOTE: { -- GitLab