[CP] Fix physical restore finish can not get latest data bug
This commit is contained in:
committed by
wangzelin.wzl
parent
a8f575409d
commit
3a4eeb579b
@ -954,6 +954,34 @@ int ObBackupInfoMgr::get_base_data_restore_schema_version(const uint64_t tenant_
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObBackupInfoMgr::get_restore_backup_snapshot_version(const uint64_t tenant_id, int64_t &snapshot_version)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObSimplePhysicalRestoreJob simple_job_info;
|
||||
snapshot_version = 0;
|
||||
|
||||
if (!is_inited_) {
|
||||
ret = OB_NOT_INIT;
|
||||
LOG_WARN("not inited", K(ret));
|
||||
} else if (OB_FAIL(get_restore_info_from_cache(tenant_id, simple_job_info))) {
|
||||
if (OB_ENTRY_NOT_EXIST != ret) {
|
||||
LOG_WARN("failed to get_restore_info_from_cache", K(ret), K(tenant_id));
|
||||
} else if (OB_FAIL(reload())) {
|
||||
LOG_WARN("failed to reload", K(ret));
|
||||
} else if (OB_FAIL(get_restore_info_from_cache(tenant_id, simple_job_info))) {
|
||||
LOG_WARN("failed to get restore info from cache again", K(ret), K(tenant_id));
|
||||
}
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
snapshot_version = simple_job_info.snapshot_version_;
|
||||
if (REACH_TIME_INTERVAL(OB_DEFAULT_BACKUP_LOG_INTERVAL)) {
|
||||
FLOG_INFO("get_restore_info", K(ret), K(tenant_id), K(simple_job_info));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
ObRestoreBackupInfoUtil::GetRestoreBackupInfoParam::GetRestoreBackupInfoParam()
|
||||
: backup_dest_(nullptr),
|
||||
backup_cluster_name_(nullptr),
|
||||
|
||||
@ -102,6 +102,7 @@ public:
|
||||
static int fetch_sys_log_archive_backup_info_and_piece(common::ObMySQLProxy &sql_proxy,
|
||||
ObLogArchiveBackupInfo &new_backup_info, ObNonFrozenBackupPieceInfo &new_backup_piece);
|
||||
int64_t get_log_archive_checkpoint_interval() const;
|
||||
int get_restore_backup_snapshot_version(const uint64_t tenant_id, int64_t &snapshot_version);
|
||||
|
||||
private:
|
||||
static const int64_t DEFAULT_UPDATE_INTERVAL_US = 10 * 1000 * 1000; // 10s
|
||||
|
||||
@ -14180,10 +14180,38 @@ int ObRestoreTailoredFinishTask::process()
|
||||
LOG_WARN("failed to get all saved info", K(ret));
|
||||
} else {
|
||||
ObDataStorageInfo &storage_info = save_info.get_data_info();
|
||||
ObBaseStorageInfo &clog_info = save_info.get_clog_info();
|
||||
const int64_t publish_version = std::min(storage_info.get_publish_version(), restore_snapshot_version);
|
||||
storage_info.set_publish_version(publish_version);
|
||||
storage_info.set_schema_version(schema_version_);
|
||||
if (OB_FAIL(partition_group->set_storage_info(save_info))) {
|
||||
int16_t restore_flag = REPLICA_NOT_RESTORE;
|
||||
restore_flag = partition_group->get_pg_storage().get_restore_state();
|
||||
const int64_t clog_info_log_id = clog_info.get_last_replay_log_id();
|
||||
const int64_t data_info_log_id = storage_info.get_last_replay_log_id();
|
||||
|
||||
if (REPLICA_RESTORE_CUT_DATA == restore_flag) {
|
||||
int64_t backup_snapshot_version = 0;
|
||||
bool is_snapshot_restore = false;
|
||||
if (OB_FAIL(ObBackupInfoMgr::get_instance().get_restore_backup_snapshot_version(
|
||||
pg_key.get_tenant_id(), backup_snapshot_version))) {
|
||||
LOG_WARN("failed to get backup snapshot version", K(ret));
|
||||
} else if (OB_FAIL(ObRestoreBackupInfoUtil::check_is_snapshot_restore(backup_snapshot_version,
|
||||
ctx_->replica_op_arg_.phy_restore_arg_.restore_info_.restore_snapshot_version_,
|
||||
ctx_->replica_op_arg_.phy_restore_arg_.restore_info_.cluster_version_,
|
||||
is_snapshot_restore))) {
|
||||
LOG_WARN("failed to check is snapshot restore", K(ret), KPC(ctx_));
|
||||
} else if (is_snapshot_restore && clog_info_log_id < data_info_log_id) {
|
||||
clog_info.set_last_replay_log_id(data_info_log_id);
|
||||
FLOG_INFO("push clog info log id",
|
||||
"orginal clog info log id",
|
||||
clog_info_log_id,
|
||||
"data info log id",
|
||||
data_info_log_id);
|
||||
}
|
||||
}
|
||||
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (OB_FAIL(partition_group->set_storage_info(save_info))) {
|
||||
LOG_WARN("failed to set storage info", K(ret), K(save_info));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user