add backup file suffix and unified format

This commit is contained in:
WenJinyu
2023-01-28 20:16:26 +08:00
committed by ob-robot
parent 3329d12085
commit c94ddf80cb
15 changed files with 237 additions and 165 deletions

View File

@ -739,7 +739,7 @@ int ObBackupCleanTaskMgr::delete_data_info_turn_files_(const ObBackupPath &infos
LOG_WARN("file name is null", K(ret));
} else if (OB_FAIL(info_path.init(infos_path.get_ptr()))) {
LOG_WARN("failed to init major path", K(ret), K(info_path));
} else if (OB_FAIL(info_path.join(tmp_entry.name_))) {
} else if (OB_FAIL(info_path.join(tmp_entry.name_, ObBackupFileSuffix::NONE))) {
LOG_WARN("failed to join major path", K(ret));
} else if (OB_FAIL(ObBackupCleanUtil::delete_backup_dir_files(info_path, backup_dest_.get_storage_info()))) {
LOG_WARN("failed to delete backup log stream dir files", K(ret), K(info_path));

View File

@ -54,7 +54,7 @@ int ObArchivePathUtil::build_restore_path(const char *base,
ARCHIVE_LOG(WARN, "init prefix failed", K(ret), K(base));
} else if (OB_FAIL(path.join_ls(id))) {
ARCHIVE_LOG(WARN, "join ls failed", K(ret), K(id));
} else if (OB_FAIL(path.join(file_id))) {
} else if (OB_FAIL(path.join(file_id, ObBackupFileSuffix::ARCHIVE))) {
ARCHIVE_LOG(WARN, "join file_id failed", K(ret), K(id), K(file_id));
} else {
ARCHIVE_LOG(INFO, "build restore prefix succ", K(path));
@ -69,7 +69,7 @@ int ObArchivePathUtil::get_rounds_dir_path(const ObBackupDest &dest, ObBackupPat
rounds_path.reset();
if (OB_FAIL(rounds_path.init(dest.get_root_path()))) {
LOG_WARN("failed to assign dest path", K(ret), K(dest));
} else if (OB_FAIL(rounds_path.join(ROUNDS_DIR_PATH))) {
} else if (OB_FAIL(rounds_path.join(ROUNDS_DIR_PATH, ObBackupFileSuffix::NONE))) {
LOG_WARN("failed to join path", K(ret), K(rounds_path));
}
return ret;
@ -85,7 +85,7 @@ int ObArchivePathUtil::get_round_start_file_path(const ObBackupDest &dest, const
LOG_WARN("failed to get rounds dir path", K(ret), K(dest), K(dest_id), K(round_id));
} else if (OB_FAIL(databuff_printf(file_name, sizeof(file_name), "round_d%ldr%ld_start", dest_id, round_id))) {
LOG_WARN("failed to assign round start file path", K(ret), K(dest), K(dest_id), K(round_id));
} else if (OB_FAIL(path.join(file_name))) {
} else if (OB_FAIL(path.join(file_name, ObBackupFileSuffix::ARCHIVE))) {
LOG_WARN("failed to join path", K(ret), K(path), K(file_name));
}
return ret;
@ -101,7 +101,7 @@ int ObArchivePathUtil::get_round_end_file_path(const ObBackupDest &dest, const i
LOG_WARN("failed to get rounds dir path", K(ret), K(dest), K(dest_id), K(round_id));
} else if (OB_FAIL(databuff_printf(file_name, sizeof(file_name), "round_d%ldr%ld_end", dest_id, round_id))) {
LOG_WARN("failed to assign round end file path", K(ret), K(dest), K(dest_id), K(round_id));
} else if (OB_FAIL(path.join(file_name))) {
} else if (OB_FAIL(path.join(file_name, ObBackupFileSuffix::ARCHIVE))) {
LOG_WARN("failed to join file name", K(ret), K(file_name), K(path));
}
return ret;
@ -114,7 +114,7 @@ int ObArchivePathUtil::get_pieces_dir_path(const ObBackupDest &dest, ObBackupPat
pieces_path.reset();
if (OB_FAIL(pieces_path.init(dest.get_root_path()))) {
LOG_WARN("failed to assign dest path", K(ret), K(dest));
} else if (OB_FAIL(pieces_path.join(PIECES_DIR_PATH))) {
} else if (OB_FAIL(pieces_path.join(PIECES_DIR_PATH, ObBackupFileSuffix::NONE))) {
LOG_WARN("failed to join path", K(ret), K(pieces_path));
}
return ret;
@ -135,7 +135,7 @@ int ObArchivePathUtil::get_piece_start_file_path(const ObBackupDest &dest, const
LOG_WARN("failed to get pieces dir path", K(ret), K(dest), K(dest_id), K(round_id), K(piece_id), K(start_scn));
} else if (OB_FAIL(databuff_printf(file_name, sizeof(file_name), "piece_d%ldr%ldp%ld_start_%s", dest_id, round_id, piece_id, buff))) {
LOG_WARN("failed to assign piece start file path", K(ret), K(dest), K(dest_id), K(round_id), K(piece_id), K(start_scn), K(buff));
} else if (OB_FAIL(path.join(file_name))) {
} else if (OB_FAIL(path.join(file_name, ObBackupFileSuffix::ARCHIVE))) {
LOG_WARN("failed to join file name", K(ret), K(path), K(file_name));
}
return ret;
@ -156,7 +156,7 @@ int ObArchivePathUtil::get_piece_end_file_path(const ObBackupDest &dest, const i
LOG_WARN("failed to get pieces dir path", K(ret), K(dest), K(dest_id), K(round_id), K(piece_id), K(end_scn));
} else if (OB_FAIL(databuff_printf(file_name, sizeof(file_name), "piece_d%ldr%ldp%ld_end_%s", dest_id, round_id, piece_id, buff))) {
LOG_WARN("failed to assign piece end file path", K(ret), K(dest), K(dest_id), K(round_id), K(piece_id), K(end_scn), K(buff));
} else if (OB_FAIL(path.join(file_name))) {
} else if (OB_FAIL(path.join(file_name, ObBackupFileSuffix::ARCHIVE))) {
LOG_WARN("failed to join file name", K(ret), K(path), K(file_name));
}
return ret;
@ -173,7 +173,7 @@ int ObArchivePathUtil::get_piece_dir_path(const ObBackupDest &dest, const int64_
LOG_WARN("failed to assign dest path", K(ret), K(dest), K(dest_id), K(round_id), K(piece_id));
} else if (OB_FAIL(databuff_printf(dir_name, sizeof(dir_name), "piece_d%ldr%ldp%ld", dest_id, round_id, piece_id))) {
LOG_WARN("failed to assign piece dir path", K(ret), K(dest), K(dest_id), K(round_id), K(piece_id));
} else if (OB_FAIL(path.join(dir_name))) {
} else if (OB_FAIL(path.join(dir_name, ObBackupFileSuffix::NONE))) {
LOG_WARN("failed to join dir name", K(ret), K(path), K(dir_name));
}
return ret;
@ -187,7 +187,7 @@ int ObArchivePathUtil::get_single_piece_file_path(const ObBackupDest &dest, cons
int64_t pos = 0;
if (OB_FAIL(get_piece_dir_path(dest, dest_id, round_id, piece_id, path))) {
LOG_WARN("failed to get piece dir path", K(ret), K(dest), K(round_id), K(dest_id), K(piece_id));
} else if (OB_FAIL(path.join("single_piece_info"))) {
} else if (OB_FAIL(path.join("single_piece_info", ObBackupFileSuffix::ARCHIVE))) {
LOG_WARN("failed to join single piece info", K(ret), K(path));
}
return ret;
@ -201,13 +201,13 @@ int ObArchivePathUtil::get_piece_checkpoint_dir_path(const ObBackupDest &dest, c
if (OB_FAIL(get_piece_dir_path(dest, dest_id, round_id, piece_id, path))) {
LOG_WARN("failed to get piece dir path", K(ret), K(dest), K(round_id), K(dest_id), K(piece_id));
} else if (OB_FAIL(path.join("checkpoint"))) {
} else if (OB_FAIL(path.join("checkpoint", ObBackupFileSuffix::NONE))) {
LOG_WARN("failed to join checkpoint dir path", K(ret), K(path));
}
return ret;
}
// oss://archive/piece_d[dest_id]r[round_id]p[piece_id]/checkpoint/checkpoint_info_[file_id]
// oss://archive/piece_d[dest_id]r[round_id]p[piece_id]/checkpoint/checkpoint_info.[file_id]
int ObArchivePathUtil::get_piece_checkpoint_file_path(const ObBackupDest &dest, const int64_t dest_id,
const int64_t round_id, const int64_t piece_id, const int64_t file_id, ObBackupPath &path)
{
@ -215,9 +215,9 @@ int ObArchivePathUtil::get_piece_checkpoint_file_path(const ObBackupDest &dest,
char file_name[OB_MAX_BACKUP_PATH_LENGTH] = { 0 };
if (OB_FAIL(get_piece_checkpoint_dir_path(dest, dest_id, round_id, piece_id, path))) {
LOG_WARN("failed to get piece dir path", K(ret), K(dest), K(round_id), K(dest_id), K(piece_id), K(file_id));
} else if (OB_FAIL(databuff_printf(file_name, sizeof(file_name), "checkpoint_info_%ld", file_id))) {
} else if (OB_FAIL(databuff_printf(file_name, sizeof(file_name), "checkpoint_info.%ld", file_id))) {
LOG_WARN("failed to assign checkpoint info path", K(ret), K(dest), K(round_id), K(dest_id), K(piece_id), K(file_id));
} else if (OB_FAIL(path.join(file_name))) {
} else if (OB_FAIL(path.join(file_name, ObBackupFileSuffix::ARCHIVE))) {
LOG_WARN("failed to join file name", K(ret), K(path), K(file_name));
}
return ret;
@ -242,7 +242,7 @@ int ObArchivePathUtil::get_piece_inner_placeholder_file_path(const ObBackupDest
} else if (OB_FAIL(databuff_printf(file_name, sizeof(file_name), "piece_d%ldr%ldp%ld_%s_%s", dest_id, round_id, piece_id, buff1, buff2))) {
LOG_WARN("failed to assign piece inner placeholder file path", K(ret), K(dest), K(dest_id),
K(round_id), K(piece_id), K(start_scn), K(end_scn), K(buff1), K(buff2));
} else if (OB_FAIL(path.join(file_name))) {
} else if (OB_FAIL(path.join(file_name, ObBackupFileSuffix::ARCHIVE))) {
LOG_WARN("failed to join file name", K(ret), K(path), K(file_name));
}
return ret;
@ -258,7 +258,7 @@ int ObArchivePathUtil::get_piece_ls_dir_path(const ObBackupDest &dest, const int
LOG_WARN("failed to get piece dir path", K(ret), K(dest), K(round_id), K(dest_id), K(piece_id), K(ls_id));
} else if (OB_FAIL(databuff_printf(dir_name, sizeof(dir_name), "logstream_%ld", ls_id.id()))) {
LOG_WARN("failed to assign ls dir path", K(ret), K(dest), K(round_id), K(dest_id), K(piece_id), K(ls_id));
} else if (OB_FAIL(path.join(dir_name))) {
} else if (OB_FAIL(path.join(dir_name, ObBackupFileSuffix::NONE))) {
LOG_WARN("failed to join dir name", K(ret), K(path), K(dir_name));
}
return ret;
@ -271,7 +271,7 @@ int ObArchivePathUtil::get_single_ls_info_file_path(const ObBackupDest &dest, co
int ret = OB_SUCCESS;
if (OB_FAIL(get_piece_ls_dir_path(dest, dest_id, round_id, piece_id, ls_id, path))) {
LOG_WARN("failed to get piece dir path", K(ret), K(dest), K(round_id), K(dest_id), K(piece_id), K(ls_id));
} else if (OB_FAIL(path.join("ls_file_info"))) {
} else if (OB_FAIL(path.join("ls_file_info", ObBackupFileSuffix::ARCHIVE))) {
LOG_WARN("failed to join ls file info ", K(ret), K(path));
}
return ret;
@ -284,7 +284,7 @@ int ObArchivePathUtil::get_piece_info_file_path(const ObBackupDest &dest, const
int ret = OB_SUCCESS;
if (OB_FAIL(get_piece_dir_path(dest, dest_id, round_id, piece_id, path))) {
LOG_WARN("failed to get piece dir path", K(ret), K(dest), K(round_id), K(dest_id), K(piece_id));
} else if (OB_FAIL(path.join("piece_file_info"))) {
} else if (OB_FAIL(path.join("piece_file_info", ObBackupFileSuffix::ARCHIVE))) {
LOG_WARN("failed to join piece info file", K(ret), K(path));
}
return ret;
@ -297,7 +297,7 @@ int ObArchivePathUtil::get_tenant_archive_piece_infos_file_path(const ObBackupDe
int ret = OB_SUCCESS;
if (OB_FAIL(get_piece_dir_path(dest, dest_id, round_id, piece_id, path))) {
LOG_WARN("failed to get piece dir path", K(ret), K(dest), K(round_id), K(dest_id), K(piece_id));
} else if (OB_FAIL(path.join("tenant_archive_piece_infos"))) {
} else if (OB_FAIL(path.join("tenant_archive_piece_infos", ObBackupFileSuffix::ARCHIVE))) {
LOG_WARN("failed to join tenant_archive_piece_infos file", K(ret), K(path));
}
return ret;
@ -310,7 +310,7 @@ int ObArchivePathUtil::get_ls_archive_file_path(const ObBackupDest &dest, const
int ret = OB_SUCCESS;
if (OB_FAIL(get_piece_ls_dir_path(dest, dest_id, round_id, piece_id, ls_id, path))) {
LOG_WARN("failed to get piece dir path", K(ret), K(dest), K(round_id), K(dest_id), K(piece_id), K(ls_id), K(file_id));
} else if (OB_FAIL(path.join(file_id))) {
} else if (OB_FAIL(path.join(file_id, ObBackupFileSuffix::ARCHIVE))) {
LOG_WARN("failed to join file id", K(ret), K(path), K(file_id));
}
return ret;
@ -326,7 +326,7 @@ int ObArchivePathUtil::get_ls_meta_record_prefix(const ObBackupDest &dest, const
ObFixedLengthString<ObArchiveLSMetaType::MAX_TYPE_LEN> s(meta_type.get_type_str());
if (OB_FAIL(get_piece_ls_dir_path(dest, dest_id, round_id, piece_id, ls_id, prefix))) {
LOG_WARN("failed to get piece dir path", K(ret), K(dest), K(round_id), K(dest_id), K(piece_id), K(ls_id));
} else if (OB_FAIL(prefix.join(::obsys::ObStringUtil::str_to_lower(s.ptr())))) {
} else if (OB_FAIL(prefix.join(::obsys::ObStringUtil::str_to_lower(s.ptr()), ObBackupFileSuffix::NONE))) {
LOG_WARN("failed to join meta_type", K(ret), K(prefix));
}
return ret;
@ -341,7 +341,7 @@ int ObArchivePathUtil::get_ls_meta_record_path(const ObBackupDest &dest, const i
if (OB_FAIL(get_ls_meta_record_prefix(dest, dest_id, round_id, piece_id, ls_id, meta_type, path))) {
LOG_WARN("failed to get ls meta record perfix", K(ret), K(dest), K(round_id),
K(dest_id), K(piece_id), K(ls_id), K(meta_type));
} else if (OB_FAIL(path.join(file_id))) {
} else if (OB_FAIL(path.join(file_id, ObBackupFileSuffix::ARCHIVE))) {
LOG_WARN("failed to join file_id", K(ret), K(path));
}
return ret;

View File

@ -38,23 +38,23 @@ public:
// oss://archive/rounds
static int get_rounds_dir_path(const ObBackupDest &dest, ObBackupPath &rounds_path);
// oss://archive/rounds/round_d[dest_id]r[round_id]_start
// oss://archive/rounds/round_d[dest_id]r[round_id]_start.obarc
static int get_round_start_file_path(const ObBackupDest &dest, const int64_t dest_id,
const int64_t round_id, ObBackupPath &path);
// oss://archive/rounds/round_d[dest_id]r[round_id]_end
// oss://archive/rounds/round_d[dest_id]r[round_id]_end.obarc
static int get_round_end_file_path(const ObBackupDest &dest, const int64_t dest_id,
const int64_t round_id, ObBackupPath &path);
// oss://archive/pieces
static int get_pieces_dir_path(const ObBackupDest &dest, ObBackupPath &pieces_path);
// oss://archive/pieces/piece_d[dest_id]r[round_id]p[piece_id]_start_20220601T120000
// oss://archive/pieces/piece_d[dest_id]r[round_id]p[piece_id]_start_20220601T120000.obarc
static int get_piece_start_file_path(const ObBackupDest &dest, const int64_t dest_id,
const int64_t round_id, const int64_t piece_id, const SCN &start_scn,
ObBackupPath &path);
// oss://archive/pieces/piece_d[dest_id]r[round_id]p[piece_id]_end_20220601T120000
// oss://archive/pieces/piece_d[dest_id]r[round_id]p[piece_id]_end_20220601T120000.obarc
static int get_piece_end_file_path(const ObBackupDest &dest, const int64_t dest_id,
const int64_t round_id, const int64_t piece_id, const SCN &end_scn,
ObBackupPath &path);
@ -63,7 +63,7 @@ public:
static int get_piece_dir_path(const ObBackupDest &dest, const int64_t dest_id,
const int64_t round_id, const int64_t piece_id, ObBackupPath &path);
// oss://archive/piece_d[dest_id]r[round_id]p[piece_id]/single_piece_info
// oss://archive/piece_d[dest_id]r[round_id]p[piece_id]/single_piece_info.obarc
static int get_single_piece_file_path(const ObBackupDest &dest, const int64_t dest_id,
const int64_t round_id, const int64_t piece_id, ObBackupPath &path);
@ -71,11 +71,11 @@ public:
static int get_piece_checkpoint_dir_path(const ObBackupDest &dest, const int64_t dest_id,
const int64_t round_id, const int64_t piece_id, ObBackupPath &path);
// oss://archive/piece_d[dest_id]r[round_id]p[piece_id]/checkpoint/checkpoint_info_[file_id]
// oss://archive/piece_d[dest_id]r[round_id]p[piece_id]/checkpoint/checkpoint_info.[file_id].obarc
static int get_piece_checkpoint_file_path(const ObBackupDest &dest, const int64_t dest_id,
const int64_t round_id, const int64_t piece_id, const int64_t file_id, ObBackupPath &path);
// oss://archive/piece_d[dest_id]r[round_id]p[piece_id]/piece_d[dest_id]r[round_id]p[piece_id]_20220601T120000_20220602T120000
// oss://archive/piece_d[dest_id]r[round_id]p[piece_id]/piece_d[dest_id]r[round_id]p[piece_id]_20220601T120000_20220602T120000.obarc
static int get_piece_inner_placeholder_file_path(const ObBackupDest &dest, const int64_t dest_id,
const int64_t round_id, const int64_t piece_id, const SCN &start_scn,
const SCN &end_scn, ObBackupPath &path);
@ -84,19 +84,19 @@ public:
static int get_piece_ls_dir_path(const ObBackupDest &dest, const int64_t dest_id,
const int64_t round_id, const int64_t piece_id, const ObLSID &ls_id, ObBackupPath &path);
// oss://archive/piece_d[dest_id]r[round_id]p[piece_id]/logstream_[ls_id]/ls_file_info
// oss://archive/piece_d[dest_id]r[round_id]p[piece_id]/logstream_[ls_id]/ls_file_info.obarc
static int get_single_ls_info_file_path(const ObBackupDest &dest, const int64_t dest_id,
const int64_t round_id, const int64_t piece_id, const ObLSID &ls_id, ObBackupPath &path);
// oss://archive/piece_d[dest_id]r[round_id]p[piece_id]/piece_file_info
// oss://archive/piece_d[dest_id]r[round_id]p[piece_id]/piece_file_info.obarc
static int get_piece_info_file_path(const ObBackupDest &dest, const int64_t dest_id,
const int64_t round_id, const int64_t piece_id, ObBackupPath &path);
// oss://archive/piece_d[dest_id]r[round_id]p[piece_id]/tenant_archive_piece_infos
// oss://archive/piece_d[dest_id]r[round_id]p[piece_id]/tenant_archive_piece_infos.obarc
static int get_tenant_archive_piece_infos_file_path(const ObBackupDest &dest, const int64_t dest_id,
const int64_t round_id, const int64_t piece_id, ObBackupPath &path);
// oss://archive/piece_d[dest_id]r[round_id]p[piece_id]/logstream_[%ld]/[file_id]
// oss://archive/piece_d[dest_id]r[round_id]p[piece_id]/logstream_[%ld]/[file_id].obarc
static int get_ls_archive_file_path(const ObBackupDest &dest, const int64_t dest_id,
const int64_t round_id, const int64_t piece_id, const share::ObLSID &ls_id, const int64_t file_id, ObBackupPath &path);

View File

@ -461,7 +461,7 @@ int ObArchiveStore::write_round_start(const int64_t dest_id, const int64_t round
return ret;
}
// oss://archive/rounds/round_d[dest_id]r[round_id]_end
// oss://archive/rounds/round_d[dest_id]r[round_id]_end.obarc
int ObArchiveStore::is_round_end_file_exist(const int64_t dest_id, const int64_t round_id, bool &is_exist) const
{
int ret = OB_SUCCESS;
@ -620,7 +620,7 @@ int ObArchiveStore::get_all_rounds(const int64_t dest_id, ObIArray<ObRoundEndDes
return ret;
}
// oss://archive/pieces/piece_d[dest_id]r[round_id]p[piece_id]_start_20220601T120000
// oss://archive/pieces/piece_d[dest_id]r[round_id]p[piece_id]_start_20220601T120000.obarc
int ObArchiveStore::is_piece_start_file_exist(const int64_t dest_id, const int64_t round_id, const int64_t piece_id,
const SCN &create_scn, bool &is_exist) const
{
@ -676,7 +676,7 @@ int ObArchiveStore::write_piece_start(const int64_t dest_id, const int64_t round
return ret;
}
// oss://archive/pieces/piece_d[dest_id]r[round_id]p[piece_id]_end_20220601T120000
// oss://archive/pieces/piece_d[dest_id]r[round_id]p[piece_id]_end_20220601T120000.obarc
int ObArchiveStore::is_piece_end_file_exist(const int64_t dest_id, const int64_t round_id, const int64_t piece_id,
const SCN &create_scn, bool &is_exist) const
{
@ -763,7 +763,7 @@ int ObArchiveStore::get_piece_range(const int64_t dest_id, const int64_t round_i
return ret;
}
// oss://archive/d[dest_id]r[round_id]p[piece_id]/single_piece_info
// oss://archive/d[dest_id]r[round_id]p[piece_id]/single_piece_info.obarc
int ObArchiveStore::is_single_piece_file_exist(const int64_t dest_id, const int64_t round_id, const int64_t piece_id, bool &is_exist) const
{
int ret = OB_SUCCESS;
@ -815,7 +815,7 @@ int ObArchiveStore::write_single_piece(const int64_t dest_id, const int64_t roun
return ret;
}
// oss://archive/d[dest_id]r[round_id]p[piece_id]/checkpoint/checkpoint_info_[file_id]
// oss://archive/d[dest_id]r[round_id]p[piece_id]/checkpoint/checkpoint_info.[file_id].obarc
int ObArchiveStore::is_piece_checkpoint_file_exist(const int64_t dest_id, const int64_t round_id, const int64_t piece_id, const int64_t file_id, bool &is_exist) const
{
int ret = OB_SUCCESS;
@ -867,7 +867,7 @@ int ObArchiveStore::write_piece_checkpoint(const int64_t dest_id, const int64_t
return ret;
}
// oss://archive/d[dest_id]r[round_id]p[piece_id]/piece_d[dest_id]r[round_id]p[piece_id]_20220601T120000_20220602T120000
// oss://archive/d[dest_id]r[round_id]p[piece_id]/piece_d[dest_id]r[round_id]p[piece_id]_20220601T120000_20220602T120000.obarc
int ObArchiveStore::is_piece_inner_placeholder_file_exist(const int64_t dest_id, const int64_t round_id, const int64_t piece_id, const SCN &start_scn,
const SCN &end_scn, bool &is_exist) const
{
@ -920,7 +920,7 @@ int ObArchiveStore::write_piece_inner_placeholder(const int64_t dest_id, const i
return ret;
}
// oss://archive/d[dest_id]r[round_id]p[piece_id]/[ls_id]/ls_file_info
// oss://archive/d[dest_id]r[round_id]p[piece_id]/[ls_id]/ls_file_info.obarc
int ObArchiveStore::is_single_ls_info_file_exist(const int64_t dest_id, const int64_t round_id, const int64_t piece_id,
const ObLSID &ls_id, bool &is_exist) const
{
@ -973,7 +973,7 @@ int ObArchiveStore::write_single_ls_info(const int64_t dest_id, const int64_t ro
return ret;
}
// oss://archive/d[dest_id]r[round_id]p[piece_id]/piece_file_info
// oss://archive/d[dest_id]r[round_id]p[piece_id]/piece_file_info.obarc
int ObArchiveStore::is_piece_info_file_exist(const int64_t dest_id, const int64_t round_id, const int64_t piece_id, bool &is_exist) const
{
int ret = OB_SUCCESS;
@ -1456,14 +1456,18 @@ static int parse_piece_file_(ObString &dir_name, int64_t &dest_id, int64_t &roun
static int is_piece_start_file_name_(ObString &file_name, bool &is_piece_start)
{
// parse file name like 'piece_d[dest_id]r[round_id]p[piece_id]_start_20220601T120000'
// parse file name like 'piece_d[dest_id]r[round_id]p[piece_id]_start_20220601T120000.obarc'
int ret = OB_SUCCESS;
char tmp_str[OB_MAX_BACKUP_DEST_LENGTH] = { 0 };
is_piece_start = false;
int32_t len = file_name.length() - strlen(OB_ARCHIVE_SUFFIX);
if (file_name.empty()) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("empty file name", K(ret), K(file_name));
} else if (OB_FAIL(databuff_printf(tmp_str, sizeof(tmp_str), "%.*s", static_cast<int>(file_name.length()), file_name.ptr()))) {
} else if (len <= 0) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("file name without a unified suffix", K(ret), K(file_name.length()), K(len));
} else if (OB_FAIL(databuff_printf(tmp_str, sizeof(tmp_str), "%.*s", len, file_name.ptr()))) {
LOG_WARN("fail to save tmp file name", K(ret), K(file_name));
} else {
const char *PREFIX = "piece";
@ -1562,11 +1566,15 @@ static int is_round_start_file_name_(ObString &file_name, bool &is_round_start)
int ret = OB_SUCCESS;
const char *PREFIX = "round_";
const char *SUFFIX = "_start";
int64_t p = file_name.length() - strlen(SUFFIX);
int64_t suffix_len = strlen(SUFFIX) + strlen(OB_ARCHIVE_SUFFIX);
int64_t p = file_name.length() - suffix_len;
ObString tmp;
if (!file_name.prefix_match(PREFIX)) {
if (p <= 0) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("file name without a unified suffix", K(ret), K(p));
} else if (!file_name.prefix_match(PREFIX)) {
is_round_start = false;
} else if (file_name.length() < strlen(SUFFIX)) {
} else if (file_name.length() < suffix_len) {
is_round_start = false;
} else if (OB_FALSE_IT(tmp.assign(file_name.ptr() + p, strlen(SUFFIX)))) {
} else if (!tmp.prefix_match(SUFFIX)) {
@ -1830,12 +1838,22 @@ int ObArchiveStore::ObPieceFileListFilter::init(ObArchiveStore *store)
int ObArchiveStore::ObPieceFileListFilter::func(const dirent *entry)
{
int ret = OB_SUCCESS;
ObString file_name(entry->d_name);
char file_name[OB_MAX_BACKUP_DEST_LENGTH] = { 0 };
int64_t file_id = -1;
int32_t len = 0;
if (IS_NOT_INIT) {
ret = OB_NOT_INIT;
LOG_WARN("ObPieceFileListFilter not init", K(ret));
} else if (1 != sscanf(file_name.ptr(), "%ld", &file_id)) {
} else if (OB_ISNULL(entry)) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid entry", K(ret));
} else if (FALSE_IT(len = strlen(entry->d_name) - strlen(OB_ARCHIVE_SUFFIX))) {
} else if (len <= 0) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("file name without a unified suffix", K(ret), K(entry->d_name), K(OB_ARCHIVE_SUFFIX));
} else if (OB_FAIL(databuff_printf(file_name, sizeof(file_name), "%.*s", len, entry->d_name))) {
LOG_WARN("fail to save tmp file name", K(ret), K(file_name));
} else if (OB_FAIL(ob_atoll(file_name, file_id))) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid archive file name", K(file_name));
} else if (OB_FAIL(files_.push_back(file_id))) {
@ -1875,13 +1893,18 @@ int ObArchiveStore::ObLSFileListOp::func(const dirent *entry)
ObString file_name;
ObSingleLSInfoDesc::OneFile one_file;
char *endptr = NULL;
int64 len = 0;
if (IS_NOT_INIT) {
ret = OB_NOT_INIT;
LOG_WARN("ObLSFileListOp not init", K(ret));
} else if (OB_ISNULL(entry)) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid entry", K(ret));
} else if (OB_FALSE_IT(file_name.assign_ptr(entry->d_name, strlen(entry->d_name)))) {
} else if (FALSE_IT(len = strlen(entry->d_name) - strlen(OB_ARCHIVE_SUFFIX))) {
} else if (len <= 0) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("file name without a unified suffix", K(ret), K(entry->d_name), K(OB_ARCHIVE_SUFFIX));
} else if (OB_FALSE_IT(file_name.assign_ptr(entry->d_name, len))) {
} else if (OB_FAIL(ob_atoll(file_name.ptr(), one_file.file_id_))) {
OB_LOG(WARN, "ignore invalid file name", K(ret), K(file_name));
ret = OB_SUCCESS;

View File

@ -356,7 +356,7 @@ public:
int read_single_piece(const int64_t dest_id, const int64_t round_id, const int64_t piece_id, ObSinglePieceDesc &desc) const;
int write_single_piece(const int64_t dest_id, const int64_t round_id, const int64_t piece_id, const ObSinglePieceDesc &desc) const;
// oss://archive/d[dest_id]r[round_id]p[piece_id]/checkpoint/checkpoint_info_[file_id]
// oss://archive/d[dest_id]r[round_id]p[piece_id]/checkpoint/checkpoint_info.[file_id]
int is_piece_checkpoint_file_exist(const int64_t dest_id, const int64_t round_id, const int64_t piece_id, const int64_t file_id, bool &is_exist) const;
int read_piece_checkpoint(const int64_t dest_id, const int64_t round_id, const int64_t piece_id, const int64_t file_id, ObPieceCheckpointDesc &desc) const;
int write_piece_checkpoint(const int64_t dest_id, const int64_t round_id, const int64_t piece_id, const int64_t file_id, const ObPieceCheckpointDesc &desc) const;

View File

@ -32,7 +32,7 @@ int ObBackupCleanFileOp::func(const dirent *entry)
LOG_WARN("invalid list entry, d_name is null");
} else if (OB_FAIL(tmp_path.init(path_.get_ptr()))) {
LOG_WARN("failed to init tmp_path", K(ret), K(path_));
} else if (OB_FAIL(tmp_path.join(entry->d_name))) {
} else if (OB_FAIL(tmp_path.join(entry->d_name, ObBackupFileSuffix::NONE))) {
LOG_WARN("failed to join file name", K(ret), K(entry->d_name));
} else if (OB_FAIL(util.del_file(tmp_path.get_ptr(), storage_info_))) {
// File does not exist should be considered successful
@ -99,7 +99,7 @@ int ObBackupPrefixDeleteFileOp::func(const dirent *entry)
// do nothing
} else if (OB_FAIL(tmp_path.init(path_.get_ptr()))) {
LOG_WARN("failed to init tmp_path", K(ret), K(path_));
} else if (OB_FAIL(tmp_path.join(entry->d_name))) {
} else if (OB_FAIL(tmp_path.join(entry->d_name, ObBackupFileSuffix::NONE))) {
LOG_WARN("failed to join file name", K(ret));
} else if (OB_FAIL(util.del_file(tmp_path.get_ptr(), storage_info_))) {
// File does not exist should be considered successful

View File

@ -179,7 +179,7 @@ int ObBackupConnectivityCheckManager::set_connectivity_check_path_(
} else if (OB_FAIL(ObBackupStorageInfoOperator::get_check_file_name(
*sql_proxy_, tenant_id_, backup_dest, check_file_name))) {
LOG_WARN("failed to get check file name", K(ret), K_(tenant_id));
} else if (OB_FAIL(path.join(check_file_name))) {
} else if (OB_FAIL(path.join(check_file_name, ObBackupFileSuffix::BACKUP))) {
LOG_WARN("failed to join check file name", K(ret), K_(tenant_id));
}
return ret;
@ -257,7 +257,7 @@ int ObBackupCheckFile::get_check_file_path(
LOG_WARN("backup dest is valid", K(ret), K_(tenant_id));
} else if (OB_FAIL(path.init(backup_dest.get_root_path()))) {
LOG_WARN("failed to init path", K(ret));
} else if (OB_FAIL(path.join(OB_STR_BACKUP_CHECK_FILE))) {
} else if (OB_FAIL(path.join(OB_STR_BACKUP_CHECK_FILE, ObBackupFileSuffix::NONE))) {
LOG_WARN("failed to join check_file", K(ret));
}
return ret;
@ -266,11 +266,16 @@ int ObBackupCheckFile::get_check_file_path(
int ObBackupCheckFile::set_connectivity_check_name_()
{
int ret = OB_SUCCESS;
int64_t check_time_s = ObTimeUtility::current_time() / 1000 / 1000;
char buff[OB_BACKUP_MAX_TIME_STR_LEN] = { 0 };
int64_t pos = 0;
if (!is_inited_) {
ret = OB_NOT_INIT;
LOG_WARN("backup check file not init", K(ret));
} else if (OB_FAIL(backup_time_to_strftime(check_time_s, buff, sizeof(buff), pos, 'T'/* concat */))) {
LOG_WARN("failed to convert time", K(ret));
} else if (OB_FAIL(databuff_printf(connectivity_file_name_, sizeof(connectivity_file_name_),
"%lu_%s_%s_%ld", tenant_id_, "connect", "file", ObTimeUtility::current_time()))) {
"%lu_%s_%s_%s", tenant_id_, "connect", "file", buff))) {
LOG_WARN("failed to set connectivity file name", K(ret));
}
return ret;
@ -406,7 +411,7 @@ int ObBackupCheckFile::create_connectivity_check_file(
} else if (false == is_match) {
if (OB_FAIL(set_connectivity_check_name_())) {
LOG_WARN("failed to set check file name", K(ret), K_(tenant_id));
} else if (OB_FAIL(path.join(connectivity_file_name_))) {
} else if (OB_FAIL(path.join(connectivity_file_name_, ObBackupFileSuffix::BACKUP))) {
LOG_WARN("failed to join connectivity file name", K(ret), K_(tenant_id));
} else if (OB_FAIL(generate_format_desc_(backup_dest, check_desc))) {
LOG_WARN("failed to set buffer", K(ret), K_(tenant_id));
@ -477,15 +482,20 @@ int ObBackupCheckFile::get_permission_check_file_path_(
share::ObBackupPath &path)
{
int ret = OB_SUCCESS;
int64_t check_time_s = ObTimeUtility::current_time() / 1000/ 1000;
char buff[OB_BACKUP_MAX_TIME_STR_LEN] = { 0 };
int64_t pos = 0;
if (!is_inited_) {
ret = OB_NOT_INIT;
LOG_WARN("backup check file not init", K(ret));
} else if (OB_FAIL(get_check_file_path(backup_dest, path))) {
LOG_WARN("failed to get check file path", K(ret), K(backup_dest));
} else if (OB_FAIL(backup_time_to_strftime(check_time_s, buff, sizeof(buff), pos, 'T'/* concat */))) {
LOG_WARN("failed to convert time", K(ret), K(backup_dest));
} else if (OB_FAIL(databuff_printf(permission_file_name_, sizeof(permission_file_name_),
"%lu_%s_%s_%ld", tenant_id_, "permission", "file", ObTimeUtility::current_time()))) {
"%lu_%s_%s_%s", tenant_id_, "permission", "file", buff))) {
LOG_WARN("failed to set permission file name", K(ret));
} else if (OB_FAIL(path.join(permission_file_name_))) {
} else if (OB_FAIL(path.join(permission_file_name_, ObBackupFileSuffix::BACKUP))) {
LOG_WARN("failed to join permission file name", K(ret), K_(permission_file_name));
}
return ret;

View File

@ -86,7 +86,39 @@ int ObBackupPath::join_incarnation(const uint64_t incarnation)
return ret;
}
int ObBackupPath::join(const common::ObString &str_path)
int ObBackupPath::add_backup_suffix(const ObBackupFileSuffix &type)
{
int ret = OB_SUCCESS;
if (cur_pos_ <= 0) {
ret = OB_NOT_INIT;
LOG_WARN("not inited", K(ret), K(*this));
} else {
switch (type) {
case ARCHIVE: {
if (OB_FAIL(databuff_printf(path_, sizeof(path_), cur_pos_, "%s", OB_ARCHIVE_SUFFIX))) {
LOG_WARN("failed to add archive suffix", K(ret));
}
break;
}
case BACKUP: {
if (OB_FAIL(databuff_printf(path_, sizeof(path_), cur_pos_, "%s", OB_BACKUP_SUFFIX))) {
LOG_WARN("failed to add backup suffix", K(ret));
}
break;
}
case NONE: {
break;
}
default: {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("unknow backup file suffix type", K(ret), K(type));
}
}
}
return ret;
}
int ObBackupPath::join(const common::ObString &str_path, const ObBackupFileSuffix &type)
{
int ret = OB_SUCCESS;
@ -99,6 +131,8 @@ int ObBackupPath::join(const common::ObString &str_path)
} else if (OB_FAIL(databuff_printf(path_, sizeof(path_), cur_pos_,
"/%.*s", str_path.length(), str_path.ptr()))) {
LOG_WARN("failed to join path", K(ret), K(str_path), K(*this));
} else if (OB_FAIL(add_backup_suffix(type))) {
LOG_WARN("failed to add backup file suffix", K(ret), K(type), K(*this));
} else if (OB_FAIL(trim_right_backslash())) {
OB_LOG(WARN, "fail to trim_right_backslash", K(ret));
}
@ -106,7 +140,7 @@ int ObBackupPath::join(const common::ObString &str_path)
}
int ObBackupPath::join(const uint64_t int_path)
int ObBackupPath::join(const uint64_t int_path, const ObBackupFileSuffix &type)
{
int ret = OB_SUCCESS;
@ -116,13 +150,15 @@ int ObBackupPath::join(const uint64_t int_path)
} else if (OB_FAIL(databuff_printf(path_, sizeof(path_), cur_pos_,
"/%lu", int_path))) {
LOG_WARN("failed to join int path", K(ret), K(int_path), K(*this));
} else if (OB_FAIL(add_backup_suffix(type))) {
LOG_WARN("failed to add backup file suffix", K(ret), K(type), K(*this));
} else if (OB_FAIL(trim_right_backslash())) {
OB_LOG(WARN, "fail to trim_right_backslash", K(ret));
}
return ret;
}
int ObBackupPath::join(const int64_t v)
int ObBackupPath::join(const int64_t v, const ObBackupFileSuffix &type)
{
int ret = OB_SUCCESS;
@ -134,6 +170,8 @@ int ObBackupPath::join(const int64_t v)
LOG_WARN("invalid argument", KR(ret), K(v));
} else if (OB_FAIL(databuff_printf(path_, sizeof(path_), cur_pos_, "/%ld", v))) {
LOG_WARN("failed to databuff_printf", KR(ret), K(*this));
} else if (OB_FAIL(add_backup_suffix(type))) {
LOG_WARN("failed to add backup file suffix", K(ret), K(type), K(*this));
} else if (OB_FAIL(trim_right_backslash())) {
LOG_WARN("fail to trim_right_backslash", K(ret));
} else {/*do nothing*/}
@ -273,12 +311,14 @@ int ObBackupPath::join_macro_data_dir(
int ObBackupPath::join_macro_data_file(const int64_t file_id)
{
int ret = OB_SUCCESS;
char file_name[OB_MAX_BACKUP_PATH_LENGTH] = { 0 };
if (cur_pos_ <= 0) {
ret = OB_NOT_INIT;
LOG_WARN("not inited", K(ret), K(*this));
} else if (OB_FAIL(
databuff_printf(path_, sizeof(path_), cur_pos_, "/%s.%ld", OB_STR_BACKUP_MACRO_BLOCK_DATA, file_id))) {
} else if (OB_FAIL(databuff_printf(file_name, sizeof(file_name), "%s.%ld", OB_STR_BACKUP_MACRO_BLOCK_DATA, file_id))) {
LOG_WARN("failed to join macro block data file", K(ret), K(file_id), K(*this));
} else if (OB_FAIL(join(file_name, ObBackupFileSuffix::BACKUP))) {
LOG_WARN("failed to join file_name", K(ret), K(file_name));
} else if (OB_FAIL(trim_right_backslash())) {
LOG_WARN("failed to trim right backslash", K(ret));
}
@ -328,19 +368,20 @@ int ObBackupPath::join_tenant_macro_range_index_file(const ObBackupDataType &bac
} else {
backup_data_type = OB_STR_SYS_BACKUP;
}
char file_name[OB_MAX_BACKUP_PATH_LENGTH] = { 0 };
if (cur_pos_ <= 0) {
ret = OB_NOT_INIT;
LOG_WARN("not init", K(ret), K(*this));
} else if (OB_FAIL(databuff_printf(path_,
sizeof(path_),
cur_pos_,
"/%s_%s_%s.%ld",
} else if (OB_FAIL(databuff_printf(file_name,
sizeof(file_name),
"%s_%s_%s.%ld",
OB_STR_TENANT,
backup_data_type,
OB_STR_BACKUP_MACRO_RANGE_INDEX,
retry_id))) {
LOG_WARN("failed to join macro range index file", K(ret), K(backup_type), K(*this));
} else if (OB_FAIL(join(file_name, ObBackupFileSuffix::BACKUP))) {
LOG_WARN("failed to join file_name", K(ret), K(file_name));
} else if (OB_FAIL(trim_right_backslash())) {
LOG_WARN("failed to trim right backslash", K(ret));
}
@ -364,14 +405,16 @@ int ObBackupPath::join_tenant_meta_index_file(const ObBackupDataType &backup_typ
// meta_index corresponds to tablet meta index and sstable meta index
// sec_meta_index corresponds to macro block id mapping meta index, which will be removed later
const char *meta_file_name = is_sec_meta ? OB_STR_BACKUP_SEC_META_INDEX : OB_STR_BACKUP_META_INDEX;
char file_name[OB_MAX_BACKUP_PATH_LENGTH] = { 0 };
if (cur_pos_ <= 0) {
ret = OB_NOT_INIT;
LOG_WARN("not init", K(ret), K(*this));
} else if (OB_FAIL(databuff_printf(
path_, sizeof(path_), cur_pos_, "/%s_%s_%s.%ld",
file_name, sizeof(file_name), "%s_%s_%s.%ld",
OB_STR_TENANT, backup_data_type, meta_file_name, retry_id))) {
LOG_WARN("failed to join tenant meta index file", K(ret), K(backup_type), K(*this));
} else if (OB_FAIL(join(file_name, ObBackupFileSuffix::BACKUP))) {
LOG_WARN("failed to join file_name", K(ret), K(file_name));
} else if (OB_FAIL(trim_right_backslash())) {
LOG_WARN("failed to trim right backslash", K(ret));
}
@ -429,7 +472,7 @@ int ObBackupPathUtil::get_tenant_data_backup_set_placeholder_path_(
} else if (OB_FAIL(databuff_printf(backup_set_placeholder_name, sizeof(backup_set_placeholder_name),
"backup_set_%lu_%s_%s_%s", backup_set_id, backup_type_str, suffix.ptr(), min_restore_ts_buff))) {
LOG_WARN("failed to format backup set placeholder name", K(ret), K(path));
} else if (OB_FAIL(path.join(backup_set_placeholder_name))) {
} else if (OB_FAIL(path.join(backup_set_placeholder_name, ObBackupFileSuffix::BACKUP))) {
LOG_WARN("failed to backup set placeholder name", K(ret), K(backup_set_placeholder_name));
}
return ret;
@ -443,13 +486,13 @@ int ObBackupPathUtil::get_backup_sets_dir_path(const share::ObBackupDest &backup
path.reset();
if (OB_FAIL(path.init(backup_tenant_dest.get_root_path()))) {
LOG_WARN("failed to init path", K(ret));
} else if (OB_FAIL(path.join(OB_STR_BACKUP_SETS))) {
} else if (OB_FAIL(path.join(OB_STR_BACKUP_SETS, ObBackupFileSuffix::NONE))) {
LOG_WARN("failed to join backup set", K(ret), K(backup_tenant_dest));
}
return ret;
}
// file:///backup/backup_sets/backup_set_xx_xxx_start
// file:///backup/backup_sets/backup_set_xx_xxx_start.obbak
int ObBackupPathUtil::get_backup_set_placeholder_start_path(
const share::ObBackupDest &backup_tenant_dest, const share::ObBackupSetDesc &backup_set_desc, share::ObBackupPath &backup_path)
{
@ -463,7 +506,7 @@ int ObBackupPathUtil::get_backup_set_placeholder_start_path(
} else if (!backup_set_desc.backup_type_.is_full_backup()
&& OB_FAIL(databuff_printf(backup_set_name, sizeof(backup_set_name), "backup_set_%lu_inc_start", backup_set_desc.backup_set_id_))) {
LOG_WARN("failed to format backup set name", K(ret), K(backup_tenant_dest));
} else if (OB_FAIL(backup_path.join(backup_set_name))) {
} else if (OB_FAIL(backup_path.join(backup_set_name, ObBackupFileSuffix::BACKUP))) {
LOG_WARN("fail to join backup set name", K(ret), K(backup_set_name));
}
return ret;
@ -542,7 +585,7 @@ int ObBackupPathUtil::get_backup_set_inner_placeholder_prefix(
return ret;
}
// file:///obbackup/backup_set_1_full/backup_set_1_full_xxxx_xxxxx
// file:///obbackup/backup_set_1_full/backup_set_1_full_xxxx_xxxxx.obbak
int ObBackupPathUtil::get_backup_set_inner_placeholder(
const share::ObBackupDest &backup_set_dest, const share::ObBackupSetDesc &backup_set_desc,
const SCN &replay_scn, const SCN &min_restore_scn,
@ -564,7 +607,7 @@ int ObBackupPathUtil::get_backup_set_inner_placeholder(
} else if (OB_FAIL(databuff_printf(backup_set_placeholder_name, sizeof(backup_set_placeholder_name),
"backup_set_%lu_%s_%s_%s", backup_set_desc.backup_set_id_, backup_type_str, log_replay_ts_buff, min_restore_ts_buff))) {
LOG_WARN("failed to format backup set placeholder name", K(ret), K(backup_set_dest));
} else if (OB_FAIL(backup_path.join(backup_set_placeholder_name))) {
} else if (OB_FAIL(backup_path.join(backup_set_placeholder_name, ObBackupFileSuffix::BACKUP))) {
LOG_WARN("failed to backup set placeholder name", K(ret), K(backup_set_placeholder_name));
}
return ret;
@ -595,7 +638,7 @@ int ObBackupPathUtil::get_ls_backup_dir_path(const share::ObBackupDest &backup_s
return ret;
}
// file:///obbackup/backup_set_1_full_20211231/log_stream_1/meta_info_turn_1/tablet_info
// file:///obbackup/backup_set_1_full_20211231/log_stream_1/meta_info_turn_1/tablet_info.obbak
int ObBackupPathUtil::get_ls_data_tablet_info_path(const share::ObBackupDest &backup_set_dest,
const share::ObLSID &ls_id, const int64_t turn_id, const int64_t retry_id, ObBackupPath &path)
{
@ -604,7 +647,7 @@ int ObBackupPathUtil::get_ls_data_tablet_info_path(const share::ObBackupDest &ba
LOG_WARN("failed to get ls info dir path", K(ret), K(backup_set_dest));
} else if (OB_FAIL(path.join_meta_info_turn_and_retry(turn_id, retry_id))) {
LOG_WARN("failed to join info retry", K(ret), K(retry_id));
} else if (OB_FAIL(path.join(OB_STR_TABLET_INFO))) {
} else if (OB_FAIL(path.join(OB_STR_TABLET_INFO, ObBackupFileSuffix::BACKUP))) {
LOG_WARN("failed to join", K(ret));
}
return ret;
@ -641,7 +684,7 @@ int ObBackupPathUtil::get_ls_backup_data_dir_path(const share::ObBackupDest &bac
return ret;
}
// file:///obbackup/backup_set_1_full_20211231/log_stream_1/major_data_turn_1_retry_0/macro_block_data.1
// file:///obbackup/backup_set_1_full_20211231/log_stream_1/major_data_turn_1_retry_0/macro_block_data.1.obbak
int ObBackupPathUtil::get_macro_block_backup_path(const share::ObBackupDest &backup_set_dest,
const share::ObLSID &ls_id, const ObBackupDataType &backup_data_type,
const int64_t turn_id, const int64_t retry_id, const int64_t file_id, ObBackupPath &path)
@ -674,7 +717,7 @@ int ObBackupPathUtil::get_macro_block_backup_path(const share::ObBackupDest &bac
return ret;
}
// file:///obbackup/backup_set_1_full_20211231/log_stream_1/major_data_turn_1_retry_0/macro_range_index
// file:///obbackup/backup_set_1_full_20211231/log_stream_1/major_data_turn_1_retry_0/macro_range_index.obbak
int ObBackupPathUtil::get_ls_macro_range_index_backup_path(const share::ObBackupDest &backup_set_dest,
const share::ObLSID &ls_id, const ObBackupDataType &backup_data_type, const int64_t turn_id,
const int64_t retry_id, ObBackupPath &path)
@ -686,7 +729,7 @@ int ObBackupPathUtil::get_ls_macro_range_index_backup_path(const share::ObBackup
K(ret),
K(backup_set_dest),
K(ls_id));
} else if (OB_FAIL(path.join(OB_STR_BACKUP_MACRO_RANGE_INDEX))) {
} else if (OB_FAIL(path.join(OB_STR_BACKUP_MACRO_RANGE_INDEX, ObBackupFileSuffix::BACKUP))) {
LOG_WARN("failed to join macro range index", K(ret));
}
return ret;
@ -707,7 +750,7 @@ int ObBackupPathUtil::get_ls_macro_range_index_backup_path(const share::ObBackup
return ret;
}
// file:///obbackup/backup_set_1_full_20211231/log_stream_1/major_data_turn_1_retry_0/meta_index
// file:///obbackup/backup_set_1_full_20211231/log_stream_1/major_data_turn_1_retry_0/meta_index.obbak
int ObBackupPathUtil::get_ls_meta_index_backup_path(const share::ObBackupDest &backup_set_dest,
const share::ObLSID &ls_id, const ObBackupDataType &backup_data_type,
const int64_t turn_id, const int64_t retry_id, const bool is_sec_meta, ObBackupPath &path)
@ -720,7 +763,7 @@ int ObBackupPathUtil::get_ls_meta_index_backup_path(const share::ObBackupDest &b
K(ret),
K(backup_set_dest),
K(ls_id));
} else if (OB_FAIL(path.join(meta_file_name))) {
} else if (OB_FAIL(path.join(meta_file_name, ObBackupFileSuffix::BACKUP))) {
LOG_WARN("failed to join macro range index", K(ret));
}
return ret;
@ -747,7 +790,7 @@ int ObBackupPathUtil::get_ls_info_dir_path(const share::ObBackupDest &backup_set
int ret = OB_SUCCESS;
if (OB_FAIL(get_backup_set_dir_path(backup_set_dest, backup_path))) {
LOG_WARN("failed to get backup set dir path", K(ret), K(backup_set_dest));
} else if (OB_FAIL(backup_path.join(ObString::make_string("infos")))) {
} else if (OB_FAIL(backup_path.join(ObString::make_string("infos"), ObBackupFileSuffix::NONE))) {
LOG_WARN("failed to join data", K(ret));
}
return ret;
@ -774,7 +817,7 @@ int ObBackupPathUtil::get_ls_info_data_info_dir_path(const share::ObBackupDest &
int ret = OB_SUCCESS;
if (OB_FAIL(get_backup_set_dir_path(backup_set_dest, backup_path))) {
LOG_WARN("failed to get backup set dir path", K(ret), K(backup_set_dest));
} else if (OB_FAIL(backup_path.join(ObString::make_string("infos")))) {
} else if (OB_FAIL(backup_path.join(ObString::make_string("infos"), ObBackupFileSuffix::NONE))) {
LOG_WARN("failed to join data", K(ret));
} else if (OB_FAIL(backup_path.join_data_info_turn(turn_id))) {
LOG_WARN("failed to join info turn", K(ret));
@ -802,7 +845,7 @@ int ObBackupPathUtil::get_tenant_meta_info_dir_path(const share::ObBackupDest &b
int ret = OB_SUCCESS;
if (OB_FAIL(get_ls_info_dir_path(backup_set_dest, backup_path))) {
LOG_WARN("failed to get backup set dir path", K(ret), K(backup_set_dest));
} else if (OB_FAIL(backup_path.join(OB_STR_META_INFO))) {
} else if (OB_FAIL(backup_path.join(OB_STR_META_INFO, ObBackupFileSuffix::NONE))) {
LOG_WARN("failed to join data", K(ret));
}
return ret;
@ -821,7 +864,7 @@ int ObBackupPathUtil::get_tenant_meta_info_dir_path(const share::ObBackupDest &b
return ret;
}
// file:///obbackup/backup_set_1_full/infos/meta_info/ls_attr_info_turn_1
// file:///obbackup/backup_set_1_full/infos/meta_info/ls_attr_info.1.obbak
int ObBackupPathUtil::get_backup_ls_attr_info_path(const share::ObBackupDest &backup_set_dest,
const int64_t turn_id, ObBackupPath &backup_path)
{
@ -829,34 +872,34 @@ int ObBackupPathUtil::get_backup_ls_attr_info_path(const share::ObBackupDest &ba
char buf[OB_BACKUP_MAX_TIME_STR_LEN] = { 0 };
if (OB_FAIL(get_tenant_meta_info_dir_path(backup_set_dest, backup_path))) {
LOG_WARN("failed to get backup set dir path", K(ret), K(backup_set_dest));
} else if (OB_FAIL(databuff_printf(buf, OB_BACKUP_MAX_TIME_STR_LEN, "%s_%ld", OB_STR_LS_ATTR_INFO, turn_id))) {
} else if (OB_FAIL(databuff_printf(buf, OB_BACKUP_MAX_TIME_STR_LEN, "%s.%ld", OB_STR_LS_ATTR_INFO, turn_id))) {
LOG_WARN("failed to printf ls attr info", K(ret));
} else if (OB_FAIL(backup_path.join(buf))) {
} else if (OB_FAIL(backup_path.join(buf, ObBackupFileSuffix::BACKUP))) {
LOG_WARN("failed to join ls attr info", K(ret));
}
return ret;
}
// file:///obbackup/backup_set_1_full/infos/meta_info/ls_meta_infos
// file:///obbackup/backup_set_1_full/infos/meta_info/ls_meta_infos.obbak
int ObBackupPathUtil::get_ls_meta_infos_path(const share::ObBackupDest &backup_set_dest, ObBackupPath &backup_path)
{
int ret = OB_SUCCESS;
if (OB_FAIL(get_tenant_meta_info_dir_path(backup_set_dest, backup_path))) {
LOG_WARN("failed to get backup set dir path", K(ret), K(backup_set_dest));
} else if (OB_FAIL(backup_path.join(OB_STR_LS_META_INFOS))) {
} else if (OB_FAIL(backup_path.join(OB_STR_LS_META_INFOS, ObBackupFileSuffix::BACKUP))) {
LOG_WARN("failed to join ls meta infos", K(ret));
}
return ret;
}
// file:///obbackup/backup_set_1_full_20211231/tenant_backup_set_infos
// file:///obbackup/backup_set_1_full_20211231/tenant_backup_set_infos.obbak
int ObBackupPathUtil::get_tenant_backup_set_infos_path(const share::ObBackupDest &backup_set_dest,
ObBackupPath &backup_path)
{
int ret = OB_SUCCESS;
if (OB_FAIL(get_backup_set_dir_path(backup_set_dest, backup_path))) {
LOG_WARN("failed to get backup set dir path", K(ret), K(backup_set_dest));
} else if (OB_FAIL(backup_path.join(OB_STR_TENANT_BACKUP_SET_INFOS))) {
} else if (OB_FAIL(backup_path.join(OB_STR_TENANT_BACKUP_SET_INFOS, ObBackupFileSuffix::BACKUP))) {
LOG_WARN("failed to join data", K(ret));
}
return ret;
@ -875,14 +918,14 @@ int ObBackupPathUtil::get_tenant_backup_set_infos_path(const share::ObBackupDest
return ret;
}
// file:///obbackup/backup_set_1_full_20211231/infos/backup_set_info
// file:///obbackup/backup_set_1_full_20211231/single_backup_set_info.obbak
int ObBackupPathUtil::get_backup_set_info_path(const share::ObBackupDest &backup_set_dest,
ObBackupPath &backup_path)
{
int ret = OB_SUCCESS;
if (OB_FAIL(get_backup_set_dir_path(backup_set_dest, backup_path))) {
LOG_WARN("failed to get backup set dir path", K(ret), K(backup_set_dest));
} else if (OB_FAIL(backup_path.join(OB_STR_SINGLE_BACKUP_SET_INFO))) {
} else if (OB_FAIL(backup_path.join(OB_STR_SINGLE_BACKUP_SET_INFO, ObBackupFileSuffix::BACKUP))) {
LOG_WARN("failed to join data", K(ret));
}
return ret;
@ -901,14 +944,14 @@ int ObBackupPathUtil::get_backup_set_info_path(const share::ObBackupDest &backup
return ret;
}
// file:///obbackup/backup_set_1_full_20211231/infos/diagnose_info
// file:///obbackup/backup_set_1_full_20211231/infos/diagnose_info.obbak
int ObBackupPathUtil::get_diagnose_info_path(const share::ObBackupDest &backup_set_dest,
ObBackupPath &backup_path)
{
int ret = OB_SUCCESS;
if (OB_FAIL(get_ls_info_dir_path(backup_set_dest, backup_path))) {
LOG_WARN("failed to get backup set dir path", K(ret), K(backup_set_dest));
} else if (OB_FAIL(backup_path.join(OB_STR_DIAGNOSE_INFO))) {
} else if (OB_FAIL(backup_path.join(OB_STR_DIAGNOSE_INFO, ObBackupFileSuffix::BACKUP))) {
LOG_WARN("failed to join data", K(ret));
}
return ret;
@ -927,14 +970,14 @@ int ObBackupPathUtil::get_diagnose_info_path(const share::ObBackupDest &backup_t
return ret;
}
// file:///obbackup/backup_set_1_full_20211231/infos/locality_info
// file:///obbackup/backup_set_1_full_20211231/infos/locality_info.obbak
int ObBackupPathUtil::get_locality_info_path(const share::ObBackupDest &backup_set_dest,
ObBackupPath &backup_path)
{
int ret = OB_SUCCESS;
if (OB_FAIL(get_ls_info_dir_path(backup_set_dest, backup_path))) {
LOG_WARN("failed to get backup set dir path", K(ret), K(backup_set_dest));
} else if (OB_FAIL(backup_path.join(OB_STR_LOCALITY_INFO))) {
} else if (OB_FAIL(backup_path.join(OB_STR_LOCALITY_INFO, ObBackupFileSuffix::BACKUP))) {
LOG_WARN("failed to join data", K(ret));
}
return ret;
@ -953,7 +996,7 @@ int ObBackupPathUtil::get_locality_info_path(const share::ObBackupDest &backup_t
return ret;
}
// file:///obbackup/backup_set_1_full_20211231/log_stream_1/info_retry_0/ls_meta_info
// file:///obbackup/backup_set_1_full_20211231/log_stream_1/meta_info_turn_1_retry_0/ls_meta_info.obbak
int ObBackupPathUtil::get_ls_meta_info_backup_path(const share::ObBackupDest &backup_tenant_dest,
const ObBackupSetDesc &desc, const share::ObLSID &ls_id, const int64_t turn_id,
const int64_t retry_id, ObBackupPath &backup_path)
@ -965,13 +1008,13 @@ int ObBackupPathUtil::get_ls_meta_info_backup_path(const share::ObBackupDest &ba
LOG_WARN("fail to join ls", K(ret), K(ls_id));
} else if (OB_FAIL(backup_path.join_meta_info_turn_and_retry(turn_id, retry_id))) {
LOG_WARN("failed to join info retry", K(ret), K(retry_id));
} else if (OB_FAIL(backup_path.join(OB_STR_LS_META_INFO))) {
} else if (OB_FAIL(backup_path.join(OB_STR_LS_META_INFO, ObBackupFileSuffix::BACKUP))) {
LOG_WARN("failed to join info turn", K(ret));
}
return ret;
}
// file:///obbackup/backup_set_1_full_20211231/infos/info_turn_1/tenant_macro_range_index.0
// file:///obbackup/backup_set_1_full_20211231/logstream_1/xxx_xxx_turn_1_retry_0/macro_range_index.obbak
int ObBackupPathUtil::get_tenant_macro_range_index_backup_path(const share::ObBackupDest &backup_set_dest,
const ObBackupDataType &backup_data_type, const int64_t turn_id, const int64_t retry_id, ObBackupPath &path)
{
@ -1001,7 +1044,7 @@ int ObBackupPathUtil::get_tenant_macro_range_index_backup_path(const share::ObBa
return ret;
}
// file:///obbackup/backup_set_1_full_20211231/infos/info_turn_1/tenant_meta_index
// file:///obbackup/backup_set_1_full_20211231/logstream_1/xxx_xxx_turn_1_retry_0/meta_index.obbak
int ObBackupPathUtil::get_tenant_meta_index_backup_path(const share::ObBackupDest &backup_set_dest,
const ObBackupDataType &backup_data_type, const int64_t turn_id, const int64_t retry_id,
const bool is_sec_meta, ObBackupPath &path)
@ -1032,7 +1075,7 @@ int ObBackupPathUtil::get_tenant_meta_index_backup_path(const share::ObBackupDes
return ret;
}
// file://obbackup/backup_set_1_full_20211231/infos/info_turn_1/tablet_log_stream_info
// file://obbackup/backup_set_1_full_20211231/infos/data_info_turn_1/tablet_log_stream_info.obbak
int ObBackupPathUtil::get_backup_data_tablet_ls_info_path(const share::ObBackupDest &backup_set_dest,
const uint64_t turn_id, ObBackupPath &path)
{
@ -1041,7 +1084,7 @@ int ObBackupPathUtil::get_backup_data_tablet_ls_info_path(const share::ObBackupD
LOG_WARN("failed to get ls info dir path", K(ret), K(backup_set_dest));
} else if (OB_FAIL(path.join_data_info_turn(turn_id))) {
LOG_WARN("failed to join info turn", K(ret));
} else if (OB_FAIL(path.join(OB_STR_TABLET_LOG_STREAM_INFO))) {
} else if (OB_FAIL(path.join(OB_STR_TABLET_LOG_STREAM_INFO, ObBackupFileSuffix::BACKUP))) {
LOG_WARN("failed to join tablet_log_stream_info", K(ret));
}
return ret;
@ -1054,7 +1097,7 @@ int ObBackupPathUtil::get_deleted_tablet_info_path(const share::ObBackupDest &ba
int ret = OB_SUCCESS;
if (OB_FAIL(get_ls_info_dir_path(backup_set_dest, path))) {
LOG_WARN("failed to get ls info dir path", K(ret), K(backup_set_dest));
} else if (OB_FAIL(path.join(OB_STR_DELETED_TABLET_INFO))) {
} else if (OB_FAIL(path.join(OB_STR_DELETED_TABLET_INFO, ObBackupFileSuffix::BACKUP))) {
LOG_WARN("failed to join tablet_log_stream_info", K(ret));
}
return ret;
@ -1095,7 +1138,7 @@ int ObBackupPathUtil::get_ls_complement_log_backup_path(const share::ObBackupDes
if (OB_FAIL(get_ls_complement_log_dir_path(backup_set_dest, ls_id, path))) {
LOG_WARN(
"failed to get ls complement log dir path", K(ret), K(backup_set_dest), K(ls_id));
} else if (OB_FAIL(path.join(file_id))) {
} else if (OB_FAIL(path.join(file_id, ObBackupFileSuffix::ARCHIVE))) {
LOG_WARN("failed to join file id", K(ret), K(file_id));
}
return ret;
@ -1126,7 +1169,7 @@ int ObBackupPathUtil::get_ls_log_archive_prefix(const share::ObBackupDest &backu
LOG_WARN("failed to init path", K(ret), K(backup_set_dest));
} else if (OB_FAIL(path.join_tenant_incarnation(tenant_id, incarnation))) {
LOG_WARN("failed to join tenant and incarnation", K(ret), K(tenant_id));
} else if (OB_FAIL(path.join(ObString::make_string(OB_STR_CLOG)))) {
} else if (OB_FAIL(path.join(ObString::make_string(OB_STR_CLOG), ObBackupFileSuffix::NONE))) {
LOG_WARN("failed to join clog", K(ret));
} else if (OB_FAIL(path.join_round_piece(round, piece_id))) {
LOG_WARN("failed to join round and piece", K(ret), K(round), K(piece_id));
@ -1144,7 +1187,7 @@ int ObBackupPathUtil::get_ls_log_archive_path(const share::ObBackupDest &backup_
int ret = OB_SUCCESS;
if (OB_FAIL(get_ls_log_archive_prefix(backup_set_dest, tenant_id, incarnation, round, piece_id, ls_id, path))) {
LOG_WARN("failed to get ls log archive prefix", K(ret));
} else if (OB_FAIL(path.join(file_id))) {
} else if (OB_FAIL(path.join(file_id, ObBackupFileSuffix::ARCHIVE))) {
LOG_WARN("failed to join file id", K(ret), K(file_id));
}
return ret;

View File

@ -20,6 +20,13 @@ namespace oceanbase
namespace share
{
enum ObBackupFileSuffix
{
NONE = 0, // files with suffix or dir
ARCHIVE = 1, // archive file
BACKUP = 2, // backup file
};
struct ObBackupPath final
{
public:
@ -30,9 +37,9 @@ public:
int init(const common::ObString &backup_root_path);
int join_incarnation(const uint64_t incarnation);
int join(const common::ObString &path);
int join(const uint64_t int_path);
int join(const int64_t v);
int join(const common::ObString &path, const ObBackupFileSuffix &type);
int join(const uint64_t int_path, const ObBackupFileSuffix &type);
int join(const int64_t v, const ObBackupFileSuffix &type);
bool is_empty() const { return 0 == cur_pos_; }
int join_tenant_incarnation(const uint64_t tenant_id, const int64_t incarnation);
@ -46,6 +53,7 @@ public:
int join_meta_info_turn_and_retry(const int64_t turn_id, const int64_t retry_id);
int join_tenant_macro_range_index_file(const share::ObBackupDataType &type, const int64_t retry_id);
int join_tenant_meta_index_file(const share::ObBackupDataType &type, const int64_t retry_id, const bool is_sec_meta);
int add_backup_suffix(const ObBackupFileSuffix &type);
const char *get_ptr() const { return path_; }
int64_t length() const { return cur_pos_; }
@ -67,16 +75,16 @@ struct ObBackupPathUtil
static int get_backup_sets_dir_path(const share::ObBackupDest &backup_tenant_dest,
share::ObBackupPath &path);
// file:///backup/backup_sets/backup_set_1_[full|inc]_start_20220601T120000
// file:///backup/backup_sets/backup_set_1_[full|inc]_start_20220601T120000.obbak
static int get_backup_set_placeholder_start_path(const share::ObBackupDest &backup_tenant_dest,
const share::ObBackupSetDesc &backup_set_desc, share::ObBackupPath &backup_path);
// file:///backup/backup_sets/backup_set_1_[full|inc]_end_success_20220601T120000
// file:///backup/backup_sets/backup_set_1_[full|inc]_end_success_20220601T120000.obbak
static int get_backup_set_placeholder_end_success_path(const share::ObBackupDest &backup_tenant_dest,
const share::ObBackupSetDesc &backup_set_desc,
const SCN &min_restore_scn, share::ObBackupPath &backup_path);
// file:///backup/backup_sets/backup_set_1_[full|inc]_end_failed_20220601T120000
// file:///backup/backup_sets/backup_set_1_[full|inc]_end_failed_20220601T120000.obbak
static int get_backup_set_placeholder_end_failed_path(const share::ObBackupDest &backup_tenant_dest,
const share::ObBackupSetDesc &backup_set_desc,
const SCN &min_restore_scn, share::ObBackupPath &backup_path);
@ -104,7 +112,7 @@ struct ObBackupPathUtil
static int get_ls_backup_dir_path(const share::ObBackupDest &backup_set_dest,
const share::ObBackupSetDesc &desc, const share::ObLSID &ls_id, share::ObBackupPath &backup_path);
// file:///obbackup/backup_set_1_full/log_stream_1/info_retry_0/tablet_info
// file:///obbackup/backup_set_1_full_20211231/log_stream_1/meta_info_turn_1/tablet_info.obbak
static int get_ls_data_tablet_info_path(const share::ObBackupDest &backup_set_dest,
const share::ObLSID &ls_id, const int64_t turn_id, const int64_t retry_id,
share::ObBackupPath &backup_path);
@ -118,7 +126,7 @@ struct ObBackupPathUtil
const share::ObBackupSetDesc &desc, const share::ObLSID &ls_id, const share::ObBackupDataType &backup_data_type,
const int64_t turn_id, const int64_t retry_id, share::ObBackupPath &backup_path);
// file:///obbackup/backup_set_1_full/log_stream_1/major_data_turn_1_retry_0/macro_block_data.1
// file:///obbackup/backup_set_1_full/log_stream_1/major_data_turn_1_retry_0/macro_block_data.1.obbak
static int get_macro_block_backup_path(const share::ObBackupDest &backup_set_dest,
const share::ObLSID &ls_id, const share::ObBackupDataType &backup_data_type,
const int64_t turn_id, const int64_t retry_id, const int64_t file_id, share::ObBackupPath &backup_path);
@ -127,7 +135,7 @@ struct ObBackupPathUtil
const share::ObBackupSetDesc &desc, const share::ObLSID &ls_id, const share::ObBackupDataType &backup_data_type,
const int64_t turn_id, const int64_t retry_id, const int64_t file_id, share::ObBackupPath &backup_path);
// file:///obbackup/backup_set_1_full/log_stream_1/major_data_turn_1_retry_0/macro_range_index
// file:///obbackup/backup_set_1_full/log_stream_1/major_data_turn_1_retry_0/macro_range_index.obbak
static int get_ls_macro_range_index_backup_path(const share::ObBackupDest &backup_set_dest,
const share::ObLSID &ls_id, const share::ObBackupDataType &backup_data_type,
const int64_t turn_id, const int64_t retry_id, share::ObBackupPath &backup_path);
@ -136,7 +144,7 @@ struct ObBackupPathUtil
const share::ObBackupSetDesc &desc, const share::ObLSID &ls_id, const share::ObBackupDataType &backup_data_type,
const int64_t turn_id, const int64_t retry_id, share::ObBackupPath &backup_path);
// file:///obbackup/backup_set_1_full/log_stream_1/major_data_turn_1_retry_0/meta_index
// file:///obbackup/backup_set_1_full/log_stream_1/major_data_turn_1_retry_0/meta_index.obbak
static int get_ls_meta_index_backup_path(const share::ObBackupDest &backup_set_dest,
const share::ObLSID &ls_id, const share::ObBackupDataType &backup_data_type,
const int64_t turn_id, const int64_t retry_id, const bool is_sec_meta, share::ObBackupPath &backup_path);
@ -166,50 +174,50 @@ struct ObBackupPathUtil
static int get_tenant_meta_info_dir_path(const share::ObBackupDest &backup_tenant_dest,
const share::ObBackupSetDesc &desc, share::ObBackupPath &backup_path);
// file:///obbackup/backup_set_1_full/infos/meta_info/ls_attr_info_turn_1
// file:///obbackup/backup_set_1_full/infos/meta_info/ls_attr_info.1.obbak
static int get_backup_ls_attr_info_path(const share::ObBackupDest &backup_set_dest,
const int64_t turn_id, share::ObBackupPath &backup_path);
static int get_backup_ls_attr_info_path(const share::ObBackupDest &backup_tenant_dest,
const share::ObBackupSetDesc &desc, const int64_t turn_id, share::ObBackupPath &backup_path);
// file:///obbackup/backup_set_1_full/infos/meta_info/ls_meta_infos
// file:///obbackup/backup_set_1_full/infos/meta_info/ls_meta_infos.obbak
static int get_ls_meta_infos_path(const share::ObBackupDest &backup_set_dest, share::ObBackupPath &backup_path);
// file:///obbackup/backup_set_1_full/tenant_backup_set_infos
// file:///obbackup/backup_set_1_full/tenant_backup_set_infos.obbak
static int get_tenant_backup_set_infos_path(const share::ObBackupDest &backup_set_dest,
share::ObBackupPath &backup_path);
static int get_tenant_backup_set_infos_path(const share::ObBackupDest &backup_tenant_dest,
const share::ObBackupSetDesc &desc, share::ObBackupPath &backup_path);
// file:///obbackup/backup_set_1_full/backup_set_info
// file:///obbackup/backup_set_1_full_20211231/single_backup_set_info.obbak
static int get_backup_set_info_path(const share::ObBackupDest &backup_set_dest,
share::ObBackupPath &backup_path);
static int get_backup_set_info_path(const share::ObBackupDest &backup_tenant_dest,
const share::ObBackupSetDesc &desc, share::ObBackupPath &backup_path);
// file:///obbackup/backup_set_1_full/infos/diagnose_info
// file:///obbackup/backup_set_1_full/infos/diagnose_info.obbak
static int get_diagnose_info_path(const share::ObBackupDest &backup_set_dest,
share::ObBackupPath &backup_path);
static int get_diagnose_info_path(const share::ObBackupDest &backup_tenant_dest,
share::ObBackupSetDesc &desc, share::ObBackupPath &backup_path);
// file:///obbackup/backup_set_1_full/infos/locality_info
// file:///obbackup/backup_set_1_full/infos/locality_info.obbak
static int get_locality_info_path(const share::ObBackupDest &backup_set_dest,
share::ObBackupPath &backup_path);
static int get_locality_info_path(const share::ObBackupDest &backup_tenant_dest,
share::ObBackupSetDesc &desc, share::ObBackupPath &backup_path);
// file:///obbackup/backup_set_1_full/log_stream_1/info_retry_0/ls_meta_info
// file:///obbackup/backup_set_1_full_20211231/log_stream_1/meta_info_turn_1_retry_0/ls_meta_info.obbak
static int get_ls_meta_info_backup_path(const share::ObBackupDest &backup_tenant_dest,
const share::ObBackupSetDesc &desc, const share::ObLSID &ls_id, const int64_t turn_id,
const int64_t retry_id, share::ObBackupPath &backup_path);
// file:///obbackup/backup_set_1_full/infos/info_turn_1/tenant_macro_range_index.0
// file:///obbackup/backup_set_1_full_20211231/logstream_1/xxx_xxx_turn_1_retry_0/macro_range_index.obbak
static int get_tenant_macro_range_index_backup_path(const share::ObBackupDest &backup_set_dest,
const share::ObBackupDataType &backup_data_type, const int64_t turn_id, const int64_t retry_id,
share::ObBackupPath &backup_path);
@ -218,7 +226,7 @@ struct ObBackupPathUtil
const share::ObBackupSetDesc &desc, const share::ObBackupDataType &backup_data_type, const int64_t turn_id,
const int64_t retry_id, share::ObBackupPath &backup_path);
// file:///obbackup/backup_set_1_full/infos/info_turn_1/tenant_meta_index.0
// file:///obbackup/backup_set_1_full_20211231/logstream_1/xxx_xxx_turn_1_retry_0/meta_index.obbak
static int get_tenant_meta_index_backup_path(const share::ObBackupDest &backup_set_dest,
const share::ObBackupDataType &backup_data_type, const int64_t turn_id, const int64_t retry_id,
const bool is_sec_meta, share::ObBackupPath &backup_path);
@ -227,7 +235,7 @@ struct ObBackupPathUtil
const share::ObBackupSetDesc &desc, const share::ObBackupDataType &backup_data_type, const int64_t turn_id,
const int64_t retry_id, const bool is_sec_meta, share::ObBackupPath &backup_path);
// file://obbackup/backup_set_1_full/infos/info_turn_1/tablet_log_stream_info
// file://obbackup/backup_set_1_full_20211231/infos/data_info_turn_1/tablet_log_stream_info.obbak
static int get_backup_data_tablet_ls_info_path(const share::ObBackupDest &backup_set_dest,
const uint64_t turn_id, share::ObBackupPath &path);

View File

@ -194,33 +194,20 @@ const ObBackupStorageInfo *ObBackupStore::get_storage_info() const
return backup_dest_.get_storage_info();
}
int ObBackupStore::get_root_path(ObBackupPathString &root_path) const
{
int ret = OB_SUCCESS;
const ObString bak_root_path = backup_dest_.get_root_path();
if (OB_FAIL(root_path.assign(bak_root_path.ptr()))) {
LOG_WARN("failed to assign root path", K(ret));
}
return ret;
}
// oss://archive/format
int ObBackupStore::get_format_file_path(ObBackupPathString &path) const
{
int ret = OB_SUCCESS;
int64_t pos = 0;
ObBackupPathString root;
ObBackupPath format_path;
if (IS_NOT_INIT) {
ret = OB_NOT_INIT;
LOG_WARN("ObBackupStore not init", K(ret));
} else if (OB_FAIL(get_root_path(root))) {
LOG_WARN("failed to get root path", K(ret));
} else if (OB_FAIL(databuff_printf(path.ptr(), path.capacity(), "%s", root.ptr()))) {
LOG_WARN("failed to assign root path", K(ret), K(root));
} else if (OB_FAIL(trim_right_backslash(path))) {
LOG_WARN("failed to trim right backslash", K(ret), K(path));
} else if (OB_FALSE_IT(pos = path.size())) {
} else if (OB_FAIL(databuff_printf(path.ptr(), path.capacity(), pos, "/%s", OB_STR_FORMAT_FILE_NAME))) {
} else if (OB_FAIL(format_path.init(backup_dest_.get_root_path()))) {
LOG_WARN("failed to get format path", K(ret));
} else if (OB_FAIL(format_path.join(OB_STR_FORMAT_FILE_NAME, ObBackupFileSuffix::BACKUP))) {
LOG_WARN("failed to assign format path", K(ret), K(format_path));
} else if (OB_FAIL(databuff_printf(path.ptr(), path.capacity(), pos, "%s", format_path.get_ptr()))) {
LOG_WARN("failed to assign format file name", K(ret), K(path));
}
return ret;

View File

@ -110,7 +110,6 @@ public:
bool is_init() const;
const ObBackupDest &get_backup_dest() const;
const ObBackupStorageInfo *get_storage_info() const;
int get_root_path(ObBackupPathString &root_path) const;
// oss://backup_dest/format
int get_format_file_path(ObBackupPathString &path) const;

View File

@ -4083,15 +4083,14 @@ int share::trim_right_backslash(ObBackupPathString &path)
return ret;
}
// Convert a scn to time string.
int share::backup_scn_to_strftime(const SCN &scn, char *buf,
// Convert time string.
int share::backup_time_to_strftime(const int64_t &ts_s, char *buf,
const int64_t buf_len, int64_t &pos, const char concat)
{
int ret = OB_SUCCESS;
ObSqlString format;
struct tm lt;
int strftime_len = 0;
const int64_t ts_s = trans_scn_to_second(scn);
time_t t = static_cast<time_t>(ts_s);
(void) localtime_r(&t, &lt);
@ -4114,7 +4113,8 @@ int share::backup_scn_to_strftime(const SCN &scn, char *buf,
int share::backup_scn_to_time_tag(const SCN &scn, char *buf, const int64_t buf_len, int64_t &pos)
{
int ret = OB_SUCCESS;
if (OB_FAIL(share::backup_scn_to_strftime(scn, buf, buf_len, pos, 'T'/* concat */))) {
const int64_t ts_s = trans_scn_to_second(scn);
if (OB_FAIL(share::backup_time_to_strftime(ts_s, buf, buf_len, pos, 'T'/* concat */))) {
LOG_WARN("failed to format time tag", K(ret), K(scn));
}
return ret;

View File

@ -289,7 +289,7 @@ const char *const OB_STR_TENANT_MAJOR_MACRO_INDEX = "tenant_major_data_macro_ran
const char *const OB_STR_TENANT_MAJOR_META_INDEX = "tenant_major_data_meta_index";
const char *const OB_STR_TENANT_MAJOR_SEC_META_INDEX = "tenant_major_data_sec_meta_index";
const char *const OB_STR_TABLET_INFO = "tablet_info";
const char *const OB_STR_LS_ATTR_INFO = "ls_attr_info_turn";
const char *const OB_STR_LS_ATTR_INFO = "ls_attr_info";
const char *const OB_STR_META_INFO = "meta_info";
const char *const OB_STR_SINGLE_BACKUP_SET_INFO = "single_backup_set_info";
const char *const OB_STR_PIECE_INFO = "piece_info";
@ -383,6 +383,8 @@ const char *const OB_STR_BACKUP_SET_LIST = "backup_set_list";
const char *const OB_STR_BACKUP_PIECE_LIST = "backup_piece_list";
const char *const OB_STR_LOG_PATH_LIST = "log_path_list";
const char *const OB_STR_LS_META_INFOS = "ls_meta_infos";
const char *const OB_BACKUP_SUFFIX=".obbak";
const char *const OB_ARCHIVE_SUFFIX=".obarc";
enum ObBackupFileType
{
@ -1621,8 +1623,8 @@ struct ObLogArchiveDestAtrr final
// trim '/' from right until encouter a non backslash charactor.
int trim_right_backslash(ObBackupPathString &path);
// Convert a scn to time string, return like '2022-05-31 12:00:00' if concat is ' '.
int backup_scn_to_strftime(const SCN &scn, char *buf, const int64_t buf_len, int64_t &pos, const char concat);
// Convert time string, return like '2022-05-31 12:00:00' if concat is ' '.
int backup_time_to_strftime(const int64_t &ts_s, char *buf, const int64_t buf_len, int64_t &pos, const char concat);
// Convert a scn to time tag, return like '20220531T120000'
int backup_scn_to_time_tag(const SCN &scn, char *buf, const int64_t buf_len, int64_t &pos);

View File

@ -600,7 +600,7 @@ int ObLSBackupCleanTask::delete_complement_log_(const ObBackupPath &path)
ObBackupPath complement_path;
if (OB_FAIL(complement_path.init(path.get_ptr()))) {
LOG_WARN("failed to init complement log path", K(ret), K(path));
} else if (OB_FAIL(complement_path.join("complement_log"))) {
} else if (OB_FAIL(complement_path.join("complement_log", ObBackupFileSuffix::NONE))) {
LOG_WARN("failed to join complement log", K(ret), K(path));
} else if (OB_FAIL(ObBackupCleanUtil::delete_backup_dir_files(path, backup_dest_.get_storage_info()))) {
LOG_WARN("failed to delete backup log stream dir files", K(ret), K(path));
@ -632,7 +632,7 @@ int ObLSBackupCleanTask::delete_sys_data_(const ObBackupPath &path)
LOG_WARN("file name is null", K(ret));
} else if (OB_FAIL(sys_path.init(path.get_ptr()))) {
LOG_WARN("failed to init major path", K(ret), K(path));
} else if (OB_FAIL(sys_path.join(tmp_entry.name_))) {
} else if (OB_FAIL(sys_path.join(tmp_entry.name_, ObBackupFileSuffix::NONE))) {
LOG_WARN("failed to join major path", K(ret));
} else if (OB_FAIL(ObBackupCleanUtil::delete_backup_dir_files(sys_path, backup_dest_.get_storage_info()))) {
LOG_WARN("failed to delete backup log stream dir files", K(ret), K(path));
@ -666,7 +666,7 @@ int ObLSBackupCleanTask::delete_major_data_(const ObBackupPath &path)
LOG_WARN("file name is null", K(ret));
} else if (OB_FAIL(major_path.init(path.get_ptr()))) {
LOG_WARN("failed to init major path", K(ret), K(path));
} else if (OB_FAIL(major_path.join(tmp_entry.name_))) {
} else if (OB_FAIL(major_path.join(tmp_entry.name_, ObBackupFileSuffix::NONE))) {
LOG_WARN("failed to join major path", K(ret));
} else if (OB_FAIL(ObBackupCleanUtil::delete_backup_dir_files(major_path, backup_dest_.get_storage_info()))) {
LOG_WARN("failed to delete backup log stream dir files", K(ret), K(path));
@ -700,7 +700,7 @@ int ObLSBackupCleanTask::delete_minor_data_(const ObBackupPath &path)
LOG_WARN("file name is null", K(ret));
} else if (OB_FAIL(minor_path.init(path.get_ptr()))) {
LOG_WARN("failed to init minor path", K(ret), K(path));
} else if (OB_FAIL(minor_path.join(tmp_entry.name_))) {
} else if (OB_FAIL(minor_path.join(tmp_entry.name_, ObBackupFileSuffix::NONE))) {
LOG_WARN("failed to join minor path", K(ret));
} else if (OB_FAIL(ObBackupCleanUtil::delete_backup_dir_files(minor_path, backup_dest_.get_storage_info()))) {
LOG_WARN("failed to delete backup log stream dir files", K(ret), K(path));
@ -734,7 +734,7 @@ int ObLSBackupCleanTask::delete_meta_info_(const ObBackupPath &path)
LOG_WARN("file name is null", K(ret));
} else if (OB_FAIL(meta_path.init(path.get_ptr()))) {
LOG_WARN("failed to init meta path", K(ret), K(path));
} else if (OB_FAIL(meta_path.join(tmp_entry.name_))) {
} else if (OB_FAIL(meta_path.join(tmp_entry.name_, ObBackupFileSuffix::NONE))) {
LOG_WARN("failed to join meta path", K(ret));
} else if (OB_FAIL(ObBackupCleanUtil::delete_backup_dir_files(meta_path, backup_dest_.get_storage_info()))) {
LOG_WARN("failed to delete backup log stream dir files", K(ret), K(path));
@ -806,7 +806,7 @@ int ObLSBackupCleanTask::get_set_ls_path_(ObBackupPath &path)
LOG_WARN("failed to get tenant data backup set dir path", K(ret));
} else if (OB_FAIL(databuff_printf(log_sream_str, sizeof(log_sream_str), "logstream_%ld", ls_id_.id()))) {
LOG_WARN("failed to get logsream_str", K(ret));
} else if (OB_FAIL(path.join(log_sream_str))) {
} else if (OB_FAIL(path.join(log_sream_str, ObBackupFileSuffix::NONE))) {
LOG_WARN("failed to join log stream dir", K(ret));
}
@ -825,7 +825,7 @@ int ObLSBackupCleanTask::get_piece_ls_path(ObBackupPath &path)
LOG_WARN("failed to get tenant clog piece dir path", K(ret));
} else if (OB_FAIL(databuff_printf(log_sream_str, sizeof(log_sream_str), "logstream_%ld", ls_id_.id()))) {
LOG_WARN("failed to get log_sream_str", K(ret));
} else if (OB_FAIL(path.join(log_sream_str))) {
} else if (OB_FAIL(path.join(log_sream_str, ObBackupFileSuffix::NONE))) {
LOG_WARN("failed to join log stream dir", K(ret));
}
return ret;

View File

@ -2487,7 +2487,7 @@ int ObAdminDumpBackupDataExecutor::get_tenant_backup_set_infos_path_(
STORAGE_LOG(WARN, "fail to init tmp_path", K(ret));
} else if (OB_FAIL(target_path.join_backup_set(backup_set_dir_name))) {
STORAGE_LOG(WARN, "fail to join backup set dir name", K(ret), K(backup_set_dir_name));
} else if (OB_FAIL(target_path.join(OB_STR_TENANT_BACKUP_SET_INFOS))) {
} else if (OB_FAIL(target_path.join(OB_STR_TENANT_BACKUP_SET_INFOS, ObBackupFileSuffix::BACKUP))) {
STORAGE_LOG(WARN, "fail to join tenant backup set infos", K(ret), K(backup_set_dir_name));
}
return ret;