From 04e378d7e44f5103f6d27a2bff0e0fa6dca0cd52 Mon Sep 17 00:00:00 2001 From: obdev Date: Wed, 26 Oct 2022 11:49:44 +0000 Subject: [PATCH] [FIX] Incorrect defensive when set filled_tx_log_ts --- .../compaction/ob_tablet_merge_ctx.cpp | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/storage/compaction/ob_tablet_merge_ctx.cpp b/src/storage/compaction/ob_tablet_merge_ctx.cpp index 3dae5e260a..c760521115 100644 --- a/src/storage/compaction/ob_tablet_merge_ctx.cpp +++ b/src/storage/compaction/ob_tablet_merge_ctx.cpp @@ -265,28 +265,26 @@ int ObTabletMergeInfo::record_start_tx_scn_for_tx_data(const ObTabletMergeCtx &c param.filled_tx_log_ts_ = tx_data_memtable->get_start_log_ts(); } } else if (ctx.param_.is_minor_merge()) { - // when this merege is MINOR_MERGE or MINI_MINOR_MERGE, use max_filtered_end_scn in filter if filtered some tx data ObTransStatusFilter *compaction_filter_ = (ObTransStatusFilter*)ctx.compaction_filter_; ObSSTable *oldest_tx_data_sstable = static_cast(ctx.tables_handle_.get_table(0)); if (OB_ISNULL(oldest_tx_data_sstable)) { ret = OB_ERR_UNEXPECTED; LOG_ERROR("tx data sstable is unexpected nullptr", KR(ret)); - } else if (OB_ISNULL(compaction_filter_)) { - // This minor merge do not filter any tx data - param.filled_tx_log_ts_ = oldest_tx_data_sstable->get_filled_tx_scn(); - } else if (compaction_filter_->get_max_filtered_end_scn() > 0) { - param.filled_tx_log_ts_ = compaction_filter_->get_max_filtered_end_scn(); } else { - param.filled_tx_log_ts_ = compaction_filter_->get_recycle_scn(); - } + param.filled_tx_log_ts_ = oldest_tx_data_sstable->get_filled_tx_scn(); - if (OB_SUCC(ret) && param.filled_tx_log_ts_ < oldest_tx_data_sstable->get_filled_tx_scn()) { - ret = OB_ERR_UNEXPECTED; - LOG_ERROR("invliad filled tx log ts", - KR(ret), - K(param), - K(oldest_tx_data_sstable->get_filled_tx_scn()), - KPC(oldest_tx_data_sstable)); + if (OB_NOT_NULL(compaction_filter_)) { + // if compaction_filter is valid, update filled_tx_log_ts if recycled some tx data + int64_t recycled_ts = 1; + if (compaction_filter_->get_max_filtered_end_scn() > 0) { + recycled_ts = compaction_filter_->get_max_filtered_end_scn(); + } else { + recycled_ts = compaction_filter_->get_recycle_scn(); + } + if (recycled_ts > param.filled_tx_log_ts_) { + param.filled_tx_log_ts_ = recycled_ts; + } + } } } else { ret = OB_ERR_UNEXPECTED; -- GitLab