From 283a205f6c50a86fc75a298e4957d4891a545c0c Mon Sep 17 00:00:00 2001 From: obdev Date: Thu, 1 Dec 2022 12:08:01 +0000 Subject: [PATCH] Cherry-pick 'Skip ready_for_flush if migration_clog_checkpoint >= end_log_ts' --- src/storage/memtable/ob_memtable.cpp | 7 +++++++ src/storage/memtable/ob_multi_source_data.cpp | 15 +++++++++++++++ src/storage/memtable/ob_multi_source_data.h | 1 + 3 files changed, 23 insertions(+) diff --git a/src/storage/memtable/ob_memtable.cpp b/src/storage/memtable/ob_memtable.cpp index 256d61139..1eea602ef 100644 --- a/src/storage/memtable/ob_memtable.cpp +++ b/src/storage/memtable/ob_memtable.cpp @@ -1647,6 +1647,13 @@ bool ObMemtable::ready_for_flush_() int ret = OB_SUCCESS; SCN current_right_boundary = ObScnRange::MIN_SCN; share::ObLSID ls_id = freezer_->get_ls_id(); + const SCN migration_clog_checkpoint_scn = get_migration_clog_checkpoint_scn(); + if (!migration_clog_checkpoint_scn.is_min() && + migration_clog_checkpoint_scn >= get_end_scn() && + 0 != get_unsynced_cnt() && + multi_source_data_.get_all_unsync_cnt_for_multi_data() == get_unsynced_cnt()) { + bool_ret = true; + } if (bool_ret) { if (OB_FAIL(resolve_snapshot_version_())) { TRANS_LOG(WARN, "fail to resolve snapshot version", K(ret), KPC(this), K(ls_id)); diff --git a/src/storage/memtable/ob_multi_source_data.cpp b/src/storage/memtable/ob_multi_source_data.cpp index 68b538a1e..a31c48dc4 100644 --- a/src/storage/memtable/ob_multi_source_data.cpp +++ b/src/storage/memtable/ob_multi_source_data.cpp @@ -223,5 +223,20 @@ int ObMultiSourceData::get_unsync_cnt_for_multi_data(const MultiSourceDataUnitTy return ret; } +int64_t ObMultiSourceData::get_all_unsync_cnt_for_multi_data() +{ + int ret = OB_SUCCESS; + int64_t unsynced_cnt_for_multi_data = 0; + + for (int i = 0; i < MAX_PTR_COUNT; ++i) { + ObIMultiSourceDataUnit *value = units_[i]; + if (nullptr != value && value->is_valid()) { + int64_t cnt = value->get_unsync_cnt_for_multi_data(); + unsynced_cnt_for_multi_data += cnt; + } + } + + return unsynced_cnt_for_multi_data; +} } // namespace memtable } // namespace oceanbase diff --git a/src/storage/memtable/ob_multi_source_data.h b/src/storage/memtable/ob_multi_source_data.h index c3700b3f6..0365cf03b 100644 --- a/src/storage/memtable/ob_multi_source_data.h +++ b/src/storage/memtable/ob_multi_source_data.h @@ -128,6 +128,7 @@ public: int save_multi_source_data_unit(const T *const src, bool is_callback); int update_unsync_cnt_for_multi_data(const MultiSourceDataUnitType multi_source_type, const bool is_inc); int get_unsync_cnt_for_multi_data(const MultiSourceDataUnitType multi_source_type, int &unsynced_cnt_for_multi_data); + int64_t get_all_unsync_cnt_for_multi_data(); private: int inner_mark_unit_sync_finish( const int64_t unit_type, -- GitLab