提交 b3780cad 编写于 作者: O oceanoverflow 提交者: LINGuanRen

fix restore failure in open source release

上级 2a8f9bf0
......@@ -643,7 +643,7 @@ int ObRestoreUtil::fill_compat_backup_path(
if (OB_SUCC(ret)) {
// for compat backup path, clog restore use multi restore path
if (OB_FAIL(fill_clog_path_list(arg.uri_, arg, job))) {
if (OB_FAIL(inner_fill_compat_backup_path(arg.uri_, arg, job))) {
if (OB_ENTRY_NOT_EXIST == ret) {
ret = OB_SUCCESS;
} else {
......@@ -655,15 +655,14 @@ int ObRestoreUtil::fill_compat_backup_path(
return ret;
}
int ObRestoreUtil::fill_clog_path_list(
const ObString& uri, const obrpc::ObPhysicalRestoreTenantArg& arg, share::ObPhysicalRestoreJob& job)
int ObRestoreUtil::inner_fill_compat_backup_path(
const ObString &uri, const obrpc::ObPhysicalRestoreTenantArg &arg, share::ObPhysicalRestoreJob &job)
{
int ret = OB_SUCCESS;
ObArray<ObString> uri_list;
uint64_t backup_tenant_id = OB_INVALID_ID;
const int64_t restore_timestamp = arg.restore_timestamp_;
ObArray<ObSimpleBackupSetPath> backup_set_list;
ObArray<ObSimpleBackupSetPath> fake_backup_set_list;
ObArray<ObSimpleBackupPiecePath> backup_piece_list;
if (OB_FAIL(uri_list.push_back(uri))) {
LOG_WARN("failed to push back", KR(ret), K(uri));
......@@ -684,7 +683,7 @@ int ObRestoreUtil::fill_clog_path_list(
backup_set_list,
backup_piece_list))) {
LOG_WARN("failed to get backup path list", KR(ret), K(uri_list));
} else if (OB_FAIL(job.multi_restore_path_list_.set(fake_backup_set_list, backup_piece_list))) {
} else if (OB_FAIL(job.multi_restore_path_list_.set(backup_set_list, backup_piece_list))) {
LOG_WARN("failed to set mutli restore path list", KR(ret));
}
return ret;
......
......@@ -141,8 +141,8 @@ private:
static int fill_backup_path(const obrpc::ObPhysicalRestoreTenantArg& arg, share::ObPhysicalRestoreJob& job);
static int fill_multi_backup_path(const obrpc::ObPhysicalRestoreTenantArg& arg, share::ObPhysicalRestoreJob& job);
static int fill_compat_backup_path(const obrpc::ObPhysicalRestoreTenantArg& arg, share::ObPhysicalRestoreJob& job);
static int fill_clog_path_list(
const ObString& uri, const obrpc::ObPhysicalRestoreTenantArg& arg, share::ObPhysicalRestoreJob& job);
static int inner_fill_compat_backup_path(
const ObString &uri, const obrpc::ObPhysicalRestoreTenantArg &arg, share::ObPhysicalRestoreJob &job);
static int get_multi_path_file_info_list(const common::ObArray<share::ObSimpleBackupSetPath>& backup_set_list,
const common::ObArray<share::ObSimpleBackupPiecePath>& backup_piece_list,
common::ObArray<share::ObBackupSetFileInfo>& set_info_list,
......
......@@ -1398,7 +1398,6 @@ int ObBackupDest::set(const char* backup_dest)
} else if (OB_FAIL(get_storage_type_from_path(bakup_dest_str, type))) {
LOG_WARN("failed to get storage type", K(ret));
} else {
// oss://backup_dir/?host=http://oss-cn-hangzhou-zmf.aliyuncs.com&access_id=111&access_key=222
// file:///root_backup_dir"
while (backup_dest[pos] != '\0') {
if (backup_dest[pos] == '?') {
......@@ -3454,8 +3453,7 @@ void ObPhysicalRestoreInfo::reset()
bool ObPhysicalRestoreInfo::is_valid() const
{
return (strlen(backup_dest_) > 0 || multi_restore_path_list_.get_backup_set_path_list().count() > 0) &&
!(strlen(backup_dest_) > 0 && multi_restore_path_list_.get_backup_set_path_list().count() > 0) &&
return !(0 == strlen(backup_dest_) && 0 == multi_restore_path_list_.get_backup_set_path_list().count()) &&
strlen(cluster_name_) > 0 && cluster_id_ > 0 && OB_START_INCARNATION == incarnation_ && tenant_id_ > 0 &&
full_backup_set_id_ > 0 && inc_backup_set_id_ > 0 && log_archive_round_ > 0 && restore_snapshot_version_ > 0 &&
restore_start_ts_ > 0 && compatible_ > 0 && cluster_version_ > 0 && backup_date_ >= 0;
......
......@@ -716,6 +716,13 @@ int ObExternBackupInfoMgr::get_extern_backup_info(const ObBaseBackupInfoStruct&
extern_backup_info.prev_backup_data_version_ =
info.backup_type_.is_full_backup() ? 0 : last_succeed_info_.backup_data_version_;
extern_backup_info.backup_type_ = info.backup_type_.type_;
#ifdef ERRSIM
const bool use_fake_date = ObServerConfig::get_instance().fake_backup_date_for_incremental_backup;
static const int64_t FAKE_DATE_DELTA = 1;
if (!info.backup_type_.is_full_backup() && use_fake_date) {
extern_backup_info.date_ += FAKE_DATE_DELTA;
}
#endif
}
}
}
......
......@@ -28,92 +28,101 @@ enum ObMultiBackupPathType {
};
struct ObCmpSetPathCopyIdSmaller {
bool operator()(const share::ObSimpleBackupSetPath& lhs, const share::ObSimpleBackupSetPath& rhs);
bool operator()(const share::ObSimpleBackupSetPath &lhs, const share::ObSimpleBackupSetPath &rhs);
};
struct ObCmpPiecePathCopyIdSmaller {
bool operator()(const share::ObSimpleBackupPiecePath& lhs, const share::ObSimpleBackupPiecePath& rhs);
bool operator()(const share::ObSimpleBackupPiecePath &lhs, const share::ObSimpleBackupPiecePath &rhs);
};
struct ObCmpBackupPieceInfoBackupPieceId {
bool operator()(const share::ObBackupPieceInfo& lhs, const share::ObBackupPieceInfo& rhs);
bool operator()(const share::ObBackupPieceInfo &lhs, const share::ObBackupPieceInfo &rhs);
};
struct ObCmpBackupSetInfoBackupSetId {
bool operator()(const share::ObBackupSetFileInfo& lhs, const share::ObBackupSetFileInfo& rhs);
bool operator()(const share::ObBackupSetFileInfo &lhs, const share::ObBackupSetFileInfo &rhs);
};
class ObMultiBackupDestUtil {
public:
ObMultiBackupDestUtil() = default;
~ObMultiBackupDestUtil() = default;
static int parse_multi_uri(const common::ObString& multi_uri, common::ObArenaAllocator& allocator,
common::ObArray<common::ObString>& uri_list);
static int parse_multi_uri(const common::ObString &multi_uri, common::ObArenaAllocator &allocator,
common::ObArray<common::ObString> &uri_list);
static int check_all_path_is_same_type(
const common::ObArray<common::ObString>& path_list, bool& is_same, ObMultiBackupPathType& type);
static int get_backup_tenant_id(const common::ObArray<common::ObString>& url_list, const ObMultiBackupPathType& type,
const common::ObString& cluster_name, const int64_t cluster_id, const common::ObString& tenant_name,
const int64_t restore_timestamp, uint64_t& tenant_id);
static int get_multi_backup_path_list(const bool is_preview, const char* cluster_name, const int64_t cluster_id,
const uint64_t tenant_id, const int64_t restore_timestamp, const common::ObArray<common::ObString>& list,
common::ObArray<ObSimpleBackupSetPath>& set_list, common::ObArray<ObSimpleBackupPiecePath>& piece_list);
const common::ObArray<common::ObString> &path_list, bool &is_same, ObMultiBackupPathType &type);
static int get_backup_tenant_id(const common::ObArray<common::ObString> &url_list, const ObMultiBackupPathType &type,
const common::ObString &cluster_name, const int64_t cluster_id, const common::ObString &tenant_name,
const int64_t restore_timestamp, uint64_t &tenant_id);
static int get_multi_backup_path_list(const bool is_preview, const char *cluster_name, const int64_t cluster_id,
const uint64_t tenant_id, const int64_t restore_timestamp, const common::ObArray<common::ObString> &list,
common::ObArray<ObSimpleBackupSetPath> &set_list, common::ObArray<ObSimpleBackupPiecePath> &piece_list);
static int filter_duplicate_path_list(
common::ObArray<ObSimpleBackupSetPath>& set_list, common::ObArray<ObSimpleBackupPiecePath>& piece_list);
common::ObArray<ObSimpleBackupSetPath> &set_list, common::ObArray<ObSimpleBackupPiecePath> &piece_list);
static int check_multi_path_is_complete(const int64_t restore_timestamp,
common::ObArray<share::ObBackupSetFileInfo>& set_info_list,
common::ObArray<share::ObBackupPieceInfo>& piece_info_list, bool& is_complete);
common::ObArray<share::ObBackupSetFileInfo> &set_info_list,
common::ObArray<share::ObBackupPieceInfo> &piece_info_list, bool &is_complete);
private:
static int check_is_compat_backup_path(const char *cluster_name, const int64_t cluster_id,
const share::ObBackupDest &backup_dest, const uint64_t tenant_id, const int64_t restore_timestamp,
int64_t &snapshot_version, bool &is_compat_path);
static int get_backup_dest_list(
const common::ObArray<common::ObString>& path_list, common::ObArray<ObBackupPathString>& dest_list);
static int get_backup_set_info_path(const common::ObString& user_path, ObBackupPath& backup_set_path);
static int get_backup_piece_info_path(const common::ObString& user_path, ObBackupPath& backup_piece_path);
const common::ObArray<common::ObString> &path_list, common::ObArray<ObBackupPathString> &dest_list);
static int get_backup_set_info_path(const common::ObString &user_path, ObBackupPath &backup_set_path);
static int get_backup_piece_info_path(const common::ObString &user_path, ObBackupPath &backup_piece_path);
static int get_path_type(
const common::ObString& path, const common::ObString& storage_info, ObMultiBackupPathType& type);
const common::ObString &path, const common::ObString &storage_info, ObMultiBackupPathType &type);
static int inner_get_backup_tenant_id_from_set_or_piece(
const common::ObArray<common::ObString>& path_list, const int64_t restore_timestamp, uint64_t& tenant_id);
const common::ObArray<common::ObString> &path_list, const int64_t restore_timestamp, uint64_t &tenant_id);
static int inner_get_backup_tenant_id_from_set_info(
const common::ObString& url, const int64_t restore_timestamp, uint64_t& tenant_id);
const common::ObString &url, const int64_t restore_timestamp, uint64_t &tenant_id);
static int inner_get_backup_tenant_id_from_piece_info(
const common::ObString& url, const int64_t restore_timestamp, uint64_t& tenant_id);
static int inner_get_backup_tenant_id_from_tenant_name_info(const common::ObString& cluster_name,
const int64_t cluster_id, const common::ObString& url, const common::ObString& tenant_name,
const int64_t restore_timestamp, uint64_t& tenant_id);
static int get_cluster_backup_dest(const ObBackupDest& backup_dest, const char* cluster_name,
const int64_t cluster_id, share::ObClusterBackupDest& cluster_backup_dest);
static int get_backup_set_list(const bool is_preview, const char* cluster_name, const int64_t cluster_id,
const uint64_t tenant_id, const int64_t restore_timestamp, const common::ObString& backup_dest_str,
common::ObArray<ObSimpleBackupSetPath>& path_list, int64_t& snapshot_version, int64_t& start_replay_log_ts);
static int do_get_backup_set_list(const bool is_preview, const char* cluster_name, const int64_t cluster_id,
const uint64_t tenant_id, const int64_t restore_timestamp, const ObBackupDest& backup_dest,
common::ObArray<ObSimpleBackupSetPath>& path_list, int64_t& snapshot_version, int64_t& start_replay_log_ts);
static int do_get_backup_set_list_from_cluster_level(const bool is_preview, const char* cluster_name,
const common::ObString &url, const int64_t restore_timestamp, uint64_t &tenant_id);
static int inner_get_backup_tenant_id_from_tenant_name_info(const common::ObString &cluster_name,
const int64_t cluster_id, const common::ObString &url, const common::ObString &tenant_name,
const int64_t restore_timestamp, uint64_t &tenant_id);
static int get_cluster_backup_dest(const ObBackupDest &backup_dest, const char *cluster_name,
const int64_t cluster_id, share::ObClusterBackupDest &cluster_backup_dest);
static int get_backup_set_list(const bool is_preview, const char *cluster_name, const int64_t cluster_id,
const uint64_t tenant_id, const int64_t restore_timestamp, const common::ObString &backup_dest_str,
common::ObArray<ObSimpleBackupSetPath> &path_list, int64_t &snapshot_version, int64_t &start_replay_log_ts,
bool &is_compat_path);
static int do_get_backup_set_list(const bool is_preview, const char *cluster_name, const int64_t cluster_id,
const uint64_t tenant_id, const int64_t restore_timestamp, const ObBackupDest &backup_dest,
common::ObArray<ObSimpleBackupSetPath> &path_list, int64_t &snapshot_version, int64_t &start_replay_log_ts,
bool &is_compat_path);
static int do_get_backup_set_list_from_cluster_level(const bool is_preview, const char *cluster_name,
const int64_t cluster_id, const uint64_t tenant_id, const int64_t restore_timestamp,
const ObBackupDest& backup_dest, common::ObArray<ObSimpleBackupSetPath>& path_list, int64_t& snapshot_version,
int64_t& start_replay_log_ts);
static int do_inner_get_backup_set_list(const char* cluster_name, const int64_t cluster_id,
const int64_t restore_timestamp, const ObArray<ObBackupSetFileInfo>& file_infos,
common::ObArray<ObSimpleBackupSetPath>& path_list, int64_t& snapshot_version, int64_t& start_replay_log_ts);
static int get_backup_piece_list(const bool is_preview, const char* cluster_name, const int64_t cluster_id,
const ObBackupDest &backup_dest, common::ObArray<ObSimpleBackupSetPath> &path_list, int64_t &snapshot_version,
int64_t &start_replay_log_ts);
static int do_inner_get_backup_set_list(const char *cluster_name, const int64_t cluster_id,
const int64_t restore_timestamp, const ObBackupDest &backup_dest, const ObArray<ObBackupSetFileInfo> &file_infos,
common::ObArray<ObSimpleBackupSetPath> &path_list, int64_t &snapshot_version, int64_t &start_replay_log_ts);
static int get_backup_piece_list(const bool is_preview, const char *cluster_name, const int64_t cluster_id,
const uint64_t tenant_id, const int64_t snapshot_version, const int64_t start_replay_log_ts,
const int64_t restore_timestamp, const common::ObString& backup_dest_str,
common::ObArray<ObSimpleBackupPiecePath>& path_list);
static int do_get_backup_piece_list(const bool is_preview, const char* cluster_name, const int64_t cluster_id,
const int64_t restore_timestamp, const common::ObString &backup_dest_str,
common::ObArray<ObSimpleBackupPiecePath> &path_list);
static int get_compat_backup_piece_list(const char *cluster_name, const int64_t cluster_id, const uint64_t tenant_id,
const int64_t snapshot_version, const int64_t restore_timestamp, const common::ObString &backup_dest_str,
common::ObArray<ObSimpleBackupPiecePath> &path_list);
static int do_get_backup_piece_list(const bool is_preview, const char *cluster_name, const int64_t cluster_id,
const uint64_t tenant_id, const int64_t snapshot_version, const int64_t start_replay_log_ts,
const int64_t restore_timestamp, const ObBackupDest& backup_dest,
common::ObArray<ObSimpleBackupPiecePath>& path_list);
static int do_get_backup_piece_list_from_cluster_level(const bool is_preview, const char* cluster_name,
const int64_t restore_timestamp, const ObBackupDest &backup_dest,
common::ObArray<ObSimpleBackupPiecePath> &path_list);
static int do_get_backup_piece_list_from_cluster_level(const bool is_preview, const char *cluster_name,
const int64_t cluster_id, const uint64_t tenant_id, const int64_t snapshot_version,
const int64_t start_replay_log_ts, const int64_t restore_timestamp, const ObBackupDest& backup_dest,
common::ObArray<ObSimpleBackupPiecePath>& path_list);
static int do_inner_get_backup_piece_list(const char* cluster_name, const int64_t cluster_id,
const int64_t start_replay_log_ts, const int64_t restore_timestamp, const ObBackupDest &backup_dest,
common::ObArray<ObSimpleBackupPiecePath> &path_list);
static int do_inner_get_backup_piece_list(const char *cluster_name, const int64_t cluster_id,
const int64_t snapshot_version, const int64_t start_replay_log_ts, const int64_t restore_timestamp,
const ObArray<ObBackupPieceInfo>& piece_array, common::ObArray<ObSimpleBackupPiecePath>& path_list);
static int may_need_replace_active_piece_info(const ObClusterBackupDest& dest, const common::ObString& storage_info,
common::ObArray<ObBackupPieceInfo>& piece_array);
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);
const ObBackupDest &backup_dest, const ObArray<ObBackupPieceInfo> &piece_array,
common::ObArray<ObSimpleBackupPiecePath> &path_list);
static int may_need_replace_active_piece_info(const ObClusterBackupDest &dest, const common::ObString &storage_info,
common::ObArray<ObBackupPieceInfo> &piece_array);
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);
private:
DISALLOW_COPY_AND_ASSIGN(ObMultiBackupDestUtil);
......
......@@ -210,8 +210,7 @@ ObPhysicalRestoreJob::ObPhysicalRestoreJob()
bool ObPhysicalRestoreJob::is_valid() const
{
return OB_INVALID_ID != job_id_ && PhysicalRestoreStatus::PHYSICAL_RESTORE_MAX_STATUS != status_ &&
((!multi_restore_path_list_.is_compat_backup_path() && strlen(backup_dest_) == 0) ||
(multi_restore_path_list_.is_compat_backup_path() && strlen(backup_dest_) > 0));
!(0 == strlen(backup_dest_) && 0 == multi_restore_path_list_.get_backup_set_path_list().count());
}
DEF_TO_STRING(ObPhysicalRestoreJob)
......
......@@ -1189,6 +1189,9 @@ ERRSIM_DEF_BOOL(allow_major_sstable_merge, OB_CLUSTER_PARAMETER, "True", "allow_
ObParameterAttr(Section::OBSERVER, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE));
ERRSIM_DEF_BOOL(trigger_reuse_table_in_table_mgr, OB_CLUSTER_PARAMETER, "False", "trigger_reuse_table_in_table_mgr",
ObParameterAttr(Section::OBSERVER, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE));
ERRSIM_DEF_BOOL(fake_backup_date_for_incremental_backup, OB_CLUSTER_PARAMETER, "False",
"incremental backup use fake backup date",
ObParameterAttr(Section::OBSERVER, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE));
ERRSIM_DEF_CAP(slog_size, OB_CLUSTER_PARAMETER, "256M", "[0M,256M]", "size of the slog file. Range: [0, 256M]",
ObParameterAttr(Section::SSTABLE, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE));
ERRSIM_DEF_BOOL(fake_replay_start_point, OB_CLUSTER_PARAMETER, "False", "fake_replay_start_point",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册