use macro iterator
This commit is contained in:
parent
3b8a815873
commit
b068e93506
@ -76,6 +76,10 @@ TEST_F(TestBlockIdList, test_id_list)
|
||||
// empty set
|
||||
ASSERT_EQ(OB_SUCCESS, info_set.init());
|
||||
ASSERT_EQ(OB_SUCCESS, macro_info.init(allocator, info_set, linked_writer));
|
||||
ASSERT_EQ(0, macro_info.meta_block_info_arr_.cnt_);
|
||||
ASSERT_EQ(0, macro_info.data_block_info_arr_.cnt_);
|
||||
ASSERT_EQ(0, macro_info.shared_meta_block_info_arr_.cnt_);
|
||||
ASSERT_EQ(0, macro_info.shared_data_block_info_arr_.cnt_);
|
||||
|
||||
// normal set
|
||||
macro_info.reset();
|
||||
@ -90,31 +94,6 @@ TEST_F(TestBlockIdList, test_id_list)
|
||||
ASSERT_EQ(1, macro_info.shared_meta_block_info_arr_.cnt_);
|
||||
ASSERT_EQ(1, macro_info.data_block_info_arr_.cnt_);
|
||||
ASSERT_EQ(1, macro_info.meta_block_info_arr_.cnt_);
|
||||
ObSArray<MacroBlockId> meta_block_arr;
|
||||
ObSArray<MacroBlockId> data_block_arr;
|
||||
ObSArray<MacroBlockId> shared_meta_block_arr;
|
||||
ObSArray<MacroBlockId> shared_data_block_arr;
|
||||
ASSERT_EQ(OB_SUCCESS, macro_info.get_all_macro_ids(meta_block_arr, data_block_arr, shared_meta_block_arr, shared_data_block_arr));
|
||||
ASSERT_EQ(macro_id, meta_block_arr.at(0));
|
||||
ASSERT_EQ(macro_id, data_block_arr.at(0));
|
||||
ASSERT_EQ(macro_id, shared_meta_block_arr.at(0));
|
||||
ASSERT_EQ(macro_id, shared_data_block_arr.at(0));
|
||||
|
||||
inc_success = false;
|
||||
ASSERT_EQ(OB_SUCCESS, macro_info.inc_macro_ref(inc_success));
|
||||
ASSERT_EQ(true, inc_success);
|
||||
{
|
||||
ObBucketHashWLockGuard lock_guard(OB_SERVER_BLOCK_MGR.bucket_lock_, macro_id.hash());
|
||||
ASSERT_EQ(OB_SUCCESS, OB_SERVER_BLOCK_MGR.block_map_.get(macro_id, block_info));
|
||||
}
|
||||
ASSERT_EQ(4, block_info.ref_cnt_); // four arrars all have this macro id
|
||||
|
||||
macro_info.dec_macro_ref();
|
||||
{
|
||||
ObBucketHashWLockGuard lock_guard(OB_SERVER_BLOCK_MGR.bucket_lock_, macro_id.hash());
|
||||
ASSERT_EQ(OB_SUCCESS, OB_SERVER_BLOCK_MGR.block_map_.get(macro_id, block_info));
|
||||
}
|
||||
ASSERT_EQ(0, block_info.ref_cnt_);
|
||||
|
||||
info_set.data_block_info_set_.reuse();
|
||||
info_set.meta_block_info_set_.reuse();
|
||||
@ -128,51 +107,10 @@ TEST_F(TestBlockIdList, test_id_list)
|
||||
ASSERT_EQ(OB_SUCCESS, init_info_set(allocator, TEST_LINKED_NUM, info_set));
|
||||
ASSERT_EQ(OB_SUCCESS, macro_info.init(allocator, info_set, linked_writer));
|
||||
ASSERT_EQ(false, IS_EMPTY_BLOCK_LIST(macro_info.entry_block_));
|
||||
meta_block_arr.reset();
|
||||
data_block_arr.reset();
|
||||
shared_meta_block_arr.reset();
|
||||
shared_data_block_arr.reset();
|
||||
ASSERT_EQ(OB_SUCCESS, macro_info.get_all_macro_ids(meta_block_arr, data_block_arr, shared_meta_block_arr, shared_data_block_arr));
|
||||
ASSERT_EQ(TEST_LINKED_NUM, meta_block_arr.count());
|
||||
|
||||
ObIArray<MacroBlockId> &linked_ids = linked_writer.get_meta_block_list();
|
||||
MacroBlockId &linked_id = linked_ids.at(0);
|
||||
{
|
||||
ObBucketHashWLockGuard lock_guard(OB_SERVER_BLOCK_MGR.bucket_lock_, linked_id.hash());
|
||||
ASSERT_EQ(OB_SUCCESS, OB_SERVER_BLOCK_MGR.block_map_.get(linked_id, block_info));
|
||||
}
|
||||
linked_ref_cnt = block_info.ref_cnt_;
|
||||
|
||||
inc_success = false;
|
||||
int64_t linked_macro_ref = 0;
|
||||
ASSERT_EQ(OB_SUCCESS, macro_info.inc_macro_ref(inc_success));
|
||||
ASSERT_EQ(true, inc_success);
|
||||
{
|
||||
ObBucketHashWLockGuard lock_guard(OB_SERVER_BLOCK_MGR.bucket_lock_, macro_id.hash());
|
||||
ASSERT_EQ(OB_SUCCESS, OB_SERVER_BLOCK_MGR.block_map_.get(macro_id, block_info));
|
||||
}
|
||||
ASSERT_EQ(4, block_info.ref_cnt_); // four arrars all have this macro id
|
||||
|
||||
{
|
||||
ObBucketHashWLockGuard lock_guard(OB_SERVER_BLOCK_MGR.bucket_lock_, linked_id.hash());
|
||||
ASSERT_EQ(OB_SUCCESS, OB_SERVER_BLOCK_MGR.block_map_.get(linked_id, block_info));
|
||||
}
|
||||
ASSERT_EQ(linked_ref_cnt + 1, block_info.ref_cnt_);
|
||||
|
||||
inc_success = false;
|
||||
ASSERT_EQ(OB_SUCCESS, macro_info.inc_macro_ref(inc_success));
|
||||
ASSERT_EQ(true, inc_success);
|
||||
{
|
||||
ObBucketHashWLockGuard lock_guard(OB_SERVER_BLOCK_MGR.bucket_lock_, macro_id.hash());
|
||||
ASSERT_EQ(OB_SUCCESS, OB_SERVER_BLOCK_MGR.block_map_.get(macro_id, block_info));
|
||||
}
|
||||
ASSERT_EQ(8, block_info.ref_cnt_);
|
||||
|
||||
{
|
||||
ObBucketHashWLockGuard lock_guard(OB_SERVER_BLOCK_MGR.bucket_lock_, linked_id.hash());
|
||||
ASSERT_EQ(OB_SUCCESS, OB_SERVER_BLOCK_MGR.block_map_.get(linked_id, block_info));
|
||||
}
|
||||
ASSERT_EQ(linked_ref_cnt + 2, block_info.ref_cnt_);
|
||||
ASSERT_EQ(0, macro_info.shared_data_block_info_arr_.cnt_);
|
||||
ASSERT_EQ(0, macro_info.shared_meta_block_info_arr_.cnt_);
|
||||
ASSERT_EQ(0, macro_info.data_block_info_arr_.cnt_);
|
||||
ASSERT_EQ(0, macro_info.meta_block_info_arr_.cnt_);
|
||||
}
|
||||
|
||||
TEST_F(TestBlockIdList, test_serialize_deep_copy)
|
||||
@ -311,38 +249,37 @@ TEST_F(TestBlockIdList, test_meta_macro_ref_cnt)
|
||||
|
||||
TEST_F(TestBlockIdList, test_info_iterator)
|
||||
{
|
||||
int64_t linked_block_num = 0;
|
||||
ObMacroInfoIterator macro_iter;
|
||||
ObLinkedMacroBlockItemWriter linked_writer;
|
||||
ObArenaAllocator allocator;
|
||||
ObTabletBlockInfo block_info;
|
||||
ObTabletID tablet_id(TestIndexBlockDataPrepare::tablet_id_);
|
||||
ObLSID ls_id(ls_id_);
|
||||
ObLSHandle ls_handle;
|
||||
ObTabletHandle tablet_handle;
|
||||
ObLSService *ls_svr = MTL(ObLSService*);
|
||||
ASSERT_EQ(OB_SUCCESS, ls_svr->get_ls(ls_id, ls_handle, ObLSGetMod::STORAGE_MOD));
|
||||
ASSERT_EQ(OB_SUCCESS, ls_handle.get_ls()->get_tablet(tablet_id, tablet_handle));
|
||||
ObTablet *tablet = tablet_handle.get_obj();
|
||||
tablet->macro_info_addr_.addr_.set_mem_addr(0, sizeof(ObTabletMacroInfo));
|
||||
|
||||
// linked macro info
|
||||
ObBlockInfoSet info_set;
|
||||
ObTabletMacroInfo macro_info;
|
||||
tablet->macro_info_addr_.ptr_ = ¯o_info;
|
||||
ASSERT_EQ(OB_SUCCESS, info_set.init());
|
||||
ASSERT_EQ(OB_SUCCESS, init_info_set(allocator, TEST_LINKED_NUM, info_set));
|
||||
ASSERT_EQ(OB_SUCCESS, macro_info.init(allocator, info_set, linked_writer));
|
||||
ASSERT_EQ(OB_SUCCESS, macro_iter.init(ObTabletMacroType::MAX, *tablet));
|
||||
ASSERT_EQ(OB_SUCCESS, macro_iter.init(ObTabletMacroType::MAX, macro_info));
|
||||
for (int64_t i = 0; i < TEST_LINKED_NUM * 4; i++) {
|
||||
block_info.reset();
|
||||
ASSERT_EQ(OB_SUCCESS, macro_iter.get_next(block_info));
|
||||
ASSERT_EQ(OB_HASH_EXIST, info_set.data_block_info_set_.exist_refactored(block_info.macro_id_));
|
||||
}
|
||||
linked_block_num = macro_iter.block_reader_.get_meta_block_list().count();
|
||||
for (int64_t i = 0; i < linked_block_num; i++) {
|
||||
block_info.reset();
|
||||
ASSERT_EQ(OB_SUCCESS, macro_iter.get_next(block_info));
|
||||
ASSERT_EQ(OB_HASH_NOT_EXIST, info_set.data_block_info_set_.exist_refactored(block_info.macro_id_));
|
||||
}
|
||||
ASSERT_EQ(OB_ITER_END, macro_iter.get_next(block_info));
|
||||
|
||||
macro_iter.destroy(); // iterate targeted ids
|
||||
ASSERT_NE(OB_SUCCESS, macro_iter.init(ObTabletMacroType::INVALID_TYPE, *tablet));
|
||||
ASSERT_EQ(OB_SUCCESS, macro_iter.init(ObTabletMacroType::SHARED_DATA_BLOCK, *tablet));
|
||||
ASSERT_NE(OB_SUCCESS, macro_iter.init(ObTabletMacroType::INVALID_TYPE, macro_info));
|
||||
ASSERT_EQ(OB_SUCCESS, macro_iter.init(ObTabletMacroType::SHARED_DATA_BLOCK, macro_info));
|
||||
for (int64_t i = 0; i < TEST_LINKED_NUM; i++) {
|
||||
block_info.reset();
|
||||
ASSERT_EQ(OB_SUCCESS, macro_iter.get_next(block_info));
|
||||
ASSERT_EQ(OB_HASH_EXIST, info_set.data_block_info_set_.exist_refactored(block_info.macro_id_));
|
||||
ASSERT_EQ(ObTabletMacroType::SHARED_DATA_BLOCK, block_info.block_type_);
|
||||
@ -354,20 +291,20 @@ TEST_F(TestBlockIdList, test_info_iterator)
|
||||
linked_writer.reset();
|
||||
ObBlockInfoSet info_set_2;
|
||||
ObTabletMacroInfo macro_info_2;
|
||||
tablet->macro_info_addr_.ptr_ = ¯o_info_2;
|
||||
ASSERT_EQ(OB_SUCCESS, info_set_2.init());
|
||||
ASSERT_EQ(OB_SUCCESS, init_info_set(allocator, 15, info_set_2));
|
||||
ASSERT_EQ(OB_SUCCESS, macro_info_2.init(allocator, info_set_2, linked_writer));
|
||||
macro_iter.destroy();
|
||||
ASSERT_EQ(OB_SUCCESS, macro_iter.init(ObTabletMacroType::MAX, *tablet));
|
||||
ASSERT_EQ(OB_SUCCESS, macro_iter.init(ObTabletMacroType::MAX, macro_info_2));
|
||||
for (int64_t i = 0; i < 60; i++) {
|
||||
block_info.reset();
|
||||
ASSERT_EQ(OB_SUCCESS, macro_iter.get_next(block_info));
|
||||
ASSERT_EQ(OB_HASH_EXIST, info_set_2.data_block_info_set_.exist_refactored(block_info.macro_id_));
|
||||
}
|
||||
ASSERT_EQ(OB_ITER_END, macro_iter.get_next(block_info));
|
||||
|
||||
macro_iter.destroy(); // iterate targeted ids
|
||||
ASSERT_EQ(OB_SUCCESS, macro_iter.init(ObTabletMacroType::META_BLOCK, *tablet));
|
||||
ASSERT_EQ(OB_SUCCESS, macro_iter.init(ObTabletMacroType::META_BLOCK, macro_info_2));
|
||||
for (int64_t i = 0; i < 15; i++) {
|
||||
ASSERT_EQ(OB_SUCCESS, macro_iter.get_next(block_info));
|
||||
ASSERT_EQ(OB_HASH_EXIST, info_set.data_block_info_set_.exist_refactored(block_info.macro_id_));
|
||||
@ -380,18 +317,16 @@ TEST_F(TestBlockIdList, test_info_iterator)
|
||||
linked_writer.reset();
|
||||
ObBlockInfoSet info_set_3;
|
||||
ObTabletMacroInfo macro_info_3;
|
||||
tablet->macro_info_addr_.ptr_ = ¯o_info_3;
|
||||
ASSERT_EQ(OB_SUCCESS, info_set_3.init());
|
||||
ASSERT_EQ(OB_SUCCESS, macro_info_3.init(allocator, info_set_3, linked_writer));
|
||||
macro_iter.destroy();
|
||||
ASSERT_EQ(OB_SUCCESS, macro_iter.init(ObTabletMacroType::MAX, *tablet));
|
||||
ASSERT_EQ(OB_SUCCESS, macro_iter.init(ObTabletMacroType::MAX, macro_info_3));
|
||||
ASSERT_EQ(OB_ITER_END, macro_iter.get_next(block_info));
|
||||
|
||||
// linked macro info without meta_block_id and shared_meta_block_id
|
||||
linked_writer.reset();
|
||||
ObBlockInfoSet info_set_4;
|
||||
ObTabletMacroInfo macro_info_4;
|
||||
tablet->macro_info_addr_.ptr_ = ¯o_info_4;
|
||||
ASSERT_EQ(OB_SUCCESS, info_set_4.init());
|
||||
for (int64_t i = 0; i < ObTabletMacroInfo::ID_COUNT_THRESHOLD; i++) {
|
||||
MacroBlockId tmp_macro_id(i + 1, i + 1, 0);
|
||||
@ -400,18 +335,24 @@ TEST_F(TestBlockIdList, test_info_iterator)
|
||||
}
|
||||
ASSERT_EQ(OB_SUCCESS, macro_info_4.init(allocator, info_set_4, linked_writer));
|
||||
macro_iter.destroy();
|
||||
ASSERT_EQ(OB_SUCCESS, macro_iter.init(ObTabletMacroType::MAX, *tablet));
|
||||
ASSERT_EQ(OB_SUCCESS, macro_iter.init(ObTabletMacroType::MAX, macro_info_4));
|
||||
for (int64_t i = 0; i < ObTabletMacroInfo::ID_COUNT_THRESHOLD * 2; i++) {
|
||||
block_info.reset();
|
||||
ASSERT_EQ(OB_SUCCESS, macro_iter.get_next(block_info));
|
||||
ASSERT_EQ(OB_HASH_EXIST, info_set_4.data_block_info_set_.exist_refactored(block_info.macro_id_));
|
||||
}
|
||||
linked_block_num = macro_iter.block_reader_.get_meta_block_list().count();
|
||||
for (int64_t i = 0; i < linked_block_num; i++) {
|
||||
block_info.reset();
|
||||
ASSERT_EQ(OB_SUCCESS, macro_iter.get_next(block_info));
|
||||
ASSERT_EQ(OB_HASH_NOT_EXIST, info_set_4.data_block_info_set_.exist_refactored(block_info.macro_id_));
|
||||
}
|
||||
ASSERT_EQ(OB_ITER_END, macro_iter.get_next(block_info));
|
||||
|
||||
// memory macro info without meta_block_id and shared_meta_block_id
|
||||
linked_writer.reset();
|
||||
ObBlockInfoSet info_set_5;
|
||||
ObTabletMacroInfo macro_info_5;
|
||||
tablet->macro_info_addr_.ptr_ = ¯o_info_5;
|
||||
static const int64_t memory_id_cnt = 100;
|
||||
ASSERT_EQ(OB_SUCCESS, info_set_5.init());
|
||||
for (int64_t i = 0; i < memory_id_cnt; i++) {
|
||||
@ -421,13 +362,13 @@ TEST_F(TestBlockIdList, test_info_iterator)
|
||||
}
|
||||
ASSERT_EQ(OB_SUCCESS, macro_info_5.init(allocator, info_set_5, linked_writer));
|
||||
macro_iter.destroy();
|
||||
ASSERT_EQ(OB_SUCCESS, macro_iter.init(ObTabletMacroType::MAX, *tablet));
|
||||
ASSERT_EQ(OB_SUCCESS, macro_iter.init(ObTabletMacroType::MAX, macro_info_5));
|
||||
for (int64_t i = 0; i < memory_id_cnt * 2; i++) {
|
||||
block_info.reset();
|
||||
ASSERT_EQ(OB_SUCCESS, macro_iter.get_next(block_info));
|
||||
ASSERT_EQ(OB_HASH_EXIST, info_set_5.data_block_info_set_.exist_refactored(block_info.macro_id_));
|
||||
}
|
||||
ASSERT_EQ(OB_ITER_END, macro_iter.get_next(block_info));
|
||||
tablet->macro_info_addr_.ptr_ = nullptr;
|
||||
}
|
||||
|
||||
TEST_F(TestBlockIdList, test_empty_shell_macro_ref_cnt)
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "storage/ob_super_block_struct.h"
|
||||
#include "storage/slog/ob_storage_logger_manager.h"
|
||||
#include "storage/blocksstable/ob_shared_macro_block_manager.h"
|
||||
#include "storage/tablet/ob_tablet_macro_info_iterator.h"
|
||||
#include "lib/worker.h"
|
||||
|
||||
using namespace oceanbase::common;
|
||||
@ -1284,104 +1285,79 @@ int ObBlockManager::mark_tablet_block(
|
||||
ObMacroBlockMarkerStatus &tmp_status)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObSArray<blocksstable::MacroBlockId> meta_block_arr;
|
||||
ObSArray<blocksstable::MacroBlockId> data_block_arr;
|
||||
ObSArray<blocksstable::MacroBlockId> shared_meta_block_arr;
|
||||
ObSArray<blocksstable::MacroBlockId> shared_data_block_arr;
|
||||
if (OB_FAIL(handle.get_obj()->get_all_macro_ids(
|
||||
meta_block_arr,
|
||||
data_block_arr,
|
||||
shared_meta_block_arr,
|
||||
shared_data_block_arr))) {
|
||||
LOG_WARN("fail to get tablet's macro info", K(ret));
|
||||
} else if (OB_FAIL(do_mark_tablet_block(
|
||||
meta_block_arr,
|
||||
ObTabletMacroType::META_BLOCK,
|
||||
mark_info,
|
||||
macro_id_set,
|
||||
tmp_status))) {
|
||||
LOG_WARN("fail to mark meta block ids", K(ret), K(meta_block_arr));
|
||||
} else if (OB_FAIL(do_mark_tablet_block(
|
||||
data_block_arr,
|
||||
ObTabletMacroType::DATA_BLOCK,
|
||||
mark_info,
|
||||
macro_id_set,
|
||||
tmp_status))) {
|
||||
LOG_WARN("fail to mark meta block ids", K(ret), K(data_block_arr));
|
||||
} else if (OB_FAIL(do_mark_tablet_block(
|
||||
shared_meta_block_arr,
|
||||
ObTabletMacroType::SHARED_META_BLOCK,
|
||||
mark_info,
|
||||
macro_id_set,
|
||||
tmp_status))) {
|
||||
LOG_WARN("fail to mark meta block ids", K(ret), K(shared_meta_block_arr));
|
||||
} else if (OB_FAIL(do_mark_tablet_block(
|
||||
shared_data_block_arr,
|
||||
ObTabletMacroType::SHARED_DATA_BLOCK,
|
||||
mark_info,
|
||||
macro_id_set,
|
||||
tmp_status))) {
|
||||
LOG_WARN("fail to mark meta block ids", K(ret), K(shared_data_block_arr));
|
||||
} else {
|
||||
const ObMetaDiskAddr &addr = handle.get_obj()->get_tablet_addr();
|
||||
if (addr.is_block()) {
|
||||
const MacroBlockId ¯o_id = addr.block_id();
|
||||
if (OB_FAIL(update_mark_info(macro_id, mark_info))) {
|
||||
LOG_WARN("fail to update mark info", K(ret), K(macro_id));
|
||||
} else if (OB_FAIL(macro_id_set.set_refactored(macro_id, 0 /* not overwrite */))) {
|
||||
if (OB_HASH_EXIST != ret) {
|
||||
LOG_WARN("fail to put macro id into set", K(ret), K(macro_id));
|
||||
const ObTablet *tablet = handle.get_obj();
|
||||
ObTabletBlockInfo block_info(tablet->get_tablet_addr().block_id(), ObTabletMacroType::SHARED_META_BLOCK, 0 /*useless param*/);
|
||||
|
||||
if (tablet->get_tablet_addr().is_block() && OB_FAIL(do_mark_tablet_block(block_info, mark_info, macro_id_set, tmp_status))) {
|
||||
LOG_WARN("fail to mark tablet macro id", K(ret), K(block_info));
|
||||
} else if (!tablet->is_empty_shell()) {// empty shell may don't have macro info
|
||||
ObArenaAllocator allocator("MarkTabletBlock");
|
||||
ObTabletMacroInfo *macro_info = nullptr;
|
||||
bool in_memory = true;
|
||||
ObMacroInfoIterator macro_iter;
|
||||
if (OB_FAIL(tablet->load_macro_info(allocator, macro_info, in_memory))) {
|
||||
LOG_WARN("fail to load macro info", K(ret));
|
||||
} else if (OB_FAIL(macro_iter.init(ObTabletMacroType::MAX, *macro_info))) {
|
||||
LOG_WARN("fail to init macro iterator", K(ret), KPC(macro_info));
|
||||
}
|
||||
while (OB_SUCC(ret)) {
|
||||
block_info.reset();
|
||||
if (OB_FAIL(macro_iter.get_next(block_info))) {
|
||||
if (OB_ITER_END != ret) {
|
||||
LOG_WARN("fail to get next block info", K(ret), K(block_info));
|
||||
} else {
|
||||
ret = OB_SUCCESS;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
tmp_status.hold_count_--;
|
||||
tmp_status.shared_meta_block_count_++;
|
||||
} else if (OB_FAIL(do_mark_tablet_block(block_info, mark_info, macro_id_set, tmp_status))) {
|
||||
LOG_WARN("fail to mark macro id", K(ret), K(block_info));
|
||||
}
|
||||
}
|
||||
if (OB_NOT_NULL(macro_info) && !in_memory) {
|
||||
macro_info->reset();
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObBlockManager::do_mark_tablet_block(
|
||||
const ObIArray<blocksstable::MacroBlockId> &id_arr,
|
||||
const ObTabletMacroType block_type,
|
||||
const ObTabletBlockInfo &block_info,
|
||||
MacroBlkIdMap &mark_info,
|
||||
common::hash::ObHashSet<MacroBlockId, common::hash::NoPthreadDefendMode> ¯o_id_set,
|
||||
ObMacroBlockMarkerStatus &tmp_status)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < id_arr.count(); i++) {
|
||||
const MacroBlockId ¯o_id = id_arr.at(i);
|
||||
if (OB_FAIL(update_mark_info(macro_id, mark_info))) {
|
||||
LOG_WARN("fail to update mark info", K(ret), K(macro_id));
|
||||
} else if (OB_FAIL(macro_id_set.set_refactored(macro_id, 0 /* not overwrite */))) {
|
||||
if (OB_HASH_EXIST != ret) {
|
||||
LOG_WARN("fail to put macro id into set", K(ret), K(macro_id));
|
||||
} else {
|
||||
ret = OB_SUCCESS;
|
||||
}
|
||||
const MacroBlockId ¯o_id = block_info.macro_id_;
|
||||
if (OB_FAIL(update_mark_info(macro_id, mark_info))) {
|
||||
LOG_WARN("fail to update mark info", K(ret), K(macro_id));
|
||||
} else if (OB_FAIL(macro_id_set.set_refactored(macro_id, 0 /* not overwrite */))) {
|
||||
if (OB_HASH_EXIST != ret) {
|
||||
LOG_WARN("fail to put macro id into set", K(ret), K(macro_id));
|
||||
} else {
|
||||
switch (block_type) {
|
||||
case ObTabletMacroType::META_BLOCK:
|
||||
tmp_status.index_block_count_++;
|
||||
break;
|
||||
case ObTabletMacroType::DATA_BLOCK:
|
||||
tmp_status.data_block_count_++;
|
||||
break;
|
||||
case ObTabletMacroType::SHARED_META_BLOCK:
|
||||
tmp_status.shared_meta_block_count_++;
|
||||
break;
|
||||
case ObTabletMacroType::SHARED_DATA_BLOCK:
|
||||
tmp_status.shared_data_block_count_++;
|
||||
break;
|
||||
default:
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("block type is invalid", K(ret), K(block_type));
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
tmp_status.hold_count_--;
|
||||
}
|
||||
ret = OB_SUCCESS;
|
||||
}
|
||||
} else {
|
||||
switch (block_info.block_type_) {
|
||||
case ObTabletMacroType::META_BLOCK:
|
||||
case ObTabletMacroType::LINKED_BLOCK:
|
||||
tmp_status.index_block_count_++;
|
||||
break;
|
||||
case ObTabletMacroType::DATA_BLOCK:
|
||||
tmp_status.data_block_count_++;
|
||||
break;
|
||||
case ObTabletMacroType::SHARED_META_BLOCK:
|
||||
tmp_status.shared_meta_block_count_++;
|
||||
break;
|
||||
case ObTabletMacroType::SHARED_DATA_BLOCK:
|
||||
tmp_status.shared_data_block_count_++;
|
||||
break;
|
||||
default:
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("block type is invalid", K(ret), K(block_info));
|
||||
break;
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
tmp_status.hold_count_--;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
@ -33,6 +33,7 @@ namespace storage
|
||||
{
|
||||
class ObTenantCheckpointSlogHandler;
|
||||
class ObTabletHandle;
|
||||
struct ObTabletBlockInfo;
|
||||
}
|
||||
|
||||
namespace blocksstable
|
||||
@ -355,8 +356,7 @@ private:
|
||||
common::hash::ObHashSet<MacroBlockId, common::hash::NoPthreadDefendMode> ¯o_id_set,
|
||||
ObMacroBlockMarkerStatus &tmp_status);
|
||||
int do_mark_tablet_block(
|
||||
const ObIArray<blocksstable::MacroBlockId> &id_arr,
|
||||
const ObTabletMacroType block_type,
|
||||
const ObTabletBlockInfo &block_info,
|
||||
MacroBlkIdMap &mark_info,
|
||||
common::hash::ObHashSet<MacroBlockId, common::hash::NoPthreadDefendMode> ¯o_id_set,
|
||||
ObMacroBlockMarkerStatus &tmp_status);
|
||||
|
@ -81,6 +81,8 @@
|
||||
#include "storage/tablet/ob_tablet_binding_info.h"
|
||||
#include "storage/tablet/ob_tablet_persister.h"
|
||||
#include "src/storage/slog_ckpt/ob_linked_macro_block_writer.h"
|
||||
#include "storage/tablet/ob_tablet_macro_info_iterator.h"
|
||||
#include "storage/blocksstable/ob_shared_macro_block_manager.h"
|
||||
|
||||
namespace oceanbase
|
||||
{
|
||||
@ -2209,39 +2211,14 @@ int ObTablet::parse_meta_addr(const ObMetaDiskAddr &addr, ObIArray<MacroBlockId>
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTablet::get_all_macro_ids(
|
||||
ObIArray<blocksstable::MacroBlockId> &meta_block_arr,
|
||||
ObIArray<blocksstable::MacroBlockId> &data_block_arr,
|
||||
ObIArray<blocksstable::MacroBlockId> &shared_meta_block_arr,
|
||||
ObIArray<blocksstable::MacroBlockId> &shared_data_block_arr) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObArenaAllocator allocator;
|
||||
ObTabletMacroInfo *tablet_macro_info = nullptr;
|
||||
bool in_memory = false;
|
||||
if (is_empty_shell()) {
|
||||
// no macro info
|
||||
} else if (OB_FAIL(load_macro_info(allocator, tablet_macro_info, in_memory))) {
|
||||
LOG_WARN("fail to fetch tablet macro info", K(ret));
|
||||
} else if (OB_FAIL(tablet_macro_info->get_all_macro_ids(
|
||||
meta_block_arr,
|
||||
data_block_arr,
|
||||
shared_meta_block_arr,
|
||||
shared_data_block_arr))) {
|
||||
LOG_WARN("fail to get tablet's macro ids", K(ret));
|
||||
}
|
||||
if (OB_NOT_NULL(tablet_macro_info) && !in_memory) {
|
||||
tablet_macro_info->~ObTabletMacroInfo();
|
||||
allocator.free(tablet_macro_info);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTablet::load_macro_info(ObArenaAllocator &allocator, ObTabletMacroInfo *&tablet_macro_info, bool &in_memory) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
in_memory = false;
|
||||
if (OB_UNLIKELY(!macro_info_addr_.is_valid() || macro_info_addr_.is_none_object())) {
|
||||
if (OB_UNLIKELY(is_empty_shell())) {
|
||||
ret = OB_NOT_SUPPORTED;
|
||||
LOG_WARN("empty shell may don't have macro info", K(ret));
|
||||
} else if (OB_UNLIKELY(!macro_info_addr_.is_valid() || macro_info_addr_.is_none_object())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("macro info addr is invalid", K(ret), K_(macro_info_addr));
|
||||
} else if (macro_info_addr_.is_memory_object()) {
|
||||
@ -2287,47 +2264,6 @@ int ObTablet::inc_macro_ref_cnt()
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTablet::inc_macro_ref_with_macro_info(const ObTabletMacroInfo &tablet_macro_info)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
bool inc_tablet_ref = false;
|
||||
bool inc_other_ref = false;
|
||||
if (OB_UNLIKELY(!is_inited_)) {
|
||||
ret = OB_NOT_INIT;
|
||||
LOG_WARN("tablet hasn't been inited", K(ret), K(is_inited_));
|
||||
} else if (OB_FAIL(inc_addr_ref_cnt(tablet_addr_, inc_tablet_ref))) {
|
||||
LOG_WARN("fail to increase macro blocks' ref cnt for 4k tablet", K(ret), K(tablet_addr_));
|
||||
} else if (OB_FAIL(tablet_macro_info.inc_macro_ref(inc_other_ref))) {
|
||||
LOG_WARN("fail to inc macro ref", K(ret));
|
||||
}
|
||||
if (OB_FAIL(ret)) {
|
||||
if (inc_tablet_ref) {
|
||||
dec_addr_ref_cnt(tablet_addr_);
|
||||
}
|
||||
if (inc_other_ref) {
|
||||
tablet_macro_info.dec_macro_ref();
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
hold_ref_cnt_ = true;
|
||||
}
|
||||
|
||||
// for issue track
|
||||
const ObTabletComplexAddr<mds::MdsDumpKV> &tablet_status_uncommitted_kv_addr = mds_data_.tablet_status_.uncommitted_kv_;
|
||||
const ObTabletComplexAddr<mds::MdsDumpKV> &tablet_status_committed_kv_addr = mds_data_.tablet_status_.committed_kv_;
|
||||
const ObTabletComplexAddr<mds::MdsDumpKV> &aux_tablet_info_uncommitted_kv_addr = mds_data_.aux_tablet_info_.uncommitted_kv_;
|
||||
const ObTabletComplexAddr<mds::MdsDumpKV> &aux_tablet_info_committed_kv_addr = mds_data_.aux_tablet_info_.committed_kv_;
|
||||
const ObTabletComplexAddr<ObTabletDumpedMediumInfo> &medium_info_list_addr = mds_data_.medium_info_list_;
|
||||
const ObTabletComplexAddr<share::ObTabletAutoincSeq> &auto_inc_seq_addr = mds_data_.auto_inc_seq_;
|
||||
FLOG_INFO("the tablet that inner increases ref cnt is",
|
||||
K(ret), K(hold_ref_cnt_), K(tablet_meta_.ls_id_), K(tablet_meta_.tablet_id_), K(table_store_addr_.addr_),
|
||||
K(auto_inc_seq_addr.addr_), K(storage_schema_addr_.addr_), K(medium_info_list_addr.addr_),
|
||||
K(tablet_status_uncommitted_kv_addr.addr_), K(tablet_status_committed_kv_addr.addr_),
|
||||
K(aux_tablet_info_uncommitted_kv_addr.addr_), K(aux_tablet_info_committed_kv_addr.addr_),
|
||||
K(tablet_addr_), KP(this), K(tablet_macro_info), K(lbt()));
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTablet::inner_inc_macro_ref_cnt()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
@ -2336,7 +2272,7 @@ int ObTablet::inner_inc_macro_ref_cnt()
|
||||
} else if (OB_UNLIKELY(ObTabletBlockHeader::TABLET_VERSION_V3 == version_ && !is_empty_shell() && macro_info_addr_.is_none_object())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_ERROR("v3 normal tablet's macro_info_addr_ shouldn't be none object", K(ret), KPC(this));
|
||||
} else if (macro_info_addr_.is_none_object()) {
|
||||
} else if (macro_info_addr_.is_none_object() || is_empty_shell()) {
|
||||
if (OB_FAIL(inc_ref_without_aggregated_info())) {
|
||||
LOG_WARN("fail to inc macro ref without fetch", K(ret));
|
||||
}
|
||||
@ -2348,6 +2284,90 @@ int ObTablet::inner_inc_macro_ref_cnt()
|
||||
if (OB_SUCC(ret)) {
|
||||
hold_ref_cnt_ = true;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTablet::inc_ref_with_aggregated_info()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObArenaAllocator allocator("IncMacroRef", OB_MALLOC_NORMAL_BLOCK_SIZE, MTL_ID());
|
||||
ObTabletMacroInfo *macro_info = nullptr;
|
||||
bool in_memory = true;
|
||||
bool inc_tablet_ref = false;
|
||||
bool inc_other_ref = false;
|
||||
ObMacroInfoIterator info_iter;
|
||||
|
||||
if (OB_FAIL(load_macro_info(allocator, macro_info, in_memory))) {
|
||||
LOG_WARN("fail to load macro info", K(ret));
|
||||
} else if (OB_FAIL(info_iter.init(ObTabletMacroType::MAX, *macro_info))) {
|
||||
LOG_WARN("fail to init macro info iterator", K(ret), KPC(macro_info));
|
||||
} else if (OB_FAIL(inc_addr_ref_cnt(tablet_addr_, inc_tablet_ref))) {
|
||||
LOG_WARN("fail to increase macro blocks' ref cnt for 4k tablet", K(ret), K(tablet_addr_));
|
||||
} else if (OB_FAIL(inc_ref_with_macro_iter(info_iter, inc_other_ref))) {
|
||||
LOG_WARN("fail to increase other blocks' ref cnt", K(ret));
|
||||
}
|
||||
if (OB_FAIL(ret)) {
|
||||
if (inc_tablet_ref) {
|
||||
dec_addr_ref_cnt(tablet_addr_);
|
||||
}
|
||||
if (inc_other_ref) {
|
||||
int tmp_ret = OB_SUCCESS;
|
||||
if (OB_TMP_FAIL(info_iter.reuse())) {
|
||||
LOG_WARN("fail to reuse macro info iterator", K(tmp_ret));
|
||||
} else {
|
||||
dec_ref_with_macro_iter(info_iter);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (OB_NOT_NULL(macro_info) && !in_memory) {
|
||||
macro_info->reset();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTablet::inc_ref_with_macro_iter(ObMacroInfoIterator ¯o_iter, bool &inc_success) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int inc_other_ref_cnt = 0;
|
||||
ObTabletBlockInfo block_info;
|
||||
inc_success = false;
|
||||
while (OB_SUCC(ret)) {
|
||||
block_info.reset();
|
||||
if (OB_FAIL(macro_iter.get_next(block_info))) {
|
||||
if (OB_ITER_END != ret) {
|
||||
LOG_WARN("fail to get next block info", K(ret));
|
||||
}
|
||||
} else if (OB_FAIL(OB_SERVER_BLOCK_MGR.inc_ref(block_info.macro_id_))) {
|
||||
LOG_ERROR("fail to increase macro block's ref cnt", K(ret), K(block_info));
|
||||
} else if (FALSE_IT(inc_other_ref_cnt++)) {
|
||||
} else if (ObTabletMacroType::SHARED_DATA_BLOCK == block_info.block_type_
|
||||
&& OB_FAIL(MTL(ObSharedMacroBlockMgr*)->add_block(block_info.macro_id_, block_info.occupy_size_))) {
|
||||
LOG_WARN("fail to add block", K(ret), K(block_info));
|
||||
}
|
||||
}
|
||||
|
||||
if (OB_LIKELY(OB_ITER_END == ret) || OB_SUCC(ret)) {
|
||||
inc_success = true;
|
||||
ret = OB_SUCCESS;
|
||||
} else if (inc_other_ref_cnt > 0) {
|
||||
int tmp_ret = OB_SUCCESS;
|
||||
if (OB_TMP_FAIL(macro_iter.reuse())) {
|
||||
LOG_WARN("fail to reuse macro info iterator", K(tmp_ret));
|
||||
} else {
|
||||
for (int64_t i = 0; i < inc_other_ref_cnt; i++) {
|
||||
block_info.reset();
|
||||
if (OB_TMP_FAIL(macro_iter.get_next(block_info))) {
|
||||
LOG_ERROR("fail to get next block info, macro block may leak", K(tmp_ret));
|
||||
} else if (OB_TMP_FAIL(OB_SERVER_BLOCK_MGR.dec_ref(block_info.macro_id_))) {
|
||||
LOG_ERROR("fail to increase macro block's ref cnt, macro block may leak", K(tmp_ret), K(block_info));
|
||||
} else if (ObTabletMacroType::SHARED_DATA_BLOCK == block_info.block_type_
|
||||
&& OB_TMP_FAIL(MTL(ObSharedMacroBlockMgr*)->free_block(block_info.macro_id_, block_info.occupy_size_))) {
|
||||
LOG_WARN("fail to free block", K(ret), K(block_info));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// for issue track
|
||||
const ObTabletComplexAddr<mds::MdsDumpKV> &tablet_status_uncommitted_kv_addr = mds_data_.tablet_status_.uncommitted_kv_;
|
||||
@ -2361,43 +2381,10 @@ int ObTablet::inner_inc_macro_ref_cnt()
|
||||
K(auto_inc_seq_addr.addr_), K(storage_schema_addr_.addr_), K(medium_info_list_addr.addr_),
|
||||
K(tablet_status_uncommitted_kv_addr.addr_), K(tablet_status_committed_kv_addr.addr_),
|
||||
K(aux_tablet_info_uncommitted_kv_addr.addr_), K(aux_tablet_info_committed_kv_addr.addr_),
|
||||
K(tablet_addr_), KP(this), KPC(macro_info_addr_.ptr_), K(lbt()));
|
||||
|
||||
K(tablet_addr_), KP(this), K(macro_iter), K(lbt()));
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTablet::inc_ref_with_aggregated_info()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
bool inc_tablet_ref = false;
|
||||
bool inc_other_ref = false;
|
||||
bool in_memory = false;
|
||||
ObArenaAllocator allocator("IncMacroRef", OB_MALLOC_NORMAL_BLOCK_SIZE, MTL_ID());
|
||||
ObTabletMacroInfo *tablet_macro_info = nullptr;
|
||||
if (OB_FAIL(load_macro_info(allocator, tablet_macro_info, in_memory))) {
|
||||
LOG_WARN("fail to fetch tablet macro info", K(ret));
|
||||
} else if (OB_FAIL(inc_addr_ref_cnt(tablet_addr_, inc_tablet_ref))) {
|
||||
LOG_WARN("fail to increase macro blocks' ref cnt for 4k tablet", K(ret), K(tablet_addr_));
|
||||
} else if (OB_FAIL(tablet_macro_info->inc_macro_ref(inc_other_ref))) {
|
||||
LOG_WARN("fail to increase other macro ref cnt", K(ret));
|
||||
}
|
||||
if (OB_FAIL(ret)) {
|
||||
if (inc_tablet_ref) {
|
||||
dec_addr_ref_cnt(tablet_addr_);
|
||||
}
|
||||
if (inc_other_ref) {
|
||||
tablet_macro_info->dec_macro_ref();
|
||||
}
|
||||
}
|
||||
if (OB_NOT_NULL(tablet_macro_info) && !in_memory) {
|
||||
tablet_macro_info->~ObTabletMacroInfo();
|
||||
allocator.free(tablet_macro_info);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int ObTablet::inc_ref_without_aggregated_info()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
@ -2480,36 +2467,20 @@ int ObTablet::inc_ref_without_aggregated_info()
|
||||
void ObTablet::dec_macro_ref_cnt()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
// for issue track
|
||||
const ObTabletComplexAddr<mds::MdsDumpKV> &tablet_status_uncommitted_kv_addr = mds_data_.tablet_status_.uncommitted_kv_;
|
||||
const ObTabletComplexAddr<mds::MdsDumpKV> &tablet_status_committed_kv_addr = mds_data_.tablet_status_.committed_kv_;
|
||||
const ObTabletComplexAddr<mds::MdsDumpKV> &aux_tablet_info_uncommitted_kv_addr = mds_data_.aux_tablet_info_.uncommitted_kv_;
|
||||
const ObTabletComplexAddr<mds::MdsDumpKV> &aux_tablet_info_committed_kv_addr = mds_data_.aux_tablet_info_.committed_kv_;
|
||||
const ObTabletComplexAddr<ObTabletDumpedMediumInfo> &medium_info_list_addr = mds_data_.medium_info_list_;
|
||||
const ObTabletComplexAddr<share::ObTabletAutoincSeq> &auto_inc_seq_addr = mds_data_.auto_inc_seq_;
|
||||
if (OB_UNLIKELY(!hold_ref_cnt_)) {
|
||||
FLOG_INFO("tablet doesn't hold ref cnt, no need to dec ref cnt",
|
||||
K(is_inited_), K(tablet_meta_.ls_id_), K(tablet_meta_.tablet_id_), K(table_store_addr_.addr_.is_valid()),
|
||||
K(auto_inc_seq_addr.addr_), K(storage_schema_addr_.addr_), K(medium_info_list_addr.addr_),
|
||||
K(tablet_status_uncommitted_kv_addr.addr_), K(tablet_status_committed_kv_addr.addr_),
|
||||
K(aux_tablet_info_uncommitted_kv_addr.addr_), K(aux_tablet_info_committed_kv_addr.addr_),
|
||||
K(tablet_addr_), KP(this), K(lbt()));
|
||||
K(is_inited_), K(tablet_meta_.ls_id_), K(tablet_meta_.tablet_id_),
|
||||
K(table_store_addr_.addr_), K(tablet_addr_), KP(this), K(lbt()));
|
||||
} else if (OB_FAIL(check_meta_addr())) {
|
||||
LOG_ERROR("fail to check meta addrs", K(ret));
|
||||
} else if (OB_UNLIKELY(ObTabletBlockHeader::TABLET_VERSION_V3 == version_ && !is_empty_shell() && macro_info_addr_.is_none_object())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_ERROR("v3 normal tablet's macro_info_addr_ shouldn't be none object", K(ret), KPC(this));
|
||||
} else if (macro_info_addr_.is_none_object()) {
|
||||
} else if (macro_info_addr_.is_none_object() || is_empty_shell()) {
|
||||
dec_ref_without_aggregated_info();
|
||||
} else {
|
||||
dec_ref_with_aggregated_info();
|
||||
}
|
||||
FLOG_INFO("the tablet that decreases ref cnt is",
|
||||
K(is_inited_), K(tablet_meta_.ls_id_), K(tablet_meta_.tablet_id_), K(table_store_addr_.addr_),
|
||||
K(auto_inc_seq_addr.addr_), K(storage_schema_addr_.addr_), K(medium_info_list_addr.addr_),
|
||||
K(tablet_status_uncommitted_kv_addr.addr_), K(tablet_status_committed_kv_addr.addr_),
|
||||
K(aux_tablet_info_uncommitted_kv_addr.addr_), K(aux_tablet_info_committed_kv_addr.addr_),
|
||||
K(tablet_addr_), KP(this), KPC(macro_info_addr_.ptr_), K(lbt()));
|
||||
}
|
||||
|
||||
void ObTablet::dec_ref_without_aggregated_info()
|
||||
@ -2539,25 +2510,58 @@ void ObTablet::dec_ref_with_aggregated_info()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObArenaAllocator allocator("DecMacroRef", OB_MALLOC_NORMAL_BLOCK_SIZE, MTL_ID());
|
||||
ObTabletMacroInfo *tablet_macro_info = nullptr;
|
||||
bool in_memory = false;
|
||||
do {
|
||||
if (nullptr != tablet_macro_info) {
|
||||
tablet_macro_info->reset();
|
||||
tablet_macro_info = nullptr;
|
||||
}
|
||||
allocator.reuse();
|
||||
ret = load_macro_info(allocator, tablet_macro_info, in_memory);
|
||||
} while (ignore_ret(ret));
|
||||
if (OB_FAIL(ret)) {
|
||||
LOG_ERROR("fail to fetch macro info, macro blocks may leak", K(ret));
|
||||
ObTabletMacroInfo *macro_info = nullptr;
|
||||
bool in_memory = true;
|
||||
ObMacroInfoIterator info_iter;
|
||||
if (OB_FAIL(load_macro_info(allocator, macro_info, in_memory))) {
|
||||
LOG_WARN("fail to load macro info", K(ret));
|
||||
} else if (OB_FAIL(info_iter.init(ObTabletMacroType::MAX, *macro_info))) {
|
||||
LOG_WARN("fail to init macro info iterator", K(ret), KPC(macro_info));
|
||||
} else {
|
||||
dec_addr_ref_cnt(tablet_addr_);
|
||||
tablet_macro_info->dec_macro_ref();
|
||||
dec_ref_with_macro_iter(info_iter);
|
||||
}
|
||||
if (OB_NOT_NULL(tablet_macro_info) && !in_memory) {
|
||||
tablet_macro_info->~ObTabletMacroInfo();
|
||||
allocator.free(tablet_macro_info);
|
||||
if (OB_NOT_NULL(macro_info) && !in_memory) {
|
||||
macro_info->reset();
|
||||
}
|
||||
|
||||
// for issue track
|
||||
const ObTabletComplexAddr<mds::MdsDumpKV> &tablet_status_uncommitted_kv_addr = mds_data_.tablet_status_.uncommitted_kv_;
|
||||
const ObTabletComplexAddr<mds::MdsDumpKV> &tablet_status_committed_kv_addr = mds_data_.tablet_status_.committed_kv_;
|
||||
const ObTabletComplexAddr<mds::MdsDumpKV> &aux_tablet_info_uncommitted_kv_addr = mds_data_.aux_tablet_info_.uncommitted_kv_;
|
||||
const ObTabletComplexAddr<mds::MdsDumpKV> &aux_tablet_info_committed_kv_addr = mds_data_.aux_tablet_info_.committed_kv_;
|
||||
const ObTabletComplexAddr<ObTabletDumpedMediumInfo> &medium_info_list_addr = mds_data_.medium_info_list_;
|
||||
const ObTabletComplexAddr<share::ObTabletAutoincSeq> &auto_inc_seq_addr = mds_data_.auto_inc_seq_;
|
||||
FLOG_INFO("the tablet that decreases ref cnt is",
|
||||
K(is_inited_), K(tablet_meta_.ls_id_), K(tablet_meta_.tablet_id_), K(table_store_addr_.addr_),
|
||||
K(auto_inc_seq_addr.addr_), K(storage_schema_addr_.addr_), K(medium_info_list_addr.addr_),
|
||||
K(tablet_status_uncommitted_kv_addr.addr_), K(tablet_status_committed_kv_addr.addr_),
|
||||
K(aux_tablet_info_uncommitted_kv_addr.addr_), K(aux_tablet_info_committed_kv_addr.addr_),
|
||||
K(tablet_addr_), KP(this), K(info_iter), K(lbt()));
|
||||
}
|
||||
|
||||
void ObTablet::dec_ref_with_macro_iter(ObMacroInfoIterator ¯o_iter) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObTabletBlockInfo block_info;
|
||||
while (OB_SUCC(ret)) {
|
||||
block_info.reset();
|
||||
if (OB_FAIL(macro_iter.get_next(block_info))) {
|
||||
if (OB_ITER_END != ret) {
|
||||
LOG_ERROR("fail to get next block info, macro block may leak", K(ret));
|
||||
}
|
||||
} else {
|
||||
if (OB_FAIL(OB_SERVER_BLOCK_MGR.dec_ref(block_info.macro_id_))) {
|
||||
LOG_ERROR("fail to decrease macro block's ref cnt, macro block may leak", K(ret), K(block_info));
|
||||
} else if (ObTabletMacroType::SHARED_DATA_BLOCK == block_info.block_type_
|
||||
&& OB_FAIL(MTL(ObSharedMacroBlockMgr*)->free_block(block_info.macro_id_, block_info.occupy_size_))) {
|
||||
LOG_WARN("fail to add block", K(ret), K(block_info));
|
||||
}
|
||||
if (OB_FAIL(ret)) {
|
||||
ret = OB_SUCCESS;
|
||||
// ignore ret, continue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -107,6 +107,7 @@ class ObTabletCreateDeleteMdsUserData;
|
||||
class ObTabletBindingMdsUserData;
|
||||
class ObMemtableArray;
|
||||
class ObCOSSTableV2;
|
||||
class ObMacroInfoIterator;
|
||||
|
||||
struct ObTableStoreCache
|
||||
{
|
||||
@ -238,12 +239,6 @@ public:
|
||||
bool is_valid() const;
|
||||
// refresh memtable and update tablet_addr_ and table_store_addr_ sequence, only used by slog ckpt
|
||||
int refresh_memtable_and_update_seq(const uint64_t seq);
|
||||
// TODO(zhouxinlan.zxl): replace ObIArray with iterator
|
||||
int get_all_macro_ids(
|
||||
ObIArray<blocksstable::MacroBlockId> &meta_block_arr,
|
||||
ObIArray<blocksstable::MacroBlockId> &data_block_arr,
|
||||
ObIArray<blocksstable::MacroBlockId> &shared_meta_block_arr,
|
||||
ObIArray<blocksstable::MacroBlockId> &shared_data_block_arr) const;
|
||||
bool is_old_tablet() { return version_ < ObTabletBlockHeader::TABLET_VERSION_V3; }
|
||||
void dec_macro_ref_cnt();
|
||||
int inc_macro_ref_cnt();
|
||||
@ -607,11 +602,11 @@ private:
|
||||
static int parse_meta_addr(const ObMetaDiskAddr &addr, ObIArray<blocksstable::MacroBlockId> &meta_ids);
|
||||
void dec_ref_with_aggregated_info();
|
||||
void dec_ref_without_aggregated_info();
|
||||
void dec_ref_with_macro_iter(ObMacroInfoIterator ¯o_iter) const;
|
||||
int inner_inc_macro_ref_cnt();
|
||||
// inc ref with existed ObTabletMacroInfo
|
||||
int inc_macro_ref_with_macro_info(const ObTabletMacroInfo &tablet_macro_info);
|
||||
int inc_ref_with_aggregated_info();
|
||||
int inc_ref_without_aggregated_info();
|
||||
int inc_ref_with_macro_iter(ObMacroInfoIterator ¯o_iter, bool &inc_success) const;
|
||||
void dec_table_store_ref_cnt();
|
||||
int inc_table_store_ref_cnt(bool &inc_success);
|
||||
static int inc_addr_ref_cnt(const ObMetaDiskAddr &addr, bool &inc_success);
|
||||
|
@ -87,19 +87,19 @@ int ObBlockInfoSet::init(
|
||||
* ---------------------------------------ObBlockInfoArray----------------------------------------
|
||||
*/
|
||||
template <typename T>
|
||||
ObBlockInfoArray<T>::ObBlockInfoArray()
|
||||
ObTabletMacroInfo::ObBlockInfoArray<T>::ObBlockInfoArray()
|
||||
: cnt_(0), arr_(nullptr), capacity_(0)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
ObBlockInfoArray<T>::~ObBlockInfoArray()
|
||||
ObTabletMacroInfo::ObBlockInfoArray<T>::~ObBlockInfoArray()
|
||||
{
|
||||
reset();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void ObBlockInfoArray<T>::reset()
|
||||
void ObTabletMacroInfo::ObBlockInfoArray<T>::reset()
|
||||
{
|
||||
cnt_ = 0;
|
||||
capacity_ = 0;
|
||||
@ -107,7 +107,7 @@ void ObBlockInfoArray<T>::reset()
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
int ObBlockInfoArray<T>::reserve(const int64_t cnt, ObArenaAllocator &allocator)
|
||||
int ObTabletMacroInfo::ObBlockInfoArray<T>::reserve(const int64_t cnt, ObArenaAllocator &allocator)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (0 == cnt) {
|
||||
@ -125,7 +125,7 @@ int ObBlockInfoArray<T>::reserve(const int64_t cnt, ObArenaAllocator &allocator)
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
int ObBlockInfoArray<T>::serialize(char *buf, const int64_t buf_len, int64_t &pos) const
|
||||
int ObTabletMacroInfo::ObBlockInfoArray<T>::serialize(char *buf, const int64_t buf_len, int64_t &pos) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_ISNULL(buf) || OB_UNLIKELY(buf_len <= 0 || pos < 0)) {
|
||||
@ -146,7 +146,7 @@ int ObBlockInfoArray<T>::serialize(char *buf, const int64_t buf_len, int64_t &po
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
int ObBlockInfoArray<T>::deserialize(ObArenaAllocator &allocator, const char *buf, const int64_t data_len, int64_t &pos)
|
||||
int ObTabletMacroInfo::ObBlockInfoArray<T>::deserialize(ObArenaAllocator &allocator, const char *buf, const int64_t data_len, int64_t &pos)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_ISNULL(buf) || OB_UNLIKELY(pos < 0 || data_len <= 0)) {
|
||||
@ -183,20 +183,20 @@ int ObBlockInfoArray<T>::deserialize(ObArenaAllocator &allocator, const char *bu
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
int64_t ObBlockInfoArray<T>::get_serialize_size() const
|
||||
int64_t ObTabletMacroInfo::ObBlockInfoArray<T>::get_serialize_size() const
|
||||
{
|
||||
T block_info;
|
||||
return serialization::encoded_length_i64(cnt_) + block_info.get_serialize_size() * cnt_;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
int64_t ObBlockInfoArray<T>::get_deep_copy_size() const
|
||||
int64_t ObTabletMacroInfo::ObBlockInfoArray<T>::get_deep_copy_size() const
|
||||
{
|
||||
return sizeof(T) * cnt_;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
int ObBlockInfoArray<T>::deep_copy(char *buf, const int64_t buf_len, int64_t &pos, ObBlockInfoArray &dest_obj) const
|
||||
int ObTabletMacroInfo::ObBlockInfoArray<T>::deep_copy(char *buf, const int64_t buf_len, int64_t &pos, ObBlockInfoArray &dest_obj) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
const int64_t memory_size = get_deep_copy_size();
|
||||
@ -580,568 +580,5 @@ bool ObTabletMacroInfo::is_valid() const
|
||||
&& shared_meta_block_info_arr_.is_valid()
|
||||
&& shared_data_block_info_arr_.is_valid();
|
||||
}
|
||||
|
||||
int ObTabletMacroInfo::get_all_macro_ids(
|
||||
ObIArray<blocksstable::MacroBlockId> &meta_block_arr,
|
||||
ObIArray<blocksstable::MacroBlockId> &data_block_arr,
|
||||
ObIArray<blocksstable::MacroBlockId> &shared_meta_block_arr,
|
||||
ObIArray<blocksstable::MacroBlockId> &shared_data_block_arr)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (IS_EMPTY_BLOCK_LIST(entry_block_)) {
|
||||
if (OB_FAIL(get_macro_ids_without_io(
|
||||
meta_block_arr,
|
||||
data_block_arr,
|
||||
shared_meta_block_arr,
|
||||
shared_data_block_arr))) {
|
||||
LOG_WARN("fail to get macro ids without io", K(ret));
|
||||
}
|
||||
} else {
|
||||
if (OB_FAIL(get_macro_ids_with_io(
|
||||
meta_block_arr,
|
||||
data_block_arr,
|
||||
shared_meta_block_arr,
|
||||
shared_data_block_arr))) {
|
||||
LOG_WARN("fail to get macro ids with io", K(ret));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTabletMacroInfo::get_macro_ids_without_io(
|
||||
ObIArray<blocksstable::MacroBlockId> &meta_block_arr,
|
||||
ObIArray<blocksstable::MacroBlockId> &data_block_arr,
|
||||
ObIArray<blocksstable::MacroBlockId> &shared_meta_block_arr,
|
||||
ObIArray<blocksstable::MacroBlockId> &shared_data_block_arr)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_FAIL(parse_id_arr(meta_block_info_arr_, meta_block_arr))) {
|
||||
LOG_WARN("fail to parse meta id array", K(ret), K(meta_block_info_arr_));
|
||||
} else if (OB_FAIL(parse_id_arr(data_block_info_arr_, data_block_arr))) {
|
||||
LOG_WARN("fail to parse data id array", K(ret), K(data_block_info_arr_));
|
||||
} else if (OB_FAIL(parse_id_arr(shared_meta_block_info_arr_, shared_meta_block_arr))) {
|
||||
LOG_WARN("fail to parse shared meta id array", K(ret), K(shared_meta_block_info_arr_));
|
||||
} else if (OB_FAIL(parse_info_arr(shared_data_block_info_arr_, shared_data_block_arr))) {
|
||||
LOG_WARN("fail to parse shared data id array", K(ret), K(shared_data_block_info_arr_));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTabletMacroInfo::parse_id_arr(
|
||||
const ObBlockInfoArray<blocksstable::MacroBlockId> &info_arr,
|
||||
ObIArray<blocksstable::MacroBlockId> &id_arr)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < info_arr.cnt_; i++) {
|
||||
if (OB_FAIL(id_arr.push_back(info_arr.arr_[i]))) {
|
||||
LOG_WARN("fail to push back macro id", K(ret), K(i), K(info_arr.arr_[i]));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTabletMacroInfo::parse_info_arr(
|
||||
const ObBlockInfoArray<ObSharedBlockInfo> &info_arr,
|
||||
ObIArray<blocksstable::MacroBlockId> &id_arr)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < info_arr.cnt_; i++) {
|
||||
if (OB_FAIL(id_arr.push_back(info_arr.arr_[i].shared_macro_id_))) {
|
||||
LOG_WARN("fail to push back macro id", K(ret), K(i), K(info_arr.arr_[i]));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTabletMacroInfo::get_macro_ids_with_io(
|
||||
ObIArray<blocksstable::MacroBlockId> &meta_block_arr,
|
||||
ObIArray<blocksstable::MacroBlockId> &data_block_arr,
|
||||
ObIArray<blocksstable::MacroBlockId> &shared_meta_block_arr,
|
||||
ObIArray<blocksstable::MacroBlockId> &shared_data_block_arr)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObLinkedMacroBlockItemReader block_reader;
|
||||
char *buf = nullptr;
|
||||
int64_t buf_len = 0;
|
||||
ObMetaDiskAddr addr;
|
||||
if (OB_UNLIKELY(!entry_block_.is_valid())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("entry block is invalid", K(ret), K(entry_block_));
|
||||
} else {
|
||||
if (OB_FAIL(block_reader.init(entry_block_))) {
|
||||
LOG_WARN("fail to init linked block item reader", K(ret), K(entry_block_));
|
||||
} else if (OB_FAIL(block_reader.get_next_item(buf, buf_len, addr))) {
|
||||
LOG_WARN("fail to get next item", K(ret));
|
||||
} else if (OB_FAIL(parse_id_buf(buf, buf_len, meta_block_arr))) {
|
||||
LOG_WARN("fail to parse meta block info buf", K(ret), K(buf_len), KP(buf));
|
||||
} else if (OB_FAIL(block_reader.get_next_item(buf, buf_len, addr))) {
|
||||
LOG_WARN("fail to get next item", K(ret));
|
||||
} else if (OB_FAIL(parse_id_buf(buf, buf_len, data_block_arr))) {
|
||||
LOG_WARN("fail to parse data block info buf", K(ret), K(buf_len), KP(buf));
|
||||
} else if (OB_FAIL(block_reader.get_next_item(buf, buf_len, addr))) {
|
||||
LOG_WARN("fail to get next item", K(ret));
|
||||
} else if (OB_FAIL(parse_id_buf(buf, buf_len, shared_meta_block_arr))) {
|
||||
LOG_WARN("fail to parse shared meta block info buf", K(ret), K(buf_len), KP(buf));
|
||||
} else if (OB_FAIL(block_reader.get_next_item(buf, buf_len, addr))) {
|
||||
LOG_WARN("fail to get next item", K(ret));
|
||||
} else if (OB_FAIL(parse_info_buf(buf, buf_len, shared_data_block_arr))) {
|
||||
LOG_WARN("fail to parse shared data block info buf", K(ret), K(buf_len), KP(buf));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTabletMacroInfo::parse_info_buf(
|
||||
const char *buf,
|
||||
const int64_t buf_len,
|
||||
ObIArray<blocksstable::MacroBlockId> &block_id_arr)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int64_t cnt = 0;
|
||||
int64_t pos = 0;
|
||||
ObSharedBlockInfo block_info;
|
||||
int16_t macro_type;
|
||||
ObArenaAllocator allocator;
|
||||
ObBlockInfoArray<ObSharedBlockInfo> block_info_arr;
|
||||
if (OB_FAIL(serialization::decode_i16(buf, buf_len, pos, ¯o_type))) {
|
||||
LOG_WARN("fail to deserialize macro type", K(ret), K(buf_len), K(pos));
|
||||
} else if (OB_FAIL(block_info_arr.deserialize(allocator, buf, buf_len, pos))) {
|
||||
LOG_WARN("fail to deserialize block info arr", K(ret), K(buf_len), K(pos));
|
||||
} else if (OB_FAIL(parse_info_arr(block_info_arr, block_id_arr))) {
|
||||
LOG_WARN("fail to parse info arr", K(ret), K(block_info_arr));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTabletMacroInfo::parse_id_buf(
|
||||
const char *buf,
|
||||
const int64_t buf_len,
|
||||
ObIArray<blocksstable::MacroBlockId> &block_id_arr)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int64_t cnt = 0;
|
||||
int64_t pos = 0;
|
||||
MacroBlockId macro_id;
|
||||
int16_t macro_type;
|
||||
ObArenaAllocator allocator;
|
||||
ObBlockInfoArray<MacroBlockId> block_info_arr;
|
||||
if (OB_FAIL(serialization::decode_i16(buf, buf_len, pos, ¯o_type))) {
|
||||
LOG_WARN("fail to deserialize macro type", K(ret), K(buf_len), K(pos));
|
||||
} else if (OB_FAIL(block_info_arr.deserialize(allocator, buf, buf_len, pos))) {
|
||||
LOG_WARN("fail to deserialize block info arr", K(ret), K(buf_len), K(pos));
|
||||
} else if (OB_FAIL(parse_id_arr(block_info_arr, block_id_arr))) {
|
||||
LOG_WARN("fail to parse id arr", K(ret), K(block_info_arr));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTabletMacroInfo::inc_macro_ref(bool &inc_success) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
inc_success = false;
|
||||
if (IS_NOT_INIT) {
|
||||
ret = OB_NOT_INIT;
|
||||
LOG_WARN("tablet macro info hasnt' been inited", K(ret));
|
||||
} else if (IS_EMPTY_BLOCK_LIST(entry_block_)) {
|
||||
if (OB_FAIL(inc_macro_ref_without_io())) {
|
||||
LOG_WARN("fail to increase macro ref cnt without io", K(ret));
|
||||
}
|
||||
} else {
|
||||
if (OB_FAIL(inc_macro_ref_with_io())) {
|
||||
LOG_WARN("fail to increase macro ref cnt with io", K(ret));
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
inc_success = true;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ObTabletMacroInfo::dec_macro_ref() const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (IS_NOT_INIT) {
|
||||
ret = OB_NOT_INIT;
|
||||
LOG_WARN("tablet macro info hasnt' been inited", K(ret));
|
||||
} else if (IS_EMPTY_BLOCK_LIST(entry_block_)) {
|
||||
dec_macro_ref_without_io();
|
||||
} else {
|
||||
dec_macro_ref_with_io();
|
||||
}
|
||||
}
|
||||
|
||||
void ObTabletMacroInfo::dec_macro_ref_with_io() const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObLinkedMacroBlockItemReader block_reader;
|
||||
char *meta_id_buf = nullptr;
|
||||
int64_t meta_id_len = 0;
|
||||
char *data_id_buf = nullptr;
|
||||
int64_t data_id_len = 0;
|
||||
char *shared_meta_id_buf = nullptr;
|
||||
int64_t shared_meta_id_len = 0;
|
||||
char *shared_data_info_buf = nullptr;
|
||||
int64_t shared_data_info_len = 0;
|
||||
ObMetaDiskAddr addr;
|
||||
if (OB_UNLIKELY(!entry_block_.is_valid())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("entry block is invalid", K(ret), K(entry_block_));
|
||||
} else {
|
||||
do {
|
||||
block_reader.reset();
|
||||
if (OB_FAIL(block_reader.init(entry_block_))) {
|
||||
LOG_WARN("fail to init linked block item reader", K(ret), K(entry_block_));
|
||||
}
|
||||
} while (ignore_ret(ret));
|
||||
}
|
||||
|
||||
if (OB_FAIL(ret)) {
|
||||
// do nothing
|
||||
} else if (OB_FAIL(block_reader.get_next_item(meta_id_buf, meta_id_len, addr))) {
|
||||
LOG_WARN("fail to get next item", K(ret));
|
||||
} else if (FALSE_IT(deserialize_and_dec_macro_ref(meta_id_buf, meta_id_len))) {
|
||||
} else if (OB_FAIL(block_reader.get_next_item(data_id_buf, data_id_len, addr))) {
|
||||
LOG_WARN("fail to get next item", K(ret));
|
||||
} else if (FALSE_IT(deserialize_and_dec_macro_ref(data_id_buf, data_id_len))) {
|
||||
} else if (OB_FAIL(block_reader.get_next_item(shared_meta_id_buf, shared_meta_id_len, addr))) {
|
||||
LOG_WARN("fail to get next item", K(ret));
|
||||
} else if (FALSE_IT(deserialize_and_dec_macro_ref(shared_meta_id_buf, shared_meta_id_len))) {
|
||||
} else if (OB_FAIL(block_reader.get_next_item(shared_data_info_buf, shared_data_info_len, addr))) {
|
||||
LOG_WARN("fail to get next item", K(ret));
|
||||
} else {
|
||||
deserialize_and_dec_shared_macro_ref(shared_data_info_buf, shared_data_info_len);
|
||||
dec_linked_block_ref_cnt(block_reader.get_meta_block_list());
|
||||
}
|
||||
}
|
||||
|
||||
int ObTabletMacroInfo::inc_macro_ref_with_io() const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObLinkedMacroBlockItemReader block_reader;
|
||||
char *meta_id_buf = nullptr;
|
||||
int64_t meta_id_len = 0;
|
||||
char *data_id_buf = nullptr;
|
||||
int64_t data_id_len = 0;
|
||||
char *shared_meta_id_buf = nullptr;
|
||||
int64_t shared_meta_id_len = 0;
|
||||
char *shared_data_info_buf = nullptr;
|
||||
int64_t shared_data_info_len = 0;
|
||||
ObMetaDiskAddr addr;
|
||||
bool inc_meta_id_success = false;
|
||||
bool inc_data_id_success = false;
|
||||
bool inc_shared_meta_id_success = false;
|
||||
bool inc_shared_data_id_success = false;
|
||||
bool inc_linked_id_success = false;
|
||||
if (OB_UNLIKELY(!entry_block_.is_valid())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("entry block is invalid", K(ret), K(entry_block_));
|
||||
} else if (OB_FAIL(block_reader.init(entry_block_))) {
|
||||
LOG_WARN("fail to init linked block item reader", K(ret), K(entry_block_));
|
||||
} else if (OB_FAIL(block_reader.get_next_item(meta_id_buf, meta_id_len, addr))) {
|
||||
LOG_WARN("fail to get next item", K(ret));
|
||||
} else if (OB_FAIL(deserialize_and_inc_macro_ref(meta_id_buf, meta_id_len, inc_meta_id_success))) {
|
||||
LOG_WARN("fail to deserialize and inc macro ref", K(ret));
|
||||
} else if (OB_FAIL(block_reader.get_next_item(data_id_buf, data_id_len, addr))) {
|
||||
LOG_WARN("fail to get next item", K(ret));
|
||||
} else if (OB_FAIL(deserialize_and_inc_macro_ref(data_id_buf, data_id_len, inc_data_id_success))) {
|
||||
LOG_WARN("fail to deserialize and inc macro ref", K(ret));
|
||||
} else if (OB_FAIL(block_reader.get_next_item(shared_meta_id_buf, shared_meta_id_len, addr))) {
|
||||
LOG_WARN("fail to get next item", K(ret));
|
||||
} else if (OB_FAIL(deserialize_and_inc_macro_ref(shared_meta_id_buf, shared_meta_id_len, inc_shared_meta_id_success))) {
|
||||
LOG_WARN("fail to deserialize and inc macro ref", K(ret));
|
||||
} else if (OB_FAIL(block_reader.get_next_item(shared_data_info_buf, shared_data_info_len, addr))) {
|
||||
LOG_WARN("fail to get next item", K(ret));
|
||||
} else if (OB_FAIL(deserialize_and_inc_shared_macro_ref(shared_data_info_buf, shared_data_info_len, inc_shared_data_id_success))) {
|
||||
LOG_WARN("fail to deserialize and inc macro ref", K(ret));
|
||||
} else if (OB_FAIL(inc_linked_block_ref_cnt(block_reader.get_meta_block_list(), inc_linked_id_success))) {
|
||||
LOG_WARN("fail to inc linked macro ref", K(ret));
|
||||
}
|
||||
if (OB_FAIL(ret)) {
|
||||
if (inc_meta_id_success) {
|
||||
deserialize_and_dec_macro_ref(meta_id_buf, meta_id_len);
|
||||
}
|
||||
if (inc_data_id_success) {
|
||||
deserialize_and_dec_macro_ref(data_id_buf, data_id_len);
|
||||
}
|
||||
if (inc_shared_meta_id_success) {
|
||||
deserialize_and_dec_macro_ref(shared_meta_id_buf, shared_meta_id_len);
|
||||
}
|
||||
if (inc_shared_data_id_success) {
|
||||
deserialize_and_dec_shared_macro_ref(shared_data_info_buf, shared_data_info_len);
|
||||
}
|
||||
if (inc_linked_id_success) {
|
||||
dec_linked_block_ref_cnt(block_reader.get_meta_block_list());
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTabletMacroInfo::inc_linked_block_ref_cnt(
|
||||
const ObIArray<blocksstable::MacroBlockId> &linked_block_list,
|
||||
bool &inc_macro_id_success) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int64_t inc_cnt = 0;
|
||||
inc_macro_id_success = false;
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < linked_block_list.count(); i++) {
|
||||
if (OB_FAIL(OB_SERVER_BLOCK_MGR.inc_ref(linked_block_list.at(i)))) {
|
||||
LOG_WARN("fail to increase ref cnt for linked block", K(ret), K(i), K(linked_block_list.at(i)));
|
||||
} else {
|
||||
inc_cnt++;
|
||||
}
|
||||
}
|
||||
if (OB_FAIL(ret)) {
|
||||
int tmp_ret = OB_SUCCESS;
|
||||
for (int64_t i = 0; i < inc_cnt; i++) {
|
||||
if (OB_FAIL(OB_SERVER_BLOCK_MGR.dec_ref(linked_block_list.at(i)))) {
|
||||
LOG_WARN("fail to decrease ref cnt for linked block", K(tmp_ret), K(i), K(linked_block_list.at(i)));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
inc_macro_id_success = true;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ObTabletMacroInfo::dec_linked_block_ref_cnt(const ObIArray<blocksstable::MacroBlockId> &linked_block_list) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
for (int64_t i = 0; i < linked_block_list.count(); i++) {
|
||||
if (OB_FAIL(OB_SERVER_BLOCK_MGR.dec_ref(linked_block_list.at(i)))) {
|
||||
LOG_WARN("fail to decrease ref cnt for linked block", K(ret), K(i), K(linked_block_list.at(i)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ObTabletMacroInfo::deserialize_and_dec_macro_ref(const char *buf, const int64_t buf_len) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int64_t cnt = 0;
|
||||
int64_t pos = 0;
|
||||
MacroBlockId macro_id;
|
||||
int16_t macro_type;
|
||||
ObArenaAllocator allocator;
|
||||
ObBlockInfoArray<MacroBlockId> block_id_arr;
|
||||
if (OB_FAIL(serialization::decode_i16(buf, buf_len, pos, ¯o_type))) {
|
||||
LOG_WARN("fail to deserialize macro type", K(ret), K(buf_len), K(pos));
|
||||
} else if (OB_FAIL(block_id_arr.deserialize(allocator, buf, buf_len, pos))) {
|
||||
LOG_WARN("fail to deserialize block id arr", K(ret), K(buf_len), K(pos));
|
||||
} else {
|
||||
do_dec_macro_ref(block_id_arr);
|
||||
}
|
||||
}
|
||||
|
||||
void ObTabletMacroInfo::deserialize_and_dec_shared_macro_ref(const char *buf, const int64_t buf_len) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int64_t cnt = 0;
|
||||
int64_t pos = 0;
|
||||
ObSharedBlockInfo block_info;
|
||||
int16_t macro_type;
|
||||
ObArenaAllocator allocator;
|
||||
ObBlockInfoArray<MacroBlockId> block_info_arr;
|
||||
if (OB_FAIL(serialization::decode_i16(buf, buf_len, pos, ¯o_type))) {
|
||||
LOG_WARN("fail to deserialize macro type", K(ret), K(buf_len), K(pos));
|
||||
} else if (OB_FAIL(block_info_arr.deserialize(allocator, buf, buf_len, pos))) {
|
||||
LOG_WARN("fail to deserialize block id arr", K(ret), K(buf_len), K(pos));
|
||||
} else {
|
||||
do_dec_macro_ref(block_info_arr);
|
||||
}
|
||||
}
|
||||
|
||||
int ObTabletMacroInfo::deserialize_and_inc_macro_ref(const char *buf, const int64_t buf_len, bool &inc_success) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int64_t cnt = 0;
|
||||
int64_t pos = 0;
|
||||
int64_t inc_cnt = 0;
|
||||
int64_t id_pos = 0;
|
||||
MacroBlockId macro_id;
|
||||
inc_success = false;
|
||||
int16_t macro_type;
|
||||
ObArenaAllocator allocator;
|
||||
ObBlockInfoArray<MacroBlockId> block_id_arr;
|
||||
if (OB_FAIL(serialization::decode_i16(buf, buf_len, pos, ¯o_type))) {
|
||||
LOG_WARN("fail to deserialize macro type", K(ret), K(buf_len), K(pos));
|
||||
} else if (OB_FAIL(block_id_arr.deserialize(allocator, buf, buf_len, pos))) {
|
||||
LOG_WARN("fail to deserialize block id arr", K(ret), KP(buf), K(buf_len));
|
||||
} else if (OB_FAIL(do_inc_macro_ref(block_id_arr, inc_success))) {
|
||||
LOG_WARN("fail to increase macro ref", K(ret), K(block_id_arr));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTabletMacroInfo::deserialize_and_inc_shared_macro_ref(const char *buf, const int64_t buf_len, bool &inc_success) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int64_t cnt = 0;
|
||||
int64_t pos = 0;
|
||||
int64_t id_pos = 0;
|
||||
int64_t macro_ref_inc_cnt = 0;
|
||||
int64_t occupy_size_inc_cnt = 0;
|
||||
ObSharedBlockInfo block_info;
|
||||
int16_t macro_type;
|
||||
inc_success = false;
|
||||
ObArenaAllocator allocator;
|
||||
ObBlockInfoArray<ObSharedBlockInfo> block_info_arr;
|
||||
if (OB_FAIL(serialization::decode_i16(buf, buf_len, pos, ¯o_type))) {
|
||||
LOG_WARN("fail to deserialize macro id cnt", K(ret), K(buf_len));
|
||||
} else if (OB_FAIL(block_info_arr.deserialize(allocator, buf, buf_len, pos))) {
|
||||
LOG_WARN("fail to deserialize block id arr", K(ret), KP(buf), K(buf_len));
|
||||
} else if (OB_FAIL(do_inc_macro_ref(block_info_arr, inc_success))) {
|
||||
LOG_WARN("fail to increase macro ref", K(ret), K(block_info_arr));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ObTabletMacroInfo::dec_macro_ref_without_io() const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
do_dec_macro_ref(data_block_info_arr_);
|
||||
do_dec_macro_ref(meta_block_info_arr_);
|
||||
do_dec_macro_ref(shared_meta_block_info_arr_);
|
||||
do_dec_macro_ref(shared_data_block_info_arr_);
|
||||
}
|
||||
|
||||
int ObTabletMacroInfo::inc_macro_ref_without_io() const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
bool inc_data_macro_id_success = false;
|
||||
bool inc_meta_macro_id_success = false;
|
||||
bool inc_shared_meta_macro_id_success = false;
|
||||
bool inc_shared_data_macro_id_success = false;
|
||||
if (OB_FAIL(do_inc_macro_ref(meta_block_info_arr_, inc_meta_macro_id_success))) {
|
||||
LOG_WARN("fail to increase meta blocks' ref cnt", K(ret), K(meta_block_info_arr_));
|
||||
} else if (OB_FAIL(do_inc_macro_ref(data_block_info_arr_, inc_data_macro_id_success))) {
|
||||
LOG_WARN("fail to increase data blocks' ref cnt", K(ret), K(data_block_info_arr_));
|
||||
} else if (OB_FAIL(do_inc_macro_ref(shared_meta_block_info_arr_, inc_shared_meta_macro_id_success))) {
|
||||
LOG_WARN("fail to increase shared meta blocks' ref cnt", K(ret), K(shared_meta_block_info_arr_));
|
||||
} else if (OB_FAIL(do_inc_macro_ref(shared_data_block_info_arr_, inc_shared_data_macro_id_success))) {
|
||||
LOG_WARN("fail to increase shared data blocks' ref cnt and block size", K(ret), K(shared_data_block_info_arr_));
|
||||
}
|
||||
if (OB_FAIL(ret)) {
|
||||
if (inc_data_macro_id_success) {
|
||||
do_dec_macro_ref(data_block_info_arr_);
|
||||
}
|
||||
if (inc_meta_macro_id_success) {
|
||||
do_dec_macro_ref(meta_block_info_arr_);
|
||||
}
|
||||
if (inc_shared_meta_macro_id_success) {
|
||||
do_dec_macro_ref(shared_meta_block_info_arr_);
|
||||
}
|
||||
if (inc_shared_data_macro_id_success) {
|
||||
do_dec_macro_ref(shared_data_block_info_arr_);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTabletMacroInfo::do_inc_macro_ref(const ObBlockInfoArray<ObSharedBlockInfo> &block_info_arr, bool &inc_macro_id_success) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
inc_macro_id_success = false;
|
||||
int64_t macro_ref_inc_cnt = 0;
|
||||
int64_t occupy_size_inc_cnt = 0;
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < block_info_arr.cnt_; i++) {
|
||||
const MacroBlockId ¯o_id = block_info_arr.arr_[i].shared_macro_id_;
|
||||
const int64_t occupy_size = block_info_arr.arr_[i].occupy_size_;
|
||||
if (OB_UNLIKELY(!macro_id.is_valid() || occupy_size <= 0)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("macro_id/occupy_size is invalid", K(ret), K(macro_id), K(occupy_size));
|
||||
} else if (OB_FAIL(OB_SERVER_BLOCK_MGR.inc_ref(macro_id))) {
|
||||
LOG_WARN("fail to increase macro ref cnt", K(ret), K(macro_id));
|
||||
} else if (FALSE_IT(macro_ref_inc_cnt++)) {
|
||||
} else if (OB_FAIL(MTL(ObSharedMacroBlockMgr*)->add_block(macro_id, occupy_size))) {
|
||||
LOG_WARN("fail to increase shared block's occupy size", K(ret), K(macro_id), K(occupy_size));
|
||||
} else {
|
||||
occupy_size_inc_cnt++;
|
||||
}
|
||||
}
|
||||
if (OB_FAIL(ret)) {
|
||||
int tmp_ret = OB_SUCCESS;
|
||||
// no need to check OB_SUCC(ret)
|
||||
for (int64_t i = 0; i < macro_ref_inc_cnt; i++) {
|
||||
const MacroBlockId ¯o_id = block_info_arr.arr_[i].shared_macro_id_;
|
||||
const int64_t occupy_size = block_info_arr.arr_[i].occupy_size_;
|
||||
if (OB_TMP_FAIL(OB_SERVER_BLOCK_MGR.dec_ref(macro_id))) {
|
||||
LOG_WARN("fail to decrease macro ref cnt", K(tmp_ret), K(macro_id));
|
||||
} else if (i < occupy_size_inc_cnt && OB_TMP_FAIL(MTL(ObSharedMacroBlockMgr*)->free_block(macro_id, occupy_size))) {
|
||||
LOG_WARN("fail to decrease shared block's occupy size", K(tmp_ret), K(macro_id), K(occupy_size));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
inc_macro_id_success = true;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTabletMacroInfo::do_inc_macro_ref(const ObBlockInfoArray<blocksstable::MacroBlockId> &block_info_arr, bool &inc_macro_id_success) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
inc_macro_id_success = false;
|
||||
int64_t increased_id_cnt = 0;
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < block_info_arr.cnt_; i++) {
|
||||
const MacroBlockId ¯o_id = block_info_arr.arr_[i];
|
||||
if (OB_UNLIKELY(!macro_id.is_valid())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("macro id is invalid", K(ret), K(macro_id));
|
||||
} else if (OB_FAIL(OB_SERVER_BLOCK_MGR.inc_ref(macro_id))) {
|
||||
LOG_WARN("fail to increase macro ref cnt", K(ret), K(macro_id));
|
||||
} else {
|
||||
increased_id_cnt++;
|
||||
}
|
||||
}
|
||||
if (OB_FAIL(ret)) {
|
||||
int tmp_ret = OB_SUCCESS;
|
||||
// no need to check OB_SUCC(ret)
|
||||
for (int64_t i = 0; i < increased_id_cnt; i++) {
|
||||
const MacroBlockId ¯o_id = block_info_arr.arr_[i];
|
||||
if (OB_TMP_FAIL(OB_SERVER_BLOCK_MGR.dec_ref(macro_id))) {
|
||||
LOG_WARN("fail to decrease macro ref cnt", K(tmp_ret), K(macro_id));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
inc_macro_id_success = true;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ObTabletMacroInfo::do_dec_macro_ref(const ObBlockInfoArray<ObSharedBlockInfo> &block_info_arr) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
// no need to check OB_SUCC(ret)
|
||||
for (int64_t i = 0; i < block_info_arr.cnt_; i++) {
|
||||
const MacroBlockId ¯o_id = block_info_arr.arr_[i].shared_macro_id_;
|
||||
const int64_t occupy_size = block_info_arr.arr_[i].occupy_size_;
|
||||
if (OB_UNLIKELY(!macro_id.is_valid() || occupy_size <= 0)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("macro_id/occupy_size is invalid", K(ret), K(macro_id), K(occupy_size));
|
||||
} else if (OB_FAIL(OB_SERVER_BLOCK_MGR.dec_ref(macro_id))) {
|
||||
LOG_WARN("fail to decrease macro ref cnt", K(ret), K(macro_id));
|
||||
} else if (OB_FAIL(MTL(ObSharedMacroBlockMgr*)->free_block(macro_id, occupy_size))) {
|
||||
LOG_WARN("fail to decrease shared block's occupy size", K(ret), K(macro_id), K(occupy_size));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ObTabletMacroInfo::do_dec_macro_ref(const ObBlockInfoArray<blocksstable::MacroBlockId> &block_info_arr) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
// no need to check OB_SUCC(ret)
|
||||
for (int64_t i = 0; i < block_info_arr.cnt_; i++) {
|
||||
const MacroBlockId ¯o_id = block_info_arr.arr_[i];
|
||||
if (OB_UNLIKELY(!macro_id.is_valid())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("macro id is invalid", K(ret), K(macro_id));
|
||||
} else if (OB_FAIL(OB_SERVER_BLOCK_MGR.dec_ref(macro_id))) {
|
||||
LOG_WARN("fail to decrease macro ref cnt", K(ret), K(macro_id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool ObTabletMacroInfo::ignore_ret(const int ret)
|
||||
{
|
||||
return OB_ALLOCATE_MEMORY_FAILED == ret || OB_TIMEOUT == ret || OB_DISK_HUNG == ret;
|
||||
}
|
||||
} // storage
|
||||
} // oceanbase
|
@ -35,6 +35,7 @@ enum class ObTabletMacroType : int16_t
|
||||
DATA_BLOCK = 2,
|
||||
SHARED_META_BLOCK = 3,
|
||||
SHARED_DATA_BLOCK = 4,
|
||||
LINKED_BLOCK = 5,
|
||||
MAX
|
||||
|
||||
};
|
||||
@ -122,35 +123,36 @@ public:
|
||||
TabletMacroMap shared_data_block_info_map_;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class ObBlockInfoArray final
|
||||
{
|
||||
public:
|
||||
ObBlockInfoArray();
|
||||
~ObBlockInfoArray();
|
||||
void reset();
|
||||
int reserve(const int64_t cnt, ObArenaAllocator &allocator);
|
||||
int serialize(char *buf, const int64_t buf_len, int64_t &pos) const;
|
||||
int deserialize(ObArenaAllocator &allocator, const char *buf, const int64_t data_len, int64_t &pos);
|
||||
int64_t get_serialize_size() const;
|
||||
int64_t get_deep_copy_size() const;
|
||||
int deep_copy(char *buf, const int64_t buf_len, int64_t &pos, ObBlockInfoArray &dest_obj) const;
|
||||
OB_INLINE bool is_valid() const
|
||||
{
|
||||
return (0 == cnt_ && nullptr == arr_) || (0 < cnt_ && nullptr != arr_);
|
||||
}
|
||||
TO_STRING_KV(K_(cnt), KP_(arr), K_(capacity));
|
||||
|
||||
public:
|
||||
int64_t cnt_;
|
||||
T *arr_;
|
||||
|
||||
// no need to be persisted and only used by iterator
|
||||
int64_t capacity_;
|
||||
};
|
||||
|
||||
class ObTabletMacroInfo final
|
||||
{
|
||||
friend class ObMacroInfoIterator;
|
||||
private:
|
||||
template <typename T>
|
||||
class ObBlockInfoArray final
|
||||
{
|
||||
public:
|
||||
ObBlockInfoArray();
|
||||
~ObBlockInfoArray();
|
||||
void reset();
|
||||
int reserve(const int64_t cnt, ObArenaAllocator &allocator);
|
||||
int serialize(char *buf, const int64_t buf_len, int64_t &pos) const;
|
||||
int deserialize(ObArenaAllocator &allocator, const char *buf, const int64_t data_len, int64_t &pos);
|
||||
int64_t get_serialize_size() const;
|
||||
int64_t get_deep_copy_size() const;
|
||||
int deep_copy(char *buf, const int64_t buf_len, int64_t &pos, ObBlockInfoArray &dest_obj) const;
|
||||
OB_INLINE bool is_valid() const
|
||||
{
|
||||
return (0 == cnt_ && nullptr == arr_) || (0 < cnt_ && nullptr != arr_);
|
||||
}
|
||||
TO_STRING_KV(K_(cnt), KP_(arr), K_(capacity));
|
||||
|
||||
public:
|
||||
int64_t cnt_;
|
||||
T *arr_;
|
||||
|
||||
// no need to be persisted and only used by iterator
|
||||
int64_t capacity_;
|
||||
};
|
||||
public:
|
||||
ObTabletMacroInfo();
|
||||
~ObTabletMacroInfo();
|
||||
@ -162,15 +164,6 @@ public:
|
||||
int64_t get_deep_copy_size() const;
|
||||
int deep_copy(char *buf, const int64_t buf_len, ObTabletMacroInfo *&dest_obj) const;
|
||||
bool is_valid() const;
|
||||
|
||||
// inc and dec macro ref cnt, can only be called by tablet
|
||||
int inc_macro_ref(bool &inc_success) const;
|
||||
void dec_macro_ref() const;
|
||||
int get_all_macro_ids(
|
||||
ObIArray<blocksstable::MacroBlockId> &meta_block_arr,
|
||||
ObIArray<blocksstable::MacroBlockId> &data_block_arr,
|
||||
ObIArray<blocksstable::MacroBlockId> &shared_meta_block_arr,
|
||||
ObIArray<blocksstable::MacroBlockId> &shared_data_block_arr);
|
||||
TO_STRING_KV(
|
||||
K_(entry_block),
|
||||
K_(meta_block_info_arr),
|
||||
@ -179,35 +172,6 @@ public:
|
||||
K_(shared_data_block_info_arr),
|
||||
K_(is_inited));
|
||||
private:
|
||||
static bool ignore_ret(const int ret);
|
||||
static int parse_info_arr(
|
||||
const ObBlockInfoArray<ObSharedBlockInfo> &info_arr,
|
||||
ObIArray<blocksstable::MacroBlockId> &id_arr);
|
||||
static int parse_id_arr(
|
||||
const ObBlockInfoArray<blocksstable::MacroBlockId> &info_arr,
|
||||
ObIArray<blocksstable::MacroBlockId> &id_arr);
|
||||
static int parse_info_buf(
|
||||
const char *buf,
|
||||
const int64_t buf_len,
|
||||
ObIArray<blocksstable::MacroBlockId> &block_id_arr);
|
||||
static int parse_id_buf(
|
||||
const char *buf,
|
||||
const int64_t buf_len,
|
||||
ObIArray<blocksstable::MacroBlockId> &block_id_arr);
|
||||
int get_macro_ids_with_io(
|
||||
ObIArray<blocksstable::MacroBlockId> &meta_block_arr,
|
||||
ObIArray<blocksstable::MacroBlockId> &data_block_arr,
|
||||
ObIArray<blocksstable::MacroBlockId> &shared_meta_block_arr,
|
||||
ObIArray<blocksstable::MacroBlockId> &shared_data_block_arr);
|
||||
int get_macro_ids_without_io(
|
||||
ObIArray<blocksstable::MacroBlockId> &meta_block_arr,
|
||||
ObIArray<blocksstable::MacroBlockId> &data_block_arr,
|
||||
ObIArray<blocksstable::MacroBlockId> &shared_meta_block_arr,
|
||||
ObIArray<blocksstable::MacroBlockId> &shared_data_block_arr);
|
||||
int inc_linked_block_ref_cnt(
|
||||
const ObIArray<blocksstable::MacroBlockId> &linked_block_list,
|
||||
bool &inc_macro_id_success) const;
|
||||
void dec_linked_block_ref_cnt(const ObIArray<blocksstable::MacroBlockId> &linked_block_list) const;
|
||||
int construct_block_id_arr(const ObBlockInfoSet::TabletMacroSet &id_set, ObBlockInfoArray<blocksstable::MacroBlockId> &block_id_arr);
|
||||
int construct_block_info_arr(const ObBlockInfoSet::TabletMacroMap &block_info_map, ObBlockInfoArray<ObSharedBlockInfo> &block_info_arr);
|
||||
int persist_macro_ids(ObArenaAllocator &allocator, ObLinkedMacroBlockItemWriter &linked_writer);
|
||||
@ -220,18 +184,6 @@ private:
|
||||
ObBlockInfoArray<ObSharedBlockInfo> &block_info_arr,
|
||||
ObArenaAllocator &allocator,
|
||||
ObLinkedMacroBlockItemWriter &linked_writer);
|
||||
int inc_macro_ref_with_io() const;
|
||||
int inc_macro_ref_without_io() const;
|
||||
void dec_macro_ref_with_io() const;
|
||||
void dec_macro_ref_without_io() const;
|
||||
int deserialize_and_inc_macro_ref(const char *buf, const int64_t buf_len, bool &inc_success) const;
|
||||
void deserialize_and_dec_macro_ref(const char *buf, const int64_t buf_len) const;
|
||||
int deserialize_and_inc_shared_macro_ref(const char *buf, const int64_t buf_len, bool &inc_success) const;
|
||||
void deserialize_and_dec_shared_macro_ref(const char *buf, const int64_t buf_len) const;
|
||||
int do_inc_macro_ref(const ObBlockInfoArray<blocksstable::MacroBlockId> &block_info_arr, bool &inc_macro_id_success) const;
|
||||
void do_dec_macro_ref(const ObBlockInfoArray<blocksstable::MacroBlockId> &block_info_arr) const;
|
||||
int do_inc_macro_ref(const ObBlockInfoArray<ObSharedBlockInfo> &block_info_arr, bool &inc_macro_id_success) const;
|
||||
void do_dec_macro_ref(const ObBlockInfoArray<ObSharedBlockInfo> &block_info_arr) const;
|
||||
private:
|
||||
static const int64_t ID_COUNT_THRESHOLD = 50000; // occupy almost 1.2MB disk space
|
||||
static const int32_t TABLET_MACRO_INFO_VERSION = 1;
|
||||
|
@ -50,7 +50,7 @@ ObMacroInfoIterator::ObMacroInfoIterator()
|
||||
cur_type_(ObTabletMacroType::INVALID_TYPE),
|
||||
target_type_(ObTabletMacroType::INVALID_TYPE), block_info_arr_(),
|
||||
allocator_("MacroInfoIter", OB_MALLOC_NORMAL_BLOCK_SIZE, MTL_ID()),
|
||||
is_linked_(false), is_loaded_(false), is_inited_(false)
|
||||
is_linked_(false), is_inited_(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -68,33 +68,21 @@ void ObMacroInfoIterator::destroy()
|
||||
target_type_ = ObTabletMacroType::INVALID_TYPE;
|
||||
block_info_arr_.reset();
|
||||
is_linked_ = false;
|
||||
if (is_loaded_ && nullptr != macro_info_) {
|
||||
macro_info_->reset();
|
||||
}
|
||||
macro_info_ = nullptr;
|
||||
is_loaded_ = false;
|
||||
is_inited_ = false;
|
||||
}
|
||||
|
||||
int ObMacroInfoIterator::init(const ObTabletMacroType target_type, const ObTablet &tablet)
|
||||
int ObMacroInfoIterator::init(const ObTabletMacroType target_type, const ObTabletMacroInfo ¯o_info)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObTabletMacroInfo *macro_info = nullptr;
|
||||
bool in_memory = false;
|
||||
|
||||
if (OB_UNLIKELY(is_inited_)) {
|
||||
ret = OB_INIT_TWICE;
|
||||
LOG_WARN("Macro Info Iterator has been inited", K(ret));
|
||||
} else if (OB_UNLIKELY(!tablet.is_valid() || ObTabletMacroType::INVALID_TYPE == target_type)) {
|
||||
} else if (OB_UNLIKELY(!macro_info.is_valid() || ObTabletMacroType::INVALID_TYPE == target_type)) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("macro info is invalid", K(ret), K(macro_info), K(target_type));
|
||||
} else if (OB_FAIL(tablet.load_macro_info(allocator_, macro_info, in_memory))) {
|
||||
LOG_WARN("fail to load macro info", K(ret), K(tablet));
|
||||
} else if (OB_ISNULL(macro_info) || OB_UNLIKELY(!macro_info->is_valid())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("invalid macro info", K(ret), KPC(macro_info));
|
||||
LOG_WARN("invalid args", K(ret), K(macro_info));
|
||||
} else {
|
||||
const MacroBlockId &entry_block = macro_info->entry_block_;
|
||||
const MacroBlockId &entry_block = macro_info.entry_block_;
|
||||
if (!IS_EMPTY_BLOCK_LIST(entry_block)) {
|
||||
if (OB_FAIL(block_reader_.init(entry_block))) {
|
||||
LOG_WARN("fail to init block reader", K(ret), K(entry_block));
|
||||
@ -111,13 +99,40 @@ int ObMacroInfoIterator::init(const ObTabletMacroType target_type, const ObTable
|
||||
cur_size_ = 0;
|
||||
cur_type_ = ObTabletMacroType::MAX;
|
||||
target_type_ = target_type;
|
||||
macro_info_ = macro_info;
|
||||
is_loaded_ = !in_memory;
|
||||
macro_info_ = ¯o_info;
|
||||
is_inited_ = true;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObMacroInfoIterator::reuse()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (IS_NOT_INIT) {
|
||||
ret = OB_NOT_INIT;
|
||||
LOG_WARN("macro info iterator hasn't been inited", K(ret));
|
||||
} else if (OB_ISNULL(macro_info_) || OB_UNLIKELY(!macro_info_->is_valid())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected macro info", K(ret), K_(macro_info));
|
||||
} else {
|
||||
block_info_arr_.reset();
|
||||
cur_pos_ = 0;
|
||||
cur_size_ = 0;
|
||||
cur_type_ = ObTabletMacroType::MAX;
|
||||
if (is_linked_) {
|
||||
block_reader_.reset();
|
||||
const MacroBlockId &entry_block = macro_info_->entry_block_;
|
||||
if (OB_UNLIKELY(!entry_block.is_valid() || IS_EMPTY_BLOCK_LIST(entry_block))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected entry block", K(ret), K(entry_block), K(is_linked_));
|
||||
} else if (OB_FAIL(block_reader_.init(entry_block))) {
|
||||
LOG_WARN("fail to init block reader", K(ret), K(entry_block));
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObMacroInfoIterator::get_next(ObTabletBlockInfo &block_info)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
@ -126,13 +141,19 @@ int ObMacroInfoIterator::get_next(ObTabletBlockInfo &block_info)
|
||||
LOG_WARN("macro info iterator hasn't been inited", K(ret));
|
||||
}
|
||||
while (OB_SUCC(ret) && cur_pos_ == cur_size_) {
|
||||
if (is_linked_) {
|
||||
if (OB_FAIL(read_from_disk())) {
|
||||
LOG_WARN("fail to read block info from disk", K(ret));
|
||||
}
|
||||
} else {
|
||||
if (!is_linked_) {
|
||||
if (OB_FAIL(read_from_memory())) {
|
||||
LOG_WARN("fail to read block info from memory", K(ret));
|
||||
if (OB_ITER_END != ret) {
|
||||
LOG_WARN("fail to read block info from memory", K(ret));
|
||||
}
|
||||
}
|
||||
} else if (ObTabletMacroType::LINKED_BLOCK == cur_type_) {
|
||||
ret = OB_ITER_END;
|
||||
} else {
|
||||
if (OB_FAIL(read_from_disk())) {
|
||||
if (OB_ITER_END != ret) {
|
||||
LOG_WARN("fail to read block info from disk", K(ret));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
@ -154,6 +175,9 @@ int ObMacroInfoIterator::read_from_memory()
|
||||
|| ObTabletMacroType::INVALID_TYPE == cur_type_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("invalid membership", K(ret), KP_(macro_info), K_(target_type), K_(cur_type));
|
||||
} else if (OB_UNLIKELY(ObTabletMacroType::LINKED_BLOCK == target_type_)) {
|
||||
ret = OB_NOT_SUPPORTED;
|
||||
LOG_WARN("don't support", K(ret));
|
||||
} else if (ObTabletMacroType::MAX == target_type_) {
|
||||
switch (cur_type_) {
|
||||
case ObTabletMacroType::MAX:
|
||||
@ -168,9 +192,13 @@ int ObMacroInfoIterator::read_from_memory()
|
||||
case ObTabletMacroType::SHARED_META_BLOCK:
|
||||
cur_type_ = ObTabletMacroType::SHARED_DATA_BLOCK;
|
||||
break;
|
||||
default:
|
||||
case ObTabletMacroType::SHARED_DATA_BLOCK:
|
||||
ret = OB_ITER_END;
|
||||
break;
|
||||
default:
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected macro type", K(ret), K(cur_type_));
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (cur_type_ == target_type_) {
|
||||
@ -228,12 +256,15 @@ int ObMacroInfoIterator::read_from_disk()
|
||||
ObMetaDiskAddr addr;
|
||||
int64_t pos = 0;
|
||||
const ObTabletMacroType prev_type = cur_type_;
|
||||
const bool target_iter = ObTabletMacroType::MAX != target_type_;
|
||||
|
||||
if (OB_UNLIKELY(ObTabletMacroType::INVALID_TYPE == target_type_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("invalid target_type", K(ret));
|
||||
} else if (OB_UNLIKELY(ObTabletMacroType::LINKED_BLOCK == target_type_)) {
|
||||
ret = OB_NOT_SUPPORTED;
|
||||
LOG_WARN("don't support", K(ret));
|
||||
} else {
|
||||
const bool target_iter = ObTabletMacroType::MAX != target_type_;
|
||||
do {
|
||||
pos = 0;
|
||||
buf = nullptr;
|
||||
@ -256,7 +287,7 @@ int ObMacroInfoIterator::read_from_disk()
|
||||
if (OB_FAIL(ret)) {
|
||||
// do nothing
|
||||
} else if (ObTabletMacroType::SHARED_DATA_BLOCK == cur_type_) {
|
||||
ObBlockInfoArray<ObSharedBlockInfo> tmp_arr;
|
||||
ObTabletMacroInfo::ObBlockInfoArray<ObSharedBlockInfo> tmp_arr;
|
||||
if (OB_FAIL(tmp_arr.deserialize(allocator, buf, buf_len, pos))) {
|
||||
LOG_WARN("fail to deserialize block info arr", K(ret), K(buf_len), K(pos));
|
||||
} else if (OB_FAIL(reuse_info_arr(tmp_arr.cnt_))) {
|
||||
@ -265,7 +296,7 @@ int ObMacroInfoIterator::read_from_disk()
|
||||
LOG_WARN("fail to convert to block info", K(ret), K(tmp_arr));
|
||||
}
|
||||
} else {
|
||||
ObBlockInfoArray<MacroBlockId> tmp_arr;
|
||||
ObTabletMacroInfo::ObBlockInfoArray<MacroBlockId> tmp_arr;
|
||||
if (OB_FAIL(tmp_arr.deserialize(allocator, buf, buf_len, pos))) {
|
||||
LOG_WARN("fail to deserialize block info arr", K(ret), K(buf_len), K(pos));
|
||||
} else if (OB_FAIL(reuse_info_arr(tmp_arr.cnt_))) {
|
||||
@ -274,10 +305,29 @@ int ObMacroInfoIterator::read_from_disk()
|
||||
LOG_WARN("fail to convert to block info", K(ret), K(tmp_arr));
|
||||
}
|
||||
}
|
||||
|
||||
if (OB_ITER_END == ret && !target_iter) {
|
||||
ret = OB_SUCCESS;
|
||||
cur_type_ = ObTabletMacroType::LINKED_BLOCK;
|
||||
const ObIArray<MacroBlockId> &meta_block_list = block_reader_.get_meta_block_list();
|
||||
const int64_t block_cnt = meta_block_list.count();
|
||||
if (OB_FAIL(reuse_info_arr(block_cnt))) {
|
||||
LOG_WARN("fail to reuse block_info_arr_", K(ret), K(block_cnt));
|
||||
}
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < block_cnt; i++) {
|
||||
const MacroBlockId &tmp_macro_id = meta_block_list.at(i);
|
||||
if (OB_UNLIKELY(!tmp_macro_id.is_valid())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("macro id is invalid", K(ret), K(tmp_macro_id));
|
||||
} else {
|
||||
block_info_arr_.arr_[i] = ObTabletBlockInfo(tmp_macro_id, cur_type_, OB_DEFAULT_MACRO_BLOCK_SIZE);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObMacroInfoIterator::convert_to_block_info(const ObBlockInfoArray<ObSharedBlockInfo> &tmp_arr)
|
||||
int ObMacroInfoIterator::convert_to_block_info(const ObTabletMacroInfo::ObBlockInfoArray<ObSharedBlockInfo> &tmp_arr)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < tmp_arr.cnt_; i++) {
|
||||
@ -291,7 +341,7 @@ int ObMacroInfoIterator::convert_to_block_info(const ObBlockInfoArray<ObSharedBl
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObMacroInfoIterator::convert_to_block_info(const ObBlockInfoArray<blocksstable::MacroBlockId> &tmp_arr)
|
||||
int ObMacroInfoIterator::convert_to_block_info(const ObTabletMacroInfo::ObBlockInfoArray<blocksstable::MacroBlockId> &tmp_arr)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < tmp_arr.cnt_; i++) {
|
||||
|
@ -31,6 +31,7 @@ public:
|
||||
const int64_t occupy_size);
|
||||
~ObTabletBlockInfo();
|
||||
void reset();
|
||||
TO_STRING_KV(K_(macro_id), K_(block_type), K_(occupy_size));
|
||||
public:
|
||||
blocksstable::MacroBlockId macro_id_;
|
||||
ObTabletMacroType block_type_;
|
||||
@ -45,26 +46,27 @@ public:
|
||||
ObMacroInfoIterator(const ObMacroInfoIterator &) = delete;
|
||||
ObMacroInfoIterator &operator=(const ObMacroInfoIterator &) = delete;
|
||||
void destroy();
|
||||
// max means iterate all kinds of ids
|
||||
int init(const ObTabletMacroType target_type, const ObTablet &tablet);
|
||||
int reuse();
|
||||
// ObTabletMacroType::MAX means iterate all kinds of ids
|
||||
int init(const ObTabletMacroType target_type, const ObTabletMacroInfo ¯o_info);
|
||||
int get_next(ObTabletBlockInfo &block_info);
|
||||
TO_STRING_KV(KPC_(macro_info), K_(cur_type), K_(target_type), K_(is_linked));
|
||||
private:
|
||||
int read_from_disk();
|
||||
int read_from_memory();
|
||||
int reuse_info_arr(const int64_t cnt);
|
||||
int convert_to_block_info(const ObBlockInfoArray<ObSharedBlockInfo> &tmp_arr);
|
||||
int convert_to_block_info(const ObBlockInfoArray<blocksstable::MacroBlockId> &tmp_arr);
|
||||
int convert_to_block_info(const ObTabletMacroInfo::ObBlockInfoArray<ObSharedBlockInfo> &tmp_arr);
|
||||
int convert_to_block_info(const ObTabletMacroInfo::ObBlockInfoArray<blocksstable::MacroBlockId> &tmp_arr);
|
||||
private:
|
||||
ObTabletMacroInfo *macro_info_;
|
||||
const ObTabletMacroInfo *macro_info_;
|
||||
ObLinkedMacroBlockItemReader block_reader_;
|
||||
int64_t cur_pos_;
|
||||
int64_t cur_size_;
|
||||
ObTabletMacroType cur_type_;
|
||||
ObTabletMacroType target_type_;
|
||||
ObBlockInfoArray<ObTabletBlockInfo> block_info_arr_;
|
||||
ObTabletMacroInfo::ObBlockInfoArray<ObTabletBlockInfo> block_info_arr_;
|
||||
common::ObArenaAllocator allocator_;
|
||||
bool is_linked_;
|
||||
bool is_loaded_;
|
||||
bool is_inited_;
|
||||
};
|
||||
}
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "storage/tablet/ob_tablet_common.h"
|
||||
#include "storage/tablet/ob_tablet_block_header.h"
|
||||
#include "storage/tablet/ob_tablet_slog_helper.h"
|
||||
#include "storage/tablet/ob_tablet_macro_info_iterator.h"
|
||||
|
||||
using namespace std::placeholders;
|
||||
using namespace oceanbase::common;
|
||||
@ -326,6 +327,7 @@ int ObTabletPersister::persist_and_transform_tablet(
|
||||
return ret;
|
||||
}
|
||||
|
||||
// !!!attention shouldn't be called by empty shell
|
||||
/*static*/ int ObTabletPersister::persist_and_transform_only_tablet_meta(
|
||||
const ObTablet &old_tablet,
|
||||
ObITabletMetaModifier &modifier,
|
||||
@ -739,6 +741,8 @@ int ObTabletPersister::persist_aggregated_meta(
|
||||
ObTabletSpaceUsage &space_usage)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObMacroInfoIterator macro_iter;
|
||||
bool inc_success = false;
|
||||
ObTablet *new_tablet = new_handle.get_obj();
|
||||
ObTenantCheckpointSlogHandler *ckpt_slog_handler = MTL(ObTenantCheckpointSlogHandler*);
|
||||
ObSharedBlockWriteInfo write_info;
|
||||
@ -748,6 +752,7 @@ int ObTabletPersister::persist_aggregated_meta(
|
||||
MacroBlockId macro_id;
|
||||
int64_t offset = 0;
|
||||
int64_t size = 0;
|
||||
|
||||
if (OB_FAIL(fill_tablet_write_info(allocator_, new_tablet, tablet_macro_info, write_info))) {
|
||||
LOG_WARN("fail to fill write info", K(ret), KPC(new_tablet));
|
||||
} else if (OB_FAIL(ckpt_slog_handler->get_shared_block_raw_reader_writer().async_write(write_info, handle))) {
|
||||
@ -759,8 +764,10 @@ int ObTabletPersister::persist_aggregated_meta(
|
||||
LOG_WARN("fail to get block addr", K(ret), K(write_ctx));
|
||||
} else if (OB_FAIL(new_tablet->set_macro_info_addr(macro_id, offset + (size - secondary_meta_size), secondary_meta_size, ObMetaDiskAddr::DiskType::RAW_BLOCK))) {
|
||||
LOG_WARN("fail to set macro info addr", K(ret), K(macro_id), K(offset), K(size), K(secondary_meta_size));
|
||||
} else if (OB_FAIL(new_tablet->inc_macro_ref_with_macro_info(tablet_macro_info))) {
|
||||
LOG_WARN("fail to increase macro ref cnt for new tablet", K(ret), KPC(new_tablet));
|
||||
} else if (OB_FAIL(macro_iter.init(ObTabletMacroType::MAX, tablet_macro_info))) {
|
||||
LOG_WARN("fail to init macro info iter", K(ret), K(tablet_macro_info));
|
||||
} else if (OB_FAIL(inc_ref_with_macro_iter(*new_tablet, macro_iter))) {
|
||||
LOG_WARN("fail to increase macro ref cnt", K(ret));
|
||||
} else {
|
||||
space_usage.shared_meta_size_ += upper_align(write_ctx.addr_.size(), DIO_READ_ALIGN_SIZE);
|
||||
new_tablet->tablet_meta_.space_usage_ = space_usage;
|
||||
@ -768,6 +775,36 @@ int ObTabletPersister::persist_aggregated_meta(
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTabletPersister::inc_ref_with_macro_iter(ObTablet &tablet, ObMacroInfoIterator ¯o_iter)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
bool inc_tablet_macro_ref_success = false;
|
||||
bool inc_other_macro_ref_success = false;
|
||||
const ObMetaDiskAddr &tablet_addr = tablet.tablet_addr_;
|
||||
|
||||
if (OB_FAIL(ObTablet::inc_addr_ref_cnt(tablet_addr, inc_tablet_macro_ref_success))) {
|
||||
LOG_WARN("fail to increase tablet macro ref", K(ret), K(tablet_addr));
|
||||
} else if (OB_FAIL(tablet.inc_ref_with_macro_iter(macro_iter, inc_other_macro_ref_success))) {
|
||||
LOG_WARN("fail to increase ref cnt from macro iter", K(ret));
|
||||
}
|
||||
if (OB_FAIL(ret)) {
|
||||
if (inc_tablet_macro_ref_success) {
|
||||
ObTablet::dec_addr_ref_cnt(tablet_addr);
|
||||
}
|
||||
if (inc_other_macro_ref_success) {
|
||||
int tmp_ret = OB_SUCCESS;
|
||||
if (OB_TMP_FAIL(macro_iter.reuse())) {
|
||||
LOG_WARN("fail to reuse macro info iterator", K(tmp_ret));
|
||||
} else {
|
||||
tablet.dec_ref_with_macro_iter(macro_iter);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
tablet.hold_ref_cnt_ = true;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTabletPersister::fill_tablet_write_info(
|
||||
common::ObArenaAllocator &allocator,
|
||||
const ObTablet *tablet,
|
||||
|
@ -226,6 +226,7 @@ public:
|
||||
ObBlockInfoSet &block_info_set);
|
||||
static int transform_empty_shell(const ObTablet &old_tablet, ObTabletHandle &new_handle);
|
||||
private:
|
||||
static int inc_ref_with_macro_iter(ObTablet &tablet, ObMacroInfoIterator ¯o_iter);
|
||||
static int do_copy_ids(
|
||||
blocksstable::ObMacroIdIterator &iter,
|
||||
ObBlockInfoSet::TabletMacroSet &id_set);
|
||||
|
Loading…
x
Reference in New Issue
Block a user