From d39cfe867fa181d005a87680f7faf3828178601e Mon Sep 17 00:00:00 2001 From: obdev Date: Tue, 6 Feb 2024 21:59:26 +0000 Subject: [PATCH] Fix memory of DecoderCtx not free as expected --- src/storage/blocksstable/ob_micro_block_row_scanner.h | 6 +++++- src/storage/column_store/ob_cg_scanner.cpp | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/storage/blocksstable/ob_micro_block_row_scanner.h b/src/storage/blocksstable/ob_micro_block_row_scanner.h index e870cd7bdf..b936e0ad76 100644 --- a/src/storage/blocksstable/ob_micro_block_row_scanner.h +++ b/src/storage/blocksstable/ob_micro_block_row_scanner.h @@ -115,7 +115,11 @@ public: const int64_t row_cap, storage::ObGroupByCell &group_by_cell) const; OB_INLINE void reserve_reader_memory(bool reserve) - { reader_->reserve_reader_memory(reserve); } + { + if (nullptr != reader_) { + reader_->reserve_reader_memory(reserve); + } + } int64_t get_current_pos() const { return current_; } VIRTUAL_TO_STRING_KV(K_(can_ignore_multi_version)); diff --git a/src/storage/column_store/ob_cg_scanner.cpp b/src/storage/column_store/ob_cg_scanner.cpp index f0459f1f20..fa64ab0834 100644 --- a/src/storage/column_store/ob_cg_scanner.cpp +++ b/src/storage/column_store/ob_cg_scanner.cpp @@ -548,6 +548,9 @@ int ObCGRowScanner::get_next_rows(uint64_t &count, const uint64_t capacity, cons } else { int64_t batch_size = MIN(iter_param_->op_->get_batch_size(), capacity); prefetcher_.recycle_block_data(); + if (nullptr != micro_scanner_) { + micro_scanner_->reserve_reader_memory(false); + } while (OB_SUCC(ret) && count < batch_size) { if (OB_FAIL(prefetcher_.prefetch())) { LOG_WARN("Fail to prefetch micro block", K(ret), K_(prefetcher)); @@ -567,9 +570,6 @@ int ObCGRowScanner::get_next_rows(uint64_t &count, const uint64_t capacity, cons } } } - if (OB_SUCC(ret) && nullptr != micro_scanner_) { - micro_scanner_->reserve_reader_memory(false); - } } if (count > 0 && datum_infos_.count() > 0) { LOG_TRACE("[COLUMNSTORE] get next rows in cg", K(ret), K_(query_index_range), K_(current), K(count),