[BUG.FIX] fix -4016 issue when loading tablet
This commit is contained in:
@ -351,7 +351,7 @@ void TestTxDataTable::init_memtable_mgr_(ObTxDataMemtableMgr *memtable_mgr)
|
|||||||
{
|
{
|
||||||
ASSERT_NE(nullptr, memtable_mgr);
|
ASSERT_NE(nullptr, memtable_mgr);
|
||||||
memtable_mgr->set_freezer(&tx_data_table_.freezer_);
|
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_());
|
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_();
|
ObTxDataMemtableMgr *memtable_mgr = tx_data_table_.get_memtable_mgr_();
|
||||||
ASSERT_NE(nullptr, memtable_mgr);
|
ASSERT_NE(nullptr, memtable_mgr);
|
||||||
memtable_mgr->set_freezer(&tx_data_table_.freezer_);
|
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_());
|
ASSERT_EQ(1, memtable_mgr->get_memtable_count_());
|
||||||
|
|
||||||
insert_start_scn.convert_for_logservice(ObTimeUtil::current_time_ns());
|
insert_start_scn.convert_for_logservice(ObTimeUtil::current_time_ns());
|
||||||
|
|||||||
@ -518,12 +518,11 @@ int ObMetaPointerMap<Key, T>::load_meta_obj(
|
|||||||
common::ObBucketHashRLockGuard lock_guard(ResourceMap::bucket_lock_, hash_val);
|
common::ObBucketHashRLockGuard lock_guard(ResourceMap::bucket_lock_, hash_val);
|
||||||
if (OB_FAIL(meta_pointer->read_from_disk(arena_allocator, buf, buf_len, load_addr))) {
|
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));
|
STORAGE_LOG(WARN, "fail to read from disk", K(ret), KPC(meta_pointer));
|
||||||
}
|
} else {
|
||||||
}
|
t->tablet_addr_ = load_addr;
|
||||||
if (OB_SUCC(ret)) {
|
if (OB_FAIL(meta_pointer->deserialize(allocator, buf, buf_len, t))) {
|
||||||
t->tablet_addr_ = load_addr;
|
STORAGE_LOG(WARN, "fail to deserialize object", K(ret), K(key), KPC(meta_pointer));
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -557,12 +556,11 @@ int ObMetaPointerMap<Key, T>::load_meta_obj(
|
|||||||
common::ObBucketHashRLockGuard lock_guard(ResourceMap::bucket_lock_, hash_val);
|
common::ObBucketHashRLockGuard lock_guard(ResourceMap::bucket_lock_, hash_val);
|
||||||
if (OB_FAIL(meta_pointer->read_from_disk(arena_allocator, buf, buf_len, load_addr))) {
|
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));
|
STORAGE_LOG(WARN, "fail to read from disk", K(ret), KPC(meta_pointer));
|
||||||
}
|
} else {
|
||||||
}
|
t->tablet_addr_ = load_addr;
|
||||||
if (OB_SUCC(ret)) {
|
if (OB_FAIL(meta_pointer->deserialize(buf, buf_len, t))) {
|
||||||
t->tablet_addr_ = load_addr;
|
STORAGE_LOG(WARN, "fail to deserialize object", K(ret), K(key), KPC(meta_pointer));
|
||||||
if (OB_FAIL(meta_pointer->deserialize(buf, buf_len, t))) {
|
}
|
||||||
STORAGE_LOG(WARN, "fail to deserialize object", K(ret), K(key), KPC(meta_pointer));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -221,10 +221,12 @@ public:
|
|||||||
|
|
||||||
virtual 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 int64_t schema_version,
|
||||||
|
const share::SCN newest_clog_checkpoint_scn,
|
||||||
const bool for_replay = false)
|
const bool for_replay = false)
|
||||||
{
|
{
|
||||||
UNUSED(clog_checkpoint_scn);
|
UNUSED(clog_checkpoint_scn);
|
||||||
UNUSED(schema_version);
|
UNUSED(schema_version);
|
||||||
|
UNUSED(newest_clog_checkpoint_scn);
|
||||||
UNUSED(for_replay);
|
UNUSED(for_replay);
|
||||||
return OB_NOT_SUPPORTED;
|
return OB_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -82,10 +82,12 @@ void ObLockMemtableMgr::reset()
|
|||||||
|
|
||||||
int ObLockMemtableMgr::create_memtable(const SCN clog_checkpoint_scn,
|
int ObLockMemtableMgr::create_memtable(const SCN clog_checkpoint_scn,
|
||||||
const int64_t schema_version,
|
const int64_t schema_version,
|
||||||
|
const SCN newest_clog_checkpoint_scn,
|
||||||
const bool for_replay)
|
const bool for_replay)
|
||||||
{
|
{
|
||||||
UNUSED(clog_checkpoint_scn);
|
UNUSED(clog_checkpoint_scn);
|
||||||
UNUSED(schema_version);
|
UNUSED(schema_version);
|
||||||
|
UNUSED(newest_clog_checkpoint_scn);
|
||||||
UNUSED(for_replay);
|
UNUSED(for_replay);
|
||||||
|
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
|
|||||||
@ -63,6 +63,7 @@ public:
|
|||||||
|
|
||||||
virtual 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 int64_t schema_version,
|
||||||
|
const share::SCN newest_clog_checkpoint_scn,
|
||||||
const bool for_replay = false) override;
|
const bool for_replay = false) override;
|
||||||
|
|
||||||
DECLARE_VIRTUAL_TO_STRING;
|
DECLARE_VIRTUAL_TO_STRING;
|
||||||
|
|||||||
@ -3474,7 +3474,7 @@ int ObTablet::inner_create_memtable(
|
|||||||
}
|
}
|
||||||
} else if (OB_FAIL(get_memtable_mgr(memtable_mgr))) {
|
} else if (OB_FAIL(get_memtable_mgr(memtable_mgr))) {
|
||||||
LOG_WARN("failed to get memtable mgr", K(ret));
|
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) {
|
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),
|
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));
|
K(clog_checkpoint_scn), K(schema_version), K(for_replay));
|
||||||
|
|||||||
@ -164,6 +164,7 @@ int ObTabletMemtableMgr::reset_storage_recorder()
|
|||||||
// 2. create the new memtable after freezing the old memtable
|
// 2. create the new memtable after freezing the old memtable
|
||||||
int ObTabletMemtableMgr::create_memtable(const SCN clog_checkpoint_scn,
|
int ObTabletMemtableMgr::create_memtable(const SCN clog_checkpoint_scn,
|
||||||
const int64_t schema_version,
|
const int64_t schema_version,
|
||||||
|
const SCN new_clog_checkpoint_scn,
|
||||||
const bool for_replay)
|
const bool for_replay)
|
||||||
{
|
{
|
||||||
ObTimeGuard time_guard("ObTabletMemtableMgr::create_memtable", 10 * 1000);
|
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;
|
memtable::ObMemtable *active_memtable = nullptr;
|
||||||
uint32_t memtable_freeze_clock = UINT32_MAX;
|
uint32_t memtable_freeze_clock = UINT32_MAX;
|
||||||
share::ObLSID ls_id;
|
share::ObLSID ls_id;
|
||||||
SCN new_clog_checkpoint_scn;
|
|
||||||
int64_t memtable_count = get_memtable_count_();
|
int64_t memtable_count = get_memtable_count_();
|
||||||
if (has_memtable && OB_NOT_NULL(active_memtable = get_active_memtable_())) {
|
if (has_memtable && OB_NOT_NULL(active_memtable = get_active_memtable_())) {
|
||||||
memtable_freeze_clock = active_memtable->get_freeze_clock();
|
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_()),
|
K(get_memtable_count_()),
|
||||||
KPC(first_frozen_memtable.get_table()));
|
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) {
|
} else if (for_replay && clog_checkpoint_scn != new_clog_checkpoint_scn) {
|
||||||
ret = OB_EAGAIN;
|
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));
|
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));
|
||||||
|
|||||||
@ -65,9 +65,11 @@ public:
|
|||||||
int get_last_frozen_memtable(ObTableHandleV2 &handle) const;
|
int get_last_frozen_memtable(ObTableHandleV2 &handle) const;
|
||||||
virtual int get_boundary_memtable(ObTableHandleV2 &handle) override;
|
virtual int get_boundary_memtable(ObTableHandleV2 &handle) override;
|
||||||
int release_tail_memtable(memtable::ObIMemtable *memtable);
|
int release_tail_memtable(memtable::ObIMemtable *memtable);
|
||||||
int create_memtable(const share::SCN clog_checkpoint_scn,
|
virtual int create_memtable(
|
||||||
const int64_t schema_version,
|
const share::SCN clog_checkpoint_scn,
|
||||||
const bool for_replay);
|
const int64_t schema_version,
|
||||||
|
const share::SCN newest_clog_checkpoint_scn,
|
||||||
|
const bool for_replay) override;
|
||||||
int get_memtables(
|
int get_memtables(
|
||||||
ObTableHdlArray &handle,
|
ObTableHdlArray &handle,
|
||||||
const bool reset_handle = true,
|
const bool reset_handle = true,
|
||||||
|
|||||||
@ -60,10 +60,12 @@ void ObTxCtxMemtableMgr::reset()
|
|||||||
|
|
||||||
int ObTxCtxMemtableMgr::create_memtable(const SCN last_replay_scn,
|
int ObTxCtxMemtableMgr::create_memtable(const SCN last_replay_scn,
|
||||||
const int64_t schema_version,
|
const int64_t schema_version,
|
||||||
|
const SCN newest_clog_checkpoint_scn,
|
||||||
const bool for_replay)
|
const bool for_replay)
|
||||||
{
|
{
|
||||||
UNUSED(last_replay_scn);
|
UNUSED(last_replay_scn);
|
||||||
UNUSED(schema_version);
|
UNUSED(schema_version);
|
||||||
|
UNUSED(newest_clog_checkpoint_scn);
|
||||||
UNUSED(for_replay);
|
UNUSED(for_replay);
|
||||||
|
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
|
|||||||
@ -59,6 +59,7 @@ public:
|
|||||||
// create_memtable is used for creating the only memtable for CheckpointMgr
|
// create_memtable is used for creating the only memtable for CheckpointMgr
|
||||||
virtual int create_memtable(const share::SCN last_replay_scn,
|
virtual int create_memtable(const share::SCN last_replay_scn,
|
||||||
const int64_t schema_version,
|
const int64_t schema_version,
|
||||||
|
const share::SCN newest_clog_checkpoint_scn,
|
||||||
const bool for_replay=false) override;
|
const bool for_replay=false) override;
|
||||||
|
|
||||||
const ObTxCtxMemtable *get_tx_ctx_memtable_(const int64_t pos) const;
|
const ObTxCtxMemtable *get_tx_ctx_memtable_(const int64_t pos) const;
|
||||||
|
|||||||
@ -132,8 +132,10 @@ int ObTxDataMemtableMgr::release_head_memtable_(memtable::ObIMemtable *imemtable
|
|||||||
|
|
||||||
int ObTxDataMemtableMgr::create_memtable(const SCN clog_checkpoint_scn,
|
int ObTxDataMemtableMgr::create_memtable(const SCN clog_checkpoint_scn,
|
||||||
const int64_t schema_version,
|
const int64_t schema_version,
|
||||||
|
const SCN newest_clog_checkpoint_scn,
|
||||||
const bool for_replay)
|
const bool for_replay)
|
||||||
{
|
{
|
||||||
|
UNUSED(newest_clog_checkpoint_scn);
|
||||||
UNUSED(for_replay);
|
UNUSED(for_replay);
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
if (IS_NOT_INIT) {
|
if (IS_NOT_INIT) {
|
||||||
|
|||||||
@ -120,6 +120,7 @@ public: // ObTxDataMemtableMgr
|
|||||||
*/
|
*/
|
||||||
virtual 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 int64_t schema_version,
|
||||||
|
const share::SCN newest_clog_checkpoint_scn,
|
||||||
const bool for_replay=false) override;
|
const bool for_replay=false) override;
|
||||||
/**
|
/**
|
||||||
* @brief Get the last tx data memtable in memtable list.
|
* @brief Get the last tx data memtable in memtable list.
|
||||||
|
|||||||
@ -175,7 +175,8 @@ TEST_F(TestTxCtxTable, test_tx_ctx_memtable_mgr)
|
|||||||
{
|
{
|
||||||
EXPECT_EQ(0, TestTxCtxTable::ref_count_);
|
EXPECT_EQ(0, TestTxCtxTable::ref_count_);
|
||||||
EXPECT_EQ(OB_SUCCESS, mt_mgr_->create_memtable(SCN::min_scn(), /*last_replay_log_ts*/
|
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_);
|
EXPECT_EQ(1, TestTxCtxTable::ref_count_);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user