[Tmp.File] fix some memory leak issue.

This commit is contained in:
Tyshawn
2021-09-02 17:11:06 +08:00
committed by wangzelin.wzl
parent 2cc75c49ce
commit 7122a4bf58
2 changed files with 13 additions and 5 deletions

View File

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