From 2b9de5aa051c713ecf44c96abacd147ce49b9a4b Mon Sep 17 00:00:00 2001 From: zhaoliwei Date: Tue, 12 May 2020 15:45:44 +0800 Subject: [PATCH 1/2] fix bug --- src/dist/replication/lib/replica_restore.cpp | 25 +++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/dist/replication/lib/replica_restore.cpp b/src/dist/replication/lib/replica_restore.cpp index 1255167293..bcc9566690 100644 --- a/src/dist/replication/lib/replica_restore.cpp +++ b/src/dist/replication/lib/replica_restore.cpp @@ -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 @@ -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 (err != ERR_OK && _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; From e5decef568763e61f7df341030950d8c7311f83d Mon Sep 17 00:00:00 2001 From: zhaoliwei Date: Wed, 13 May 2020 10:09:53 +0800 Subject: [PATCH 2/2] fix --- src/dist/replication/lib/replica_restore.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dist/replication/lib/replica_restore.cpp b/src/dist/replication/lib/replica_restore.cpp index bcc9566690..36ebe7c6d4 100644 --- a/src/dist/replication/lib/replica_restore.cpp +++ b/src/dist/replication/lib/replica_restore.cpp @@ -445,7 +445,7 @@ 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 && _restore_status == ERR_CORRUPTION) { + if (_restore_status == ERR_CORRUPTION) { if (skip_bad_partition) { err = skip_restore_partition(restore_dir); } else {