From f8d871eaf5cbb9867022f95d2f5b5923d2da4dda Mon Sep 17 00:00:00 2001 From: obdev Date: Mon, 20 Feb 2023 04:47:00 +0000 Subject: [PATCH] fix stanby tenant schedule & consider snapshot_gc when schedule --- src/storage/compaction/ob_medium_compaction_func.cpp | 6 +++--- src/storage/compaction/ob_medium_compaction_mgr.cpp | 6 +++--- src/storage/ob_storage_schema_recorder.cpp | 3 ++- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/storage/compaction/ob_medium_compaction_func.cpp b/src/storage/compaction/ob_medium_compaction_func.cpp index 4db5a24f26..9bf55cfa0b 100644 --- a/src/storage/compaction/ob_medium_compaction_func.cpp +++ b/src/storage/compaction/ob_medium_compaction_func.cpp @@ -332,9 +332,10 @@ int ObMediumCompactionScheduleFunc::decide_medium_snapshot( if (medium_info.medium_snapshot_ == tablet_.get_snapshot_version() // no uncommitted sstable && weak_read_ts.get_val_for_tx() <= max_reserved_snapshot && weak_read_ts.get_val_for_tx() + DEFAULT_SCHEDULE_MEDIUM_INTERVAL < ObTimeUtility::current_time_ns()) { - medium_info.medium_snapshot_ = MAX(max_reserved_snapshot, weak_read_ts.get_val_for_tx()); + const int64_t snapshot_gc_ts = MTL(ObTenantFreezeInfoMgr*)->get_snapshot_gc_ts(); + medium_info.medium_snapshot_ = MAX(max_reserved_snapshot, MIN(weak_read_ts.get_val_for_tx(), snapshot_gc_ts)); LOG_INFO("use weak_read_ts to schedule medium", K(ret), KPC(this), - K(medium_info), K(max_reserved_snapshot), K(weak_read_ts)); + K(medium_info), K(max_reserved_snapshot), K(weak_read_ts), K(snapshot_gc_ts)); } else { ret = OB_NO_NEED_MERGE; } @@ -839,7 +840,6 @@ int ObMediumCompactionScheduleFunc::schedule_tablet_medium_merge( LOG_WARN("failed to get status from inner tablet", K(ret), K(ls_id), K(tablet_id)); } else if (ret_info.could_schedule_next_round(last_major->get_snapshot_version())) { LOG_INFO("success to check RS major checksum validation finished", K(ret), K(ls_id), K(tablet_id)); - } else { schedule_flag = true; } } else { diff --git a/src/storage/compaction/ob_medium_compaction_mgr.cpp b/src/storage/compaction/ob_medium_compaction_mgr.cpp index f22a6be7fc..86622c5607 100644 --- a/src/storage/compaction/ob_medium_compaction_mgr.cpp +++ b/src/storage/compaction/ob_medium_compaction_mgr.cpp @@ -164,7 +164,7 @@ int ObTabletMediumCompactionInfoRecorder::inner_replay_clog( ObMediumCompactionInfo replay_medium_info; ObTabletHandle tmp_tablet_handle; if (OB_FAIL(replay_get_tablet_handle(ls_id_, tablet_id_, scn, tmp_tablet_handle))) { - LOG_WARN("failed to get tablet handle", K(ret), K_(tablet_id), K(scn)); + LOG_WARN("failed to get tablet handle", K(ret), K_(ls_id), K_(tablet_id), K(scn)); } else if (OB_FAIL(replay_medium_info.deserialize(tmp_allocator, buf, size, pos))) { LOG_WARN("failed to deserialize medium compaction info", K(ret)); } else if (!replay_medium_info.from_cur_cluster() @@ -176,7 +176,7 @@ int ObTabletMediumCompactionInfoRecorder::inner_replay_clog( LOG_WARN("failed to save medium info", K(ret), K_(tablet_id), K(replay_medium_info)); } else { tmp_tablet_handle.reset(); - FLOG_INFO("success to save medium info", K(ret), K_(tablet_id), K(replay_medium_info), K(max_saved_version_)); + FLOG_INFO("success to save medium info", K(ret), K_(ls_id), K_(tablet_id), K(replay_medium_info), K(max_saved_version_)); } return ret; } @@ -193,7 +193,7 @@ int ObTabletMediumCompactionInfoRecorder::sync_clog_succ_for_leader(const int64_ } else if (OB_FAIL(dec_ref_on_memtable(true/*sync_finish*/))) { LOG_WARN("failed to dec ref on memtable", K(ret), K_(tablet_id), KPC(medium_info_)); } else { - FLOG_INFO("success to save medium info", K(ret), K_(tablet_id), KPC(medium_info_), + FLOG_INFO("success to save medium info", K(ret), K_(ls_id), K_(tablet_id), KPC(medium_info_), K(max_saved_version_), K_(clog_scn)); } return ret; diff --git a/src/storage/ob_storage_schema_recorder.cpp b/src/storage/ob_storage_schema_recorder.cpp index 0c0617d130..0b781e84f5 100644 --- a/src/storage/ob_storage_schema_recorder.cpp +++ b/src/storage/ob_storage_schema_recorder.cpp @@ -153,7 +153,8 @@ int ObStorageSchemaRecorder::inner_replay_clog( true/*for_replay*/, memtable::MemtableRefOp::NONE))) { LOG_WARN("failed to save storage schema", K(ret), K_(tablet_id), K(replay_storage_schema)); } else { - LOG_INFO("success to replay schema clog", K(ret), K(replay_storage_schema.get_schema_version()), K(replay_storage_schema.compat_mode_)); + LOG_INFO("success to replay schema clog", K(ret), K_(ls_id), K_(tablet_id), + K(replay_storage_schema.get_schema_version()), K(replay_storage_schema.compat_mode_)); } replay_storage_schema.reset(); tmp_tablet_handle.reset();