adjust the start replay scn when backup start at the first archive piece
This commit is contained in:
@ -1585,16 +1585,31 @@ int ObBackupSetTaskMgr::calculate_start_replay_scn_(SCN &start_replay_scn)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObBackupLSMetaInfosDesc ls_meta_infos;
|
||||
SCN tmp_start_replay_scn = set_task_attr_.start_scn_;
|
||||
if (OB_FAIL(store_.read_ls_meta_infos(ls_meta_infos))) {
|
||||
ObTenantArchiveRoundAttr round_attr;
|
||||
if (OB_FAIL(ObTenantArchiveMgr::get_tenant_current_round(job_attr_->tenant_id_, job_attr_->incarnation_id_, round_attr))) {
|
||||
LOG_WARN("failed to get tenant current round", K(ret), KPC(job_attr_));
|
||||
} else if (!round_attr.state_.is_doing()) {
|
||||
ret = OB_LOG_ARCHIVE_NOT_RUNNING;
|
||||
LOG_WARN("backup is not supported when log archive is not doing", K(ret), K(round_attr));
|
||||
} else if (round_attr.start_scn_ > set_task_attr_.start_scn_) {
|
||||
ret = OB_LOG_ARCHIVE_INTERRUPTED;
|
||||
LOG_WARN("backup is not supported when archive is interrupted", K(ret), K(round_attr), K(set_task_attr_.start_scn_));
|
||||
} else if (OB_FAIL(store_.read_ls_meta_infos(ls_meta_infos))) {
|
||||
LOG_WARN("fail to read ls meta infos", K(ret));
|
||||
} else {
|
||||
// To ensure that restore can be successfully initiated,
|
||||
// we need to avoid clearing too many logs and the start_replay_scn less than the start_scn of the first piece.
|
||||
// so we choose the minimum palf_base_info.prev_log_info_.scn firstly, to ensure keep enough logs.
|
||||
// Then we choose the max(minimum palf_base_info.prev_log_info_.scn, round_attr.start_scn) as the start_replay_scn,
|
||||
// to ensure the start_replay_scn is greater than the start scn of first piece
|
||||
SCN tmp_start_replay_scn = set_task_attr_.start_scn_;
|
||||
ARRAY_FOREACH_X(ls_meta_infos.ls_meta_packages_, i, cnt, OB_SUCC(ret)) {
|
||||
const palf::PalfBaseInfo &palf_base_info = ls_meta_infos.ls_meta_packages_.at(i).palf_meta_;
|
||||
tmp_start_replay_scn = SCN::min(tmp_start_replay_scn, palf_base_info.prev_log_info_.scn_);
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
start_replay_scn = tmp_start_replay_scn;
|
||||
start_replay_scn = SCN::max(tmp_start_replay_scn, round_attr.start_scn_);
|
||||
LOG_INFO("calculate start replay scn finish", K(start_replay_scn), K(ls_meta_infos), K(round_attr));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
@ -1237,22 +1237,27 @@ int ObArchiveStore::get_piece_paths_in_range(const SCN &start_scn, const SCN &en
|
||||
|
||||
if (pieces.empty()) {
|
||||
// this piece can be used to restore.
|
||||
if (OB_FAIL(ObArchivePathUtil::get_piece_dir_path(dest, cur.key_.dest_id_, cur.key_.round_id_, cur.key_.piece_id_, piece_path))) {
|
||||
LOG_WARN("failed to get piece path", K(ret), K(dest), K(cur));
|
||||
} else if (OB_FAIL(pieces.push_back(piece_path))) {
|
||||
LOG_WARN("fail to push back path", K(ret), K(piece_path));
|
||||
if (cur.start_scn_ <= start_scn) {
|
||||
if (OB_FAIL(ObArchivePathUtil::get_piece_dir_path(dest, cur.key_.dest_id_, cur.key_.round_id_, cur.key_.piece_id_, piece_path))) {
|
||||
LOG_WARN("failed to get piece path", K(ret), K(dest), K(cur));
|
||||
} else if (OB_FAIL(pieces.push_back(piece_path))) {
|
||||
LOG_WARN("fail to push back path", K(ret), K(piece_path));
|
||||
} else {
|
||||
last_piece_idx = i;
|
||||
}
|
||||
} else {
|
||||
last_piece_idx = i;
|
||||
ret = OB_ENTRY_NOT_EXIST;
|
||||
LOG_WARN("first piece start_scn is bigger than start_scn", K(ret), K(cur), K(start_scn), K(end_scn));
|
||||
LOG_USER_ERROR(OB_ENTRY_NOT_EXIST, "No enough log for restore");
|
||||
}
|
||||
} else {
|
||||
const ObTenantArchivePieceAttr &prev = piece_whole_info.his_frozen_pieces_.at(last_piece_idx);
|
||||
if (prev.checkpoint_scn_ != cur.start_scn_) {
|
||||
// piece not continous
|
||||
pieces.reset();
|
||||
ret = OB_ENTRY_NOT_EXIST;
|
||||
LOG_WARN("pieces are not continous", K(ret), K(prev), K(cur), K(start_scn), K(end_scn));
|
||||
}
|
||||
|
||||
if (OB_FAIL(ObArchivePathUtil::get_piece_dir_path(dest, cur.key_.dest_id_, cur.key_.round_id_, cur.key_.piece_id_, piece_path))) {
|
||||
LOG_USER_ERROR(OB_ENTRY_NOT_EXIST, "No enough log for restore");
|
||||
} else if (OB_FAIL(ObArchivePathUtil::get_piece_dir_path(dest, cur.key_.dest_id_, cur.key_.round_id_, cur.key_.piece_id_, piece_path))) {
|
||||
LOG_WARN("failed to get piece path", K(ret), K(dest), K(cur));
|
||||
} else if (OB_FAIL(pieces.push_back(piece_path))) {
|
||||
LOG_WARN("fail to push back path", K(ret), K(piece_path));
|
||||
|
Reference in New Issue
Block a user