提交 7122a4bf 编写于 作者: T Tyshawn 提交者: wangzelin.wzl

[Tmp.File] fix some memory leak issue.

上级 2cc75c49
......@@ -168,6 +168,9 @@ int ObTmpPageCache::prefetch(
}
}
}
if (OB_FAIL(ret) && OB_NOT_NULL(buf)) {
allocator_.free(buf);
}
}
return ret;
}
......@@ -732,6 +735,8 @@ int ObTmpTenantMemBlockManager::free_macro_block(const int64_t block_id)
STORAGE_LOG(WARN, "invalid argument", K(ret), K(block_id));
} else if (OB_FAIL(t_mblk_map_.erase_refactored(block_id))) {
STORAGE_LOG(WARN, "fail to erase tmp macro block", K(ret));
} else {
free_page_nums_ -= mblk_page_nums_;
}
return ret;
}
......@@ -959,12 +964,10 @@ int ObTmpTenantMemBlockManager::wash_with_no_wait(const uint64_t tenant_id, ObTm
} else if (NULL == wash_block) {
STORAGE_LOG(WARN, "The washing block is null", K(ret));
} else {
int64_t free_page_nums = wash_block->get_free_page_nums();
bool is_all_close = false;
if (OB_FAIL(wash_block->close(is_all_close))) {
STORAGE_LOG(WARN, "fail to close the wash block", K(ret));
} else if (is_all_close) {
free_page_nums_ = free_page_nums_ + wash_block->get_free_page_nums() - free_page_nums;
if (wash_block->is_empty()) {
// this block don't need to wash.
if (OB_FAIL(refresh_dir_to_blk_map(wash_block->get_dir_id(), wash_block))) {
......
......@@ -564,11 +564,11 @@ int ObTmpTenantMacroBlockManager::alloc_macro_block(
if (OB_FAIL(ret)) {
if (NULL != t_mblk) {
int tmp_ret = OB_SUCCESS;
t_mblk->~ObTmpMacroBlock();
allocator_->free(block_buf);
if (OB_SUCCESS != (tmp_ret = blocks_.erase_refactored(t_mblk->get_block_id()))) {
STORAGE_LOG(WARN, "fail to erase from tmp macro block map", K(tmp_ret), K(t_mblk));
}
t_mblk->~ObTmpMacroBlock();
allocator_->free(block_buf);
}
}
return ret;
......@@ -953,6 +953,7 @@ int ObTmpTenantFileStore::free_macro_block(ObTmpMacroBlock*& t_mblk)
int ObTmpTenantFileStore::alloc_macro_block(const int64_t dir_id, const uint64_t tenant_id, ObTmpMacroBlock*& t_mblk)
{
int ret = OB_SUCCESS;
t_mblk = nullptr;
if (OB_UNLIKELY(!is_inited_)) {
ret = OB_NOT_INIT;
STORAGE_LOG(WARN, "ObTmpMacroBlockManager has not been inited", K(ret));
......@@ -973,7 +974,11 @@ int ObTmpTenantFileStore::alloc_macro_block(const int64_t dir_id, const uint64_t
t_mblk->give_back_buf_into_cache();
}
}
if (OB_FAIL(ret) && OB_NOT_NULL(t_mblk)) {
allocator_.free(t_mblk);
}
}
return ret;
}
......@@ -1266,7 +1271,7 @@ int ObTmpFileStore::free_tenant_file_store(const uint64_t tenant_id)
}
} else if (OB_ISNULL(store)) {
ret = OB_ERR_UNEXPECTED;
STORAGE_LOG(WARN, "unexcepted error, store is null", K(ret));
STORAGE_LOG(WARN, "unexpected error, store is null", K(ret));
} else {
store->~ObTmpTenantFileStore();
allocator_.free(store);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册