Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

fix: fix the bug in restore #459

Merged
merged 5 commits into from
May 13, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 11 additions & 14 deletions src/dist/replication/lib/replica_restore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ dsn::error_code replica::download_checkpoint(const configuration_restore_request
derror("%s: checkpoint is damaged, chkpt = %s", name(), local_chkpt_dir.c_str());
// if checkpoint is damaged, using corruption to represent it
err = ERR_CORRUPTION;
_restore_status = ERR_CORRUPTION;
} else {
ddebug("%s: checkpoint is valid, chkpt = %s", name(), local_chkpt_dir.c_str());
// checkpoint is valid, we should delete the backup_metadata under checkpoint
Expand Down Expand Up @@ -444,27 +445,23 @@ dsn::error_code replica::restore_checkpoint()

if (err == dsn::ERR_OK) {
err = download_checkpoint(restore_req, remote_chkpt_dir, restore_dir);
if (err != ERR_OK) {
if (_restore_status == ERR_CORRUPTION) {
if (skip_bad_partition) {
err = skip_restore_partition(restore_dir);
} else {
tell_meta_to_restore_rollback();
return ERR_CORRUPTION;
}
}
}
} else { // find valid checkpoint failed
if (err == ERR_OBJECT_NOT_FOUND) {
if (_restore_status == ERR_CORRUPTION) {
if (skip_bad_partition) {
err = skip_restore_partition(restore_dir);
} else {
// current_checkpoint doesn't exist, we think partition is damaged
tell_meta_to_restore_rollback();
_restore_status = ERR_CORRUPTION;
return ERR_CORRUPTION;
}
}
} else if (err == ERR_OBJECT_NOT_FOUND) { // find valid checkpoint failed
if (skip_bad_partition) {
err = skip_restore_partition(restore_dir);
} else {
// current_checkpoint doesn't exist, we think partition is damaged
tell_meta_to_restore_rollback();
_restore_status = ERR_CORRUPTION;
return ERR_CORRUPTION;
}
}
report_restore_status_to_meta();
return err;
Expand Down