From 5f403ea6eac626c909005b13bb32ead3e03790e0 Mon Sep 17 00:00:00 2001 From: obdev Date: Fri, 28 Apr 2023 08:12:04 +0000 Subject: [PATCH] Fix memory leak because fix memory expansion --- src/sql/das/ob_das_group_scan_op.cpp | 11 ++++++++++- src/sql/das/ob_das_group_scan_op.h | 2 ++ src/sql/das/ob_das_scan_op.cpp | 1 + src/sql/das/ob_group_scan_iter.cpp | 3 ++- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/sql/das/ob_das_group_scan_op.cpp b/src/sql/das/ob_das_group_scan_op.cpp index 1df48f16d9..90cc49f453 100644 --- a/src/sql/das/ob_das_group_scan_op.cpp +++ b/src/sql/das/ob_das_group_scan_op.cpp @@ -362,7 +362,16 @@ int ObGroupLookupOp::set_lookup_scan_group(int64_t group_id) return ret; } - +int ObGroupLookupOp::revert_iter() +{ + int ret = OB_SUCCESS; + if (OB_FAIL(ObLocalIndexLookupOp::revert_iter())) { + LOG_WARN("revert ObLocalIndexLookupOp fail",K(ret)); + } else { + group_iter_.reset(); + } + return ret; +} OB_SERIALIZE_MEMBER((ObDASGroupScanOp, ObDASScanOp), iter_, cur_group_idx_, group_size_); diff --git a/src/sql/das/ob_das_group_scan_op.h b/src/sql/das/ob_das_group_scan_op.h index fb15da4729..30d39b895e 100644 --- a/src/sql/das/ob_das_group_scan_op.h +++ b/src/sql/das/ob_das_group_scan_op.h @@ -54,6 +54,8 @@ public: ObExpr *group_id_expr); virtual int switch_lookup_scan_group() override; virtual int set_lookup_scan_group(int64_t group_id) override; + + int revert_iter(); public: ObGroupScanIter group_iter_; }; diff --git a/src/sql/das/ob_das_scan_op.cpp b/src/sql/das/ob_das_scan_op.cpp index 014cf5f15a..55cb69292a 100644 --- a/src/sql/das/ob_das_scan_op.cpp +++ b/src/sql/das/ob_das_scan_op.cpp @@ -1197,6 +1197,7 @@ int ObLocalIndexLookupOp::revert_iter() LOG_WARN("revert scan iterator failed", K(ret)); } //release the memory hold by local index lookup op + rowkey_iter_ = NULL; lookup_iter_ = NULL; scan_param_.destroy_schema_guard(); diff --git a/src/sql/das/ob_group_scan_iter.cpp b/src/sql/das/ob_group_scan_iter.cpp index e6ff704cd5..bc0288b0ad 100644 --- a/src/sql/das/ob_group_scan_iter.cpp +++ b/src/sql/das/ob_group_scan_iter.cpp @@ -39,7 +39,8 @@ int ObGroupResultRows::init(const common::ObIArray &exprs, reuse_alloc_ = new(reuse_alloc_buf_) common::ObArenaAllocator(); reuse_alloc_->set_attr(attr); } - rows_ = static_cast(reuse_alloc_->alloc(max_size * sizeof(LastDASStoreRow))); + //rows_ = static_cast(reuse_alloc_->alloc(max_size * sizeof(LastDASStoreRow))); + rows_ = static_cast(das_op_allocator.alloc(max_size * sizeof(LastDASStoreRow))); if (NULL == rows_) { ret = OB_ALLOCATE_MEMORY_FAILED; LOG_WARN("fail to alloc memory", K(max_size), K(ret));