[BUG.FIX] fix unable to read newest memtable in follower
This commit is contained in:
parent
3ef61117ef
commit
8ad8629476
@ -259,7 +259,7 @@ public:
|
||||
|
||||
virtual int get_boundary_memtable(ObTableHandleV2 &handle) { return OB_NOT_SUPPORTED; }
|
||||
|
||||
virtual int get_memtable_for_replay(share::SCN replay_scn, ObTableHandleV2 &handle)
|
||||
virtual int get_memtable_for_replay(const share::SCN &replay_scn, ObTableHandleV2 &handle)
|
||||
{
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ int ObStorageTableGuard::refresh_and_protect_memtable()
|
||||
int64_t warn_interval = DEFAULT_REFRESH_WARN_INTERVAL;
|
||||
|
||||
do {
|
||||
if (OB_FAIL(tablet_->get_boundary_memtable(handle))) {
|
||||
if (OB_FAIL(tablet_->get_boundary_memtable_from_memtable_mgr(handle))) {
|
||||
// if there is no memtable, create a new one
|
||||
if (OB_ENTRY_NOT_EXIST == ret) {
|
||||
ret = create_data_memtable_(ls_id, tablet_id, need_retry);
|
||||
|
@ -4282,29 +4282,31 @@ int ObTablet::create_memtable(
|
||||
LOG_WARN("failed to create memtable", K(ret), K(clog_checkpoint_scn),
|
||||
K(schema_version), K(for_replay));
|
||||
}
|
||||
} else if (FALSE_IT(time_guard.click("inner_create_memtable"))) {
|
||||
} else if (OB_FAIL(update_memtables())) {
|
||||
LOG_WARN("failed to append new memtable to table store", K(ret), KPC(this));
|
||||
if (OB_SIZE_OVERFLOW == ret) {
|
||||
// rewrite errno to OB_EAGAIN when memtable count overflow, in case to stuck the log relpay engine
|
||||
ret = OB_EAGAIN;
|
||||
}
|
||||
} else if (FALSE_IT(time_guard.click("update_memtables"))) {
|
||||
} else {
|
||||
tablet_addr_.inc_seq();
|
||||
table_store_addr_.addr_.inc_seq();
|
||||
|
||||
if (table_store_addr_.is_memory_object()) {
|
||||
ObSEArray<ObITable *, MAX_MEMSTORE_CNT> memtable_array;
|
||||
if (OB_FAIL(inner_get_memtables(memtable_array, true/*need_active*/))) {
|
||||
LOG_WARN("inner get memtables fail", K(ret), K(*this));
|
||||
} else if (OB_FAIL(table_store_addr_.get_ptr()->update_memtables(memtable_array))) {
|
||||
LOG_WARN("table store update memtables fail", K(ret), K(memtable_array));
|
||||
time_guard.click("inner_create_memtable");
|
||||
do {
|
||||
if (OB_FAIL(update_memtables())) {
|
||||
LOG_WARN("failed to append new memtable to table store", K(ret), KPC(this));
|
||||
} else if (FALSE_IT(time_guard.click("update_memtables"))) {
|
||||
} else {
|
||||
time_guard.click("ts update mem");
|
||||
LOG_INFO("table store update memtable success", K(ret), K(ls_id), K(tablet_id), K_(table_store_addr), KP(this));
|
||||
tablet_addr_.inc_seq();
|
||||
table_store_addr_.addr_.inc_seq();
|
||||
if (table_store_addr_.is_memory_object()) {
|
||||
ObSEArray<ObITable *, MAX_MEMSTORE_CNT> memtable_array;
|
||||
if (OB_FAIL(inner_get_memtables(memtable_array, true/*need_active*/))) {
|
||||
LOG_WARN("inner get memtables fail", K(ret), K(*this));
|
||||
} else if (OB_FAIL(table_store_addr_.get_ptr()->update_memtables(memtable_array))) {
|
||||
LOG_WARN("table store update memtables fail", K(ret), K(memtable_array));
|
||||
} else {
|
||||
time_guard.click("ts update mem");
|
||||
LOG_INFO("table store update memtable success", K(ret), K(ls_id), K(tablet_id), K_(table_store_addr), KP(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (OB_FAIL(ret) && REACH_COUNT_INTERVAL(100)) {
|
||||
LOG_ERROR("fail to refresh tablet memtables, which may cause hang", K(ret), KPC(this));
|
||||
}
|
||||
} while(OB_FAIL(ret));
|
||||
}
|
||||
|
||||
STORAGE_LOG(DEBUG,
|
||||
@ -7359,7 +7361,7 @@ int ObTablet::get_all_memtables(ObTableHdlArray &handle) const
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTablet::get_boundary_memtable(ObTableHandleV2 &handle) const
|
||||
int ObTablet::get_boundary_memtable_from_memtable_mgr(ObTableHandleV2 &handle) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObProtectedMemtableMgrHandle *protected_handle = NULL;
|
||||
|
@ -347,8 +347,10 @@ public:
|
||||
int update_upper_trans_version(ObLS &ls, bool &is_updated);
|
||||
|
||||
// memtable operation
|
||||
// ATTENTION!!!
|
||||
// - The `get_all_memtables()` is that get all memtables from memtable mgr, not from this tablet.
|
||||
int get_all_memtables(ObTableHdlArray &handle) const;
|
||||
int get_boundary_memtable(ObTableHandleV2 &handle) const;
|
||||
int get_boundary_memtable_from_memtable_mgr(ObTableHandleV2 &handle) const;
|
||||
int get_protected_memtable_mgr_handle(ObProtectedMemtableMgrHandle *&handle) const;
|
||||
|
||||
// get the active memtable for write or replay.
|
||||
|
@ -663,7 +663,7 @@ int ObTabletMemtableMgr::set_is_tablet_freeze_for_active_memtable(
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTabletMemtableMgr::get_memtable_for_replay(SCN replay_scn, ObTableHandleV2 &handle)
|
||||
int ObTabletMemtableMgr::get_memtable_for_replay(const SCN &replay_scn, ObTableHandleV2 &handle)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObITabletMemtable *tablet_memtable = nullptr;
|
||||
|
@ -67,7 +67,7 @@ public: // derived from ObIMemtableMgr
|
||||
virtual int get_active_memtable(ObTableHandleV2 &handle) const override;
|
||||
virtual int get_all_memtables(ObTableHdlArray &handle) override;
|
||||
virtual void destroy() override;
|
||||
virtual int get_memtable_for_replay(share::SCN replay_scn,
|
||||
virtual int get_memtable_for_replay(const share::SCN &replay_scn,
|
||||
ObTableHandleV2 &handle) override;
|
||||
virtual int get_boundary_memtable(ObTableHandleV2 &handle) override;
|
||||
virtual int create_memtable(const CreateMemtableArg &arg) override;
|
||||
|
Loading…
x
Reference in New Issue
Block a user