diff --git a/src/storage/blocksstable/index_block/ob_clustered_index_block_writer.cpp b/src/storage/blocksstable/index_block/ob_clustered_index_block_writer.cpp index 4a5182d0e6..f50cdf7eb9 100644 --- a/src/storage/blocksstable/index_block/ob_clustered_index_block_writer.cpp +++ b/src/storage/blocksstable/index_block/ob_clustered_index_block_writer.cpp @@ -311,6 +311,7 @@ int ObClusteredIndexBlockWriter::rewrite_and_append_clustered_index_micro_block( LOG_DEBUG("succeed to make clustered index micro block in rebuilder", K(ret), K(macro_meta)); } + object_handle.reset(); // Recycle buffer. if (OB_NOT_NULL(micro_buf)) { macro_block_io_allocator_.free(micro_buf); @@ -682,4 +683,4 @@ int ObClusteredIndexBlockWriter::print_macro_ids() } } // namespace blocksstable -} // namespace oceanbase \ No newline at end of file +} // namespace oceanbase diff --git a/src/storage/blocksstable/index_block/ob_index_block_macro_iterator.cpp b/src/storage/blocksstable/index_block/ob_index_block_macro_iterator.cpp index 0eaefc833c..db644d838d 100644 --- a/src/storage/blocksstable/index_block/ob_index_block_macro_iterator.cpp +++ b/src/storage/blocksstable/index_block/ob_index_block_macro_iterator.cpp @@ -735,9 +735,12 @@ int ObIndexBlockMacroIterator::get_cs_range( int64_t data_begin = 0; int64_t data_end = 0; int64_t micro_start_row_offset = 0; + + // Need to pay attention!!! + // The allocator is used to allocate io data buffer, and its memory life cycle needs to be longer than the object handle. + common::ObArenaAllocator io_allocator("cs_range"); ObStorageObjectHandle macro_handle; ObStorageObjectReadInfo read_info; - common::ObArenaAllocator io_allocator("cs_range"); read_info.offset_ = sstable_->get_macro_offset(); read_info.size_ = sstable_->get_macro_read_size(); diff --git a/src/storage/blocksstable/index_block/ob_index_block_tree_cursor.cpp b/src/storage/blocksstable/index_block/ob_index_block_tree_cursor.cpp index 5f95608086..236f4c47e0 100644 --- a/src/storage/blocksstable/index_block/ob_index_block_tree_cursor.cpp +++ b/src/storage/blocksstable/index_block/ob_index_block_tree_cursor.cpp @@ -1126,6 +1126,9 @@ int ObIndexBlockTreeCursor::load_micro_block_data(const MacroBlockId ¯o_bloc // TODO: optimize with prefetch // Cache miss, read in sync IO int ret = OB_SUCCESS; + // Need to pay attention!!! + // The allocator is used to allocate io data buffer, and its memory life cycle needs to be longer than the object handle. + ObArenaAllocator io_allocator("IBTC_IOUB", OB_MALLOC_NORMAL_BLOCK_SIZE, tenant_id_); ObStorageObjectHandle macro_handle; ObMacroBlockReader macro_reader; ObStorageObjectReadInfo read_info; @@ -1141,7 +1144,6 @@ int ObIndexBlockTreeCursor::load_micro_block_data(const MacroBlockId ¯o_bloc read_info.mtl_tenant_id_ = MTL_ID(); idx_row_header.fill_deserialize_meta(block_des_meta); - ObArenaAllocator io_allocator("IBTC_IOUB", OB_MALLOC_NORMAL_BLOCK_SIZE, tenant_id_); if (OB_ISNULL(read_info.buf_ = reinterpret_cast(io_allocator.alloc(read_info.size_)))) { ret = OB_ALLOCATE_MEMORY_FAILED; diff --git a/src/storage/blocksstable/ob_bloom_filter_data_reader.cpp b/src/storage/blocksstable/ob_bloom_filter_data_reader.cpp index cd37bfb698..d7f5fa27aa 100644 --- a/src/storage/blocksstable/ob_bloom_filter_data_reader.cpp +++ b/src/storage/blocksstable/ob_bloom_filter_data_reader.cpp @@ -34,6 +34,7 @@ ObBloomFilterMacroBlockReader::ObBloomFilterMacroBlockReader(const bool is_sys_r ObBloomFilterMacroBlockReader::~ObBloomFilterMacroBlockReader() { + reset(); } void ObBloomFilterMacroBlockReader::reset() diff --git a/src/storage/compaction/ob_index_block_micro_iterator.h b/src/storage/compaction/ob_index_block_micro_iterator.h index 82cd7e30f7..d84df7d64b 100644 --- a/src/storage/compaction/ob_index_block_micro_iterator.h +++ b/src/storage/compaction/ob_index_block_micro_iterator.h @@ -69,7 +69,7 @@ class ObIndexBlockMicroIterator { public: ObIndexBlockMicroIterator(); - virtual ~ObIndexBlockMicroIterator() {} + virtual ~ObIndexBlockMicroIterator() { reset(); } int init( const blocksstable::ObMacroBlockDesc ¯o_desc, diff --git a/src/storage/slog_ckpt/ob_linked_macro_block_reader.cpp b/src/storage/slog_ckpt/ob_linked_macro_block_reader.cpp index d5b44494f9..b69741823b 100644 --- a/src/storage/slog_ckpt/ob_linked_macro_block_reader.cpp +++ b/src/storage/slog_ckpt/ob_linked_macro_block_reader.cpp @@ -65,6 +65,9 @@ int ObLinkedMacroBlockReader::init(const MacroBlockId &entry_block, const ObMemA int ObLinkedMacroBlockReader::get_meta_blocks(const MacroBlockId &entry_block) { int ret = OB_SUCCESS; + // Need to pay attention!!! + // The allocator is used to allocate io data buffer, and its memory life cycle needs to be longer than the object handle. + common::ObArenaAllocator allocator; ObMacroBlockCommonHeader common_header; ObStorageObjectReadInfo read_info; read_info.offset_ = 0; @@ -80,7 +83,6 @@ int ObLinkedMacroBlockReader::get_meta_blocks(const MacroBlockId &entry_block) int64_t handle_pos = 0; MacroBlockId previous_block_id; handles_[handle_pos].reset(); - common::ObArenaAllocator allocator; if (OB_ISNULL(read_info.buf_ = reinterpret_cast(allocator.alloc(read_info.size_)))) { ret = OB_ALLOCATE_MEMORY_FAILED; STORAGE_LOG(WARN, "failed to alloc macro read info buffer", K(ret), K(read_info.size_));