[CP] [BUG.FIX] fix io buffer memory lifecycle

This commit is contained in:
Tyshawn 2024-10-17 17:46:37 +00:00 committed by ob-robot
parent 50904f047f
commit bace82ca6c
6 changed files with 14 additions and 5 deletions

View File

@ -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
} // namespace oceanbase

View File

@ -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();

View File

@ -1126,6 +1126,9 @@ int ObIndexBlockTreeCursor::load_micro_block_data(const MacroBlockId &macro_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 &macro_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<char*>(io_allocator.alloc(read_info.size_)))) {
ret = OB_ALLOCATE_MEMORY_FAILED;

View File

@ -34,6 +34,7 @@ ObBloomFilterMacroBlockReader::ObBloomFilterMacroBlockReader(const bool is_sys_r
ObBloomFilterMacroBlockReader::~ObBloomFilterMacroBlockReader()
{
reset();
}
void ObBloomFilterMacroBlockReader::reset()

View File

@ -69,7 +69,7 @@ class ObIndexBlockMicroIterator
{
public:
ObIndexBlockMicroIterator();
virtual ~ObIndexBlockMicroIterator() {}
virtual ~ObIndexBlockMicroIterator() { reset(); }
int init(
const blocksstable::ObMacroBlockDesc &macro_desc,

View File

@ -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<char*>(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_));