Fix 2277 backup 320 restore backup snapshot failed bug

This commit is contained in:
godyangfight 2022-03-03 14:46:14 +08:00 committed by LINxiansheng
parent 9eeefd68f5
commit 47044f346e
5 changed files with 55 additions and 36 deletions

View File

@ -469,6 +469,10 @@ int ObRestoreScheduler::fill_backup_info(ObPhysicalRestoreJob &job, ObCreateTena
// fill restore_pkeys/restore_log_pkeys
if (OB_FAIL(arg.restore_pkeys_.assign(backup_info.sys_pg_key_list_))) {
LOG_WARN("fail to assign pkeys", KR(ret), K(job));
} else if (backup_info.snapshot_version_ == param.restore_timestamp_ &&
backup_info.physical_restore_info_.cluster_version_ > CLUSTER_VERSION_3000) {
LOG_INFO("backup snapshot equal to restore timestamp, no need get pkeys from log",
K(backup_info), K(param.restore_timestamp_));
} else if (OB_FAIL(fill_pkeys_for_physical_restore_log(job, arg))) {
LOG_WARN("fail to fill pkeys for physical restore log", KR(ret), K(arg));
}

View File

@ -1046,6 +1046,7 @@ int ObRestoreBackupInfoUtil::get_restore_backup_info_v1_(
const int64_t restore_timestamp = param.restore_timestamp_;
const char *passwd_array = param.passwd_array_;
ObFakeBackupLeaseService fake_backup_lease;
bool is_snapshot_restore = false;
if (OB_ISNULL(backup_dest) || OB_ISNULL(backup_cluster_name) || cluster_id <= 0 || incarnation < 0 ||
OB_ISNULL(backup_tenant_name) || restore_timestamp <= 0 || OB_ISNULL(passwd_array)) {
@ -1079,6 +1080,13 @@ int ObRestoreBackupInfoUtil::get_restore_backup_info_v1_(
LOG_WARN("failed to init backup info mgr", K(ret), K(dest), K(tenant_info));
} else if (OB_FAIL(backup_info_mgr.find_backup_info(restore_timestamp, passwd_array, backup_info))) {
LOG_WARN("failed to find backup info", K(ret), K(restore_timestamp), K(tenant_info));
} else if (OB_FAIL(check_is_snapshot_restore(backup_info.backup_snapshot_version_,
restore_timestamp,
backup_info.cluster_version_,
is_snapshot_restore))) {
LOG_WARN("failed to check is snapshot restore", K(ret), K(backup_info), K(restore_timestamp));
} else if (is_snapshot_restore) {
LOG_INFO("backup info backup snapshot version equal to restore timestamp", K(backup_info), K(restore_timestamp));
} else if (OB_FAIL(log_archive_backup_info_mgr.read_extern_log_archive_backup_info(
dest, tenant_info.tenant_id_, log_archive_backup_info))) {
LOG_WARN("failed to read extern log archive backup info", K(ret), K(dest), K(tenant_info));
@ -1154,7 +1162,10 @@ int ObRestoreBackupInfoUtil::get_restore_backup_info_v2_(
if (OB_FAIL(
inner_get_restore_backup_set_info_(param, backup_set_info, tenant_locality_info, info.sys_pg_key_list_))) {
LOG_WARN("failed to inner get restore backup set info", K(ret));
} else if (OB_FAIL(check_is_snapshot_restore_(param, backup_set_info, is_snapshot_restore))) {
} else if (OB_FAIL(check_is_snapshot_restore(backup_set_info.snapshot_version_,
param.restore_timestamp_,
backup_set_info.cluster_version_,
is_snapshot_restore))) {
LOG_WARN("failed to check is snapshot backup", K(ret), K(backup_set_info));
} else if (!is_snapshot_restore && OB_FAIL(inner_get_restore_backup_piece_info_(param, piece_info))) {
LOG_WARN("failed to inner get restore backup piece info", K(ret));
@ -1190,18 +1201,6 @@ int ObRestoreBackupInfoUtil::get_restore_backup_info_v2_(
return ret;
}
int ObRestoreBackupInfoUtil::check_is_snapshot_restore_(
const GetRestoreBackupInfoParam &param, const ObBackupSetFileInfo &backup_set_info, bool &is_snapshot_restore)
{
int ret = OB_SUCCESS;
is_snapshot_restore = false;
if (param.backup_piece_path_list_.empty() && !param.backup_set_path_list_.empty()) {
is_snapshot_restore = backup_set_info.snapshot_version_ == param.restore_timestamp_;
LOG_INFO("check is snapshot backup", K(backup_set_info.snapshot_version_), K(param.restore_timestamp_));
}
return ret;
}
int ObRestoreBackupInfoUtil::inner_get_restore_backup_set_info_(const GetRestoreBackupInfoParam &param,
ObBackupSetFileInfo &backup_set_info, ObExternTenantLocalityInfo &tenant_locality_info,
common::ObIArray<common::ObPGKey> &sys_pg_key_list)
@ -1266,6 +1265,30 @@ int ObRestoreBackupInfoUtil::get_restore_sys_table_ids(
return OB_SUCCESS;
}
int ObRestoreBackupInfoUtil::check_is_snapshot_restore(const int64_t backup_snapshot, const int64_t restore_timestamp,
const uint64_t cluster_version, bool &is_snapshot_restore)
{
int ret = OB_SUCCESS;
is_snapshot_restore = false;
if (backup_snapshot <= 0 || restore_timestamp <= 0 || 0 == cluster_version) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("check is restore snapshot restore get invalid argument",
K(ret),
K(backup_snapshot),
K(restore_timestamp),
K(cluster_version));
} else {
is_snapshot_restore = backup_snapshot == restore_timestamp && cluster_version > CLUSTER_VERSION_3000;
}
LOG_INFO("check is snapshot restore",
K(is_snapshot_restore),
K(backup_snapshot),
K(restore_timestamp),
K(cluster_version));
return ret;
}
ObRestoreFatalErrorReporter &ObRestoreFatalErrorReporter::get_instance()
{
static ObRestoreFatalErrorReporter reporter;

View File

@ -165,13 +165,14 @@ public:
static int get_restore_sys_table_ids(
const ObPhysicalRestoreInfo &info, common::ObIArray<common::ObPartitionKey> &pkey_list);
static int check_is_snapshot_restore(const int64_t backup_snapshot, const int64_t restore_timestamp,
const uint64_t cluster_version, bool &is_snapshot_restore);
private:
// get info from cluster backup dest level
static int get_restore_backup_info_v1_(const GetRestoreBackupInfoParam &param, ObRestoreBackupInfo &info);
// get info from simple path level
static int get_restore_backup_info_v2_(const GetRestoreBackupInfoParam &param, ObRestoreBackupInfo &info);
static int check_is_snapshot_restore_(
const GetRestoreBackupInfoParam &param, const ObBackupSetFileInfo &backup_set_info, bool &is_snapshot_restore);
static int inner_get_restore_backup_set_info_(const GetRestoreBackupInfoParam &param,
ObBackupSetFileInfo &backup_set_info, ObExternTenantLocalityInfo &tenant_locality_info,
common::ObIArray<common::ObPGKey> &sys_pg_keys);

View File

@ -20,6 +20,7 @@
#include "share/backup/ob_extern_backup_info_mgr.h"
#include "share/backup/ob_log_archive_backup_info_mgr.h"
#include "lib/restore/ob_storage.h"
#include "share/backup/ob_backup_info_mgr.h"
using namespace oceanbase::common;
using namespace oceanbase::share;
@ -776,8 +777,9 @@ int ObMultiBackupDestUtil::do_get_backup_set_list(const bool is_preview, const c
} else {
LOG_WARN("failed to get extern backup set file infos", KR(ret), K(simple_path));
}
} else if (OB_FAIL(check_is_snapshot_restore(info, restore_timestamp, is_snapshot_restore))) {
LOG_WARN("failed to check is snapshot backup", K(ret), K(info));
} else if (OB_FAIL(ObRestoreBackupInfoUtil::check_is_snapshot_restore(
info.snapshot_version_, restore_timestamp, info.cluster_version_, is_snapshot_restore))) {
LOG_WARN("failed to check is snapshot restore", K(ret), K(info), K(restore_timestamp));
} else {
simple_path.backup_set_id_ = info.backup_set_id_;
simple_path.copy_id_ = info.copy_id_;
@ -880,8 +882,11 @@ int ObMultiBackupDestUtil::do_get_backup_set_list_from_cluster_level(const bool
ObClusterBackupDest cluster_backup_dest;
ObBackupDest tmp_backup_dest;
char tmp_simple_path_str[OB_MAX_BACKUP_DEST_LENGTH] = "";
if (OB_FAIL(check_is_snapshot_restore(tmp_file_info, restore_timestamp, is_snapshot_restore))) {
LOG_WARN("failed to check is snaptshot backup", K(ret), K(tmp_file_info));
if (OB_FAIL(ObRestoreBackupInfoUtil::check_is_snapshot_restore(tmp_file_info.snapshot_version_,
restore_timestamp,
tmp_file_info.cluster_version_,
is_snapshot_restore))) {
LOG_WARN("failed to check is snapshot restore", K(ret), K(tmp_file_info), K(restore_timestamp));
} else if (OB_FAIL(cluster_backup_dest.set(
tmp_file_info.backup_dest_.ptr(), cluster_name, cluster_id, OB_START_INCARNATION))) {
LOG_WARN("failed to set cluster backup dest");
@ -953,8 +958,9 @@ int ObMultiBackupDestUtil::do_inner_get_backup_set_list(const char *cluster_name
const ObBackupSetFileInfo &info = file_infos.at(i);
if (OB_SUCCESS != info.result_) {
// do nothing
} else if (OB_FAIL(check_is_snapshot_restore(info, restore_timestamp, is_snapshot_restore))) {
LOG_WARN("failed to check is snaptshot backup", K(ret), K(info), K(restore_timestamp));
} else if (OB_FAIL(ObRestoreBackupInfoUtil::check_is_snapshot_restore(
info.snapshot_version_, restore_timestamp, info.cluster_version_, is_snapshot_restore))) {
LOG_WARN("failed to check is snapshot restore", K(ret), K(info), K(restore_timestamp));
} else if (!ObBackupFileStatus::can_show_in_preview(info.file_status_)) {
LOG_INFO("backup set info cannot list in preview", K(info));
} else {
@ -1442,18 +1448,5 @@ int ObMultiBackupDestUtil::check_backup_path_is_backup_backup(const char *cluste
return ret;
}
int ObMultiBackupDestUtil::check_is_snapshot_restore(
const share::ObBackupSetFileInfo &backup_set_info, const int64_t restore_timestamp, bool &is_snapshot_restore)
{
int ret = OB_SUCCESS;
if (!backup_set_info.is_valid() || restore_timestamp <= 0) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("get invalid args", K(ret), K(backup_set_info), K(restore_timestamp));
} else {
is_snapshot_restore = backup_set_info.snapshot_version_ == restore_timestamp;
}
return ret;
}
} // end namespace share
} // end namespace oceanbase

View File

@ -126,8 +126,6 @@ private:
static int check_backup_path_is_backup_backup(const char *cluster_name, const int64_t cluster_id,
const common::ObString &root_path, const common::ObString &storage_info, const uint64_t tenant_id,
bool &is_backup_backup);
static int check_is_snapshot_restore(
const share::ObBackupSetFileInfo &backup_set_info, const int64_t restore_timestamp, bool &is_snapshot_restore);
private:
DISALLOW_COPY_AND_ASSIGN(ObMultiBackupDestUtil);