[BUG.FIX] fix duplicated memtable in tablet memtable array

This commit is contained in:
Tyshawn 2024-10-12 03:55:30 +00:00 committed by ob-robot
parent e52676a128
commit fb6e80f1f6
3 changed files with 11 additions and 5 deletions

View File

@ -163,8 +163,8 @@ public:
OB_INLINE bool is_true_major_sstable() const { return is_row_store_major_sstable() || is_column_store_major_sstable(); }
OB_INLINE const common::ObTabletID &get_tablet_id() const { return tablet_id_; }
share::SCN get_start_scn() const { return scn_range_.start_scn_; }
share::SCN get_end_scn() const { return scn_range_.end_scn_; }
share::SCN get_start_scn() const { return scn_range_.start_scn_.atomic_get(); }
share::SCN get_end_scn() const { return scn_range_.end_scn_.atomic_get(); }
OB_INLINE int64_t get_snapshot_version() const
{
return version_range_.snapshot_version_;

View File

@ -1072,7 +1072,10 @@ bool ObMemtableArray::exist_memtable_with_end_scn(const ObITable *table, const S
// we need to make sure duplicate memtable was not added to tablet,
// and ensure active memtable could be added to tablet
bool is_exist = false;
if (table->get_end_scn() == end_scn && count_ >= 1) {
if (0 >= count_) {
} else if (table->get_end_scn() == end_scn || end_scn.is_max()) {
// Pay Attention!!!
// The end scn of memtable can only be max or a certain value.
for (int64_t i = count_ - 1; i >= 0 ; --i) {
const ObITable *memtable = memtable_array_[i];
if (memtable == table) {
@ -1439,4 +1442,4 @@ int ObTableStoreUtil::check_has_backup_macro_block(const ObITable *table, bool &
}
}
return ret;
}
}

View File

@ -7498,7 +7498,10 @@ bool ObTablet::exist_memtable_with_end_scn(const ObITable *table, const SCN &end
// we need to make sure duplicate memtable was not added to tablet,
// and ensure active memtable could be added to tablet
bool is_exist = false;
if (table->get_end_scn() == end_scn && memtable_count_ >= 1) {
if (0 >= memtable_count_) {
} else if (table->get_end_scn() == end_scn || end_scn.is_max()) {
// Pay Attention!!!
// The end scn of memtable can only be max or a certain value.
for (int64_t i = memtable_count_ - 1; i >= 0 ; --i) {
const ObIMemtable *memtable = memtables_[i];
if (memtable == table) {