[BUG.FIX] fix -4016 issue when loading tablet

This commit is contained in:
Tyshawn
2023-10-18 03:13:55 +00:00
committed by ob-robot
parent 9688e0d157
commit eb7a594855
13 changed files with 32 additions and 22 deletions

View File

@ -351,7 +351,7 @@ void TestTxDataTable::init_memtable_mgr_(ObTxDataMemtableMgr *memtable_mgr)
{
ASSERT_NE(nullptr, memtable_mgr);
memtable_mgr->set_freezer(&tx_data_table_.freezer_);
ASSERT_EQ(OB_SUCCESS, memtable_mgr->create_memtable(SCN::min_scn(), 1));
ASSERT_EQ(OB_SUCCESS, memtable_mgr->create_memtable(SCN::min_scn(), 1, SCN::min_scn()));
ASSERT_EQ(1, memtable_mgr->get_memtable_count_());
}
@ -634,7 +634,7 @@ void TestTxDataTable::do_repeat_insert_test() {
ObTxDataMemtableMgr *memtable_mgr = tx_data_table_.get_memtable_mgr_();
ASSERT_NE(nullptr, memtable_mgr);
memtable_mgr->set_freezer(&tx_data_table_.freezer_);
ASSERT_EQ(OB_SUCCESS, memtable_mgr->create_memtable(SCN::min_scn(), 1));
ASSERT_EQ(OB_SUCCESS, memtable_mgr->create_memtable(SCN::min_scn(), 1, SCN::min_scn()));
ASSERT_EQ(1, memtable_mgr->get_memtable_count_());
insert_start_scn.convert_for_logservice(ObTimeUtil::current_time_ns());

View File

@ -518,15 +518,14 @@ int ObMetaPointerMap<Key, T>::load_meta_obj(
common::ObBucketHashRLockGuard lock_guard(ResourceMap::bucket_lock_, hash_val);
if (OB_FAIL(meta_pointer->read_from_disk(arena_allocator, buf, buf_len, load_addr))) {
STORAGE_LOG(WARN, "fail to read from disk", K(ret), KPC(meta_pointer));
}
}
if (OB_SUCC(ret)) {
} else {
t->tablet_addr_ = load_addr;
if (OB_FAIL(meta_pointer->deserialize(allocator, buf, buf_len, t))) {
STORAGE_LOG(WARN, "fail to deserialize object", K(ret), K(key), KPC(meta_pointer));
}
}
}
}
// this load_meta_obj is called when tablet memory hold by external allocator
// let caller tackle failure, recycle object and memory,
@ -557,15 +556,14 @@ int ObMetaPointerMap<Key, T>::load_meta_obj(
common::ObBucketHashRLockGuard lock_guard(ResourceMap::bucket_lock_, hash_val);
if (OB_FAIL(meta_pointer->read_from_disk(arena_allocator, buf, buf_len, load_addr))) {
STORAGE_LOG(WARN, "fail to read from disk", K(ret), KPC(meta_pointer));
}
}
if (OB_SUCC(ret)) {
} else {
t->tablet_addr_ = load_addr;
if (OB_FAIL(meta_pointer->deserialize(buf, buf_len, t))) {
STORAGE_LOG(WARN, "fail to deserialize object", K(ret), K(key), KPC(meta_pointer));
}
}
}
}
if (OB_FAIL(ret) && OB_NOT_NULL(t)) {
meta_pointer->release_obj(t);

View File

@ -221,10 +221,12 @@ public:
virtual int create_memtable(const share::SCN clog_checkpoint_scn,
const int64_t schema_version,
const share::SCN newest_clog_checkpoint_scn,
const bool for_replay = false)
{
UNUSED(clog_checkpoint_scn);
UNUSED(schema_version);
UNUSED(newest_clog_checkpoint_scn);
UNUSED(for_replay);
return OB_NOT_SUPPORTED;
}

View File

@ -82,10 +82,12 @@ void ObLockMemtableMgr::reset()
int ObLockMemtableMgr::create_memtable(const SCN clog_checkpoint_scn,
const int64_t schema_version,
const SCN newest_clog_checkpoint_scn,
const bool for_replay)
{
UNUSED(clog_checkpoint_scn);
UNUSED(schema_version);
UNUSED(newest_clog_checkpoint_scn);
UNUSED(for_replay);
int ret = OB_SUCCESS;

View File

@ -63,6 +63,7 @@ public:
virtual int create_memtable(const share::SCN clog_checkpoint_scn,
const int64_t schema_version,
const share::SCN newest_clog_checkpoint_scn,
const bool for_replay = false) override;
DECLARE_VIRTUAL_TO_STRING;

View File

@ -3474,7 +3474,7 @@ int ObTablet::inner_create_memtable(
}
} else if (OB_FAIL(get_memtable_mgr(memtable_mgr))) {
LOG_WARN("failed to get memtable mgr", K(ret));
} else if (OB_FAIL(memtable_mgr->create_memtable(clog_checkpoint_scn, schema_version, for_replay))) {
} else if (OB_FAIL(memtable_mgr->create_memtable(clog_checkpoint_scn, schema_version, tablet_meta_.clog_checkpoint_scn_, for_replay))) {
if (OB_ENTRY_EXIST != ret && OB_MINOR_FREEZE_NOT_ALLOW != ret) {
LOG_WARN("failed to create memtable for tablet", K(ret), K(ls_id), K(tablet_id),
K(clog_checkpoint_scn), K(schema_version), K(for_replay));

View File

@ -164,6 +164,7 @@ int ObTabletMemtableMgr::reset_storage_recorder()
// 2. create the new memtable after freezing the old memtable
int ObTabletMemtableMgr::create_memtable(const SCN clog_checkpoint_scn,
const int64_t schema_version,
const SCN new_clog_checkpoint_scn,
const bool for_replay)
{
ObTimeGuard time_guard("ObTabletMemtableMgr::create_memtable", 10 * 1000);
@ -178,7 +179,6 @@ int ObTabletMemtableMgr::create_memtable(const SCN clog_checkpoint_scn,
memtable::ObMemtable *active_memtable = nullptr;
uint32_t memtable_freeze_clock = UINT32_MAX;
share::ObLSID ls_id;
SCN new_clog_checkpoint_scn;
int64_t memtable_count = get_memtable_count_();
if (has_memtable && OB_NOT_NULL(active_memtable = get_active_memtable_())) {
memtable_freeze_clock = active_memtable->get_freeze_clock();
@ -204,8 +204,6 @@ int ObTabletMemtableMgr::create_memtable(const SCN clog_checkpoint_scn,
K(get_memtable_count_()),
KPC(first_frozen_memtable.get_table()));
}
} else if (OB_FAIL(get_newest_clog_checkpoint_scn(new_clog_checkpoint_scn))) {
LOG_WARN("failed to get newest clog_checkpoint_scn", K(ret), K(ls_id), K(tablet_id_), K(new_clog_checkpoint_scn));
} else if (for_replay && clog_checkpoint_scn != new_clog_checkpoint_scn) {
ret = OB_EAGAIN;
LOG_INFO("clog_checkpoint_scn changed, need retry to replay", K(ls_id), K(tablet_id_), K(clog_checkpoint_scn), K(new_clog_checkpoint_scn));

View File

@ -65,9 +65,11 @@ public:
int get_last_frozen_memtable(ObTableHandleV2 &handle) const;
virtual int get_boundary_memtable(ObTableHandleV2 &handle) override;
int release_tail_memtable(memtable::ObIMemtable *memtable);
int create_memtable(const share::SCN clog_checkpoint_scn,
virtual int create_memtable(
const share::SCN clog_checkpoint_scn,
const int64_t schema_version,
const bool for_replay);
const share::SCN newest_clog_checkpoint_scn,
const bool for_replay) override;
int get_memtables(
ObTableHdlArray &handle,
const bool reset_handle = true,

View File

@ -60,10 +60,12 @@ void ObTxCtxMemtableMgr::reset()
int ObTxCtxMemtableMgr::create_memtable(const SCN last_replay_scn,
const int64_t schema_version,
const SCN newest_clog_checkpoint_scn,
const bool for_replay)
{
UNUSED(last_replay_scn);
UNUSED(schema_version);
UNUSED(newest_clog_checkpoint_scn);
UNUSED(for_replay);
int ret = OB_SUCCESS;

View File

@ -59,6 +59,7 @@ public:
// create_memtable is used for creating the only memtable for CheckpointMgr
virtual int create_memtable(const share::SCN last_replay_scn,
const int64_t schema_version,
const share::SCN newest_clog_checkpoint_scn,
const bool for_replay=false) override;
const ObTxCtxMemtable *get_tx_ctx_memtable_(const int64_t pos) const;

View File

@ -132,8 +132,10 @@ int ObTxDataMemtableMgr::release_head_memtable_(memtable::ObIMemtable *imemtable
int ObTxDataMemtableMgr::create_memtable(const SCN clog_checkpoint_scn,
const int64_t schema_version,
const SCN newest_clog_checkpoint_scn,
const bool for_replay)
{
UNUSED(newest_clog_checkpoint_scn);
UNUSED(for_replay);
int ret = OB_SUCCESS;
if (IS_NOT_INIT) {

View File

@ -120,6 +120,7 @@ public: // ObTxDataMemtableMgr
*/
virtual int create_memtable(const share::SCN clog_checkpoint_scn,
const int64_t schema_version,
const share::SCN newest_clog_checkpoint_scn,
const bool for_replay=false) override;
/**
* @brief Get the last tx data memtable in memtable list.

View File

@ -175,7 +175,8 @@ TEST_F(TestTxCtxTable, test_tx_ctx_memtable_mgr)
{
EXPECT_EQ(0, TestTxCtxTable::ref_count_);
EXPECT_EQ(OB_SUCCESS, mt_mgr_->create_memtable(SCN::min_scn(), /*last_replay_log_ts*/
0 /*schema_version*/));
0 /*schema_version*/,
SCN::min_scn()));
EXPECT_EQ(1, TestTxCtxTable::ref_count_);