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

Commit

Permalink
fix: fix the bug in restore (#459)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhao liwei authored May 13, 2020
1 parent c0ee1f6 commit 704e1f0
Showing 1 changed file with 11 additions and 14 deletions.
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

0 comments on commit 704e1f0

Please sign in to comment.