[CP] fix bug about update memtables in table store

This commit is contained in:
Fengjingkun
2023-05-29 04:11:49 +00:00
committed by ob-robot
parent 9211f9025b
commit 2acfa1137c
3 changed files with 13 additions and 6 deletions

View File

@ -584,7 +584,9 @@ int ObMemtableArray::build(
return ret;
}
int ObMemtableArray::rebuild(common::ObIArray<ObTableHandleV2> &handle_array)
int ObMemtableArray::rebuild(
const share::SCN &clog_checkpoint_scn,
common::ObIArray<ObTableHandleV2> &handle_array)
{
int ret = OB_SUCCESS;
@ -593,7 +595,9 @@ int ObMemtableArray::rebuild(common::ObIArray<ObTableHandleV2> &handle_array)
LOG_ERROR("ObMemtableArray not inited", K(ret), KPC(this), K(handle_array));
} else {
ObITable *last_memtable = get_table(count() - 1);
SCN end_scn = (NULL == last_memtable) ? SCN::min_scn() : last_memtable->get_end_scn();
SCN last_memtable_end_scn = (NULL == last_memtable)
? clog_checkpoint_scn // memtable was filtered when tablet was initialized, use ckpt scn to filter again
: last_memtable->get_end_scn();
for (int64_t i = 0; OB_SUCC(ret) && i < handle_array.count(); ++i) {
memtable::ObMemtable *memtable = nullptr;
@ -604,8 +608,11 @@ int ObMemtableArray::rebuild(common::ObIArray<ObTableHandleV2> &handle_array)
} else if (FALSE_IT(memtable = reinterpret_cast<memtable::ObMemtable *>(table))) {
} else if (memtable->is_empty()) {
FLOG_INFO("Empty memtable discarded", KPC(memtable));
} else if (table->get_end_scn() < end_scn) {
} else if (table->get_end_scn() == end_scn && table == last_memtable) { //fix issue 41996395
} else if (memtable->get_end_scn() == last_memtable_end_scn && memtable == last_memtable) {
// fix issue 41996395
// if last memtable is freezing, its end scn may still be INT64_MAX, which will cause the new active memtable to be filtered.
continue;
} else if (memtable->get_end_scn() <= last_memtable_end_scn) {
} else if (OB_FAIL(add_table(table))) {
LOG_WARN("failed to add memtable to curr memtables", K(ret), KPC(this));
}

View File

@ -111,7 +111,7 @@ public:
int init(common::ObIAllocator *allocator);
int init(common::ObIAllocator *allocator, const ObMemtableArray &other);
int build(common::ObIArray<ObTableHandleV2> &handle_array, const int64_t start_pos = 0);
int rebuild(common::ObIArray<ObTableHandleV2> &handle_array);
int rebuild(const share::SCN &clog_checkpoint_scn, common::ObIArray<ObTableHandleV2> &handle_array);
int prepare_allocate();
int find(const ObITable::TableKey &table_key, ObTableHandleV2 &handle) const;
int find(const share::SCN &start_scn, const int64_t base_version, ObITable *&table, int64_t &mem_pos) const;

View File

@ -440,7 +440,7 @@ int ObTabletTableStore::update_memtables()
} else if (OB_FAIL(tablet_ptr_->get_memtable_mgr()->get_all_memtables(inc_memtables))) {
LOG_WARN("failed to get all memtables from memtable_mgr", K(ret));
} else if (FALSE_IT(time_guard.click("get_all_memtable"))) {
} else if (OB_FAIL(memtables_.rebuild(inc_memtables))) {
} else if (OB_FAIL(memtables_.rebuild(tablet_ptr_->get_clog_checkpoint_scn(), inc_memtables))) {
LOG_ERROR("failed to rebuild table store memtables", K(ret), K(inc_memtables), KPC(this));
} else if (FALSE_IT(time_guard.click("memtables_.rebuild"))) {
} else {