Fix memory leak and memory expansion in das group scan.

This commit is contained in:
obdev 2023-05-09 18:04:57 +00:00 committed by ob-robot
parent c1413102b0
commit 0ac5e967aa
3 changed files with 10 additions and 2 deletions

View File

@ -32,6 +32,12 @@ ObDASGroupScanOp::ObDASGroupScanOp(ObIAllocator &op_alloc)
ObDASGroupScanOp::~ObDASGroupScanOp()
{
if (nullptr != group_lookup_op_) {
group_lookup_op_->~ObGroupLookupOp();
//Memory of lookupop come from op_alloc,We do not need free,just set ptr to null.
group_lookup_op_ = nullptr;
}
if (result_iter_ != nullptr && result_iter_->get_type() == ObNewRowIterator::ObTableScanIterator) {
LOG_ERROR_RET(OB_ERR_UNEXPECTED, "table group scan iter is not released, maybe some bug occured",
KPC(scan_ctdef_), K(scan_param_), KPC(scan_rtdef_));

View File

@ -39,8 +39,7 @@ int ObGroupResultRows::init(const common::ObIArray<ObExpr *> &exprs,
reuse_alloc_ = new(reuse_alloc_buf_) common::ObArenaAllocator();
reuse_alloc_->set_attr(attr);
}
//rows_ = static_cast<LastDASStoreRow *>(reuse_alloc_->alloc(max_size * sizeof(LastDASStoreRow)));
rows_ = static_cast<LastDASStoreRow *>(das_op_allocator.alloc(max_size * sizeof(LastDASStoreRow)));
rows_ = static_cast<LastDASStoreRow *>(reuse_alloc_->alloc(max_size * sizeof(LastDASStoreRow)));
if (NULL == rows_) {
ret = OB_ALLOCATE_MEMORY_FAILED;
LOG_WARN("fail to alloc memory", K(max_size), K(ret));

View File

@ -27,6 +27,8 @@ public:
{
}
~ObGroupResultRows() { reset(); }
int init(const common::ObIArray<ObExpr *> &exprs,
ObEvalCtx &eval_ctx,
common::ObIAllocator &das_op_allocator,
@ -91,6 +93,7 @@ class ObGroupScanIter : public ObNewRowIterator
OB_UNIS_VERSION(1);
public:
ObGroupScanIter();
virtual ~ObGroupScanIter() = default;
//virtual int rescan() override;
int switch_scan_group();
int set_scan_group(int64_t group_id);