提交 1bb97602 编写于 作者: W WenJinyu 提交者: ob-robot

[CP] fix when delete specified backup_set, the round task is deleted

上级 4036f512
......@@ -2416,41 +2416,24 @@ int ObBackupDataClean::get_sys_tenant_delete_clog_round_and_piece(const share::O
return ret;
}
int ObBackupDataClean::get_sys_tenant_prepare_clog_round_and_piece(const share::ObBackupCleanInfo &clean_info,
const ObBackupDataCleanElement &clean_element, common::ObIArray<ObLogArchiveRound> &log_archive_rounds,
int ObBackupDataClean::get_sys_tenant_prepare_clog_piece(const share::ObBackupCleanInfo &clean_info,
const ObLogArchiveRound &log_archive_round, const ObBackupDataCleanElement &clean_element, bool &is_delete_inorder,
common::ObIArray<ObBackupPieceInfoKey> &backup_piece_keys)
{
int ret = OB_SUCCESS;
log_archive_rounds.reset();
backup_piece_keys.reset();
const int64_t clog_gc_snapshot = clean_info.clog_gc_snapshot_;
ObLogArchiveBackupInfoMgr log_info_mgr;
const uint64_t tenant_id = clean_info.tenant_id_;
const int64_t incarnation = clean_element.incarnation_;
const int64_t backup_copies = clean_element.backup_dest_option_.backup_copies_;
ObSimpleArchiveRound simple_archive_round;
ObSimplePieceKey simple_piece_key;
const bool overwrite_key = true;
bool is_delete_inorder = true;
ObSimplePieceKey simple_piece_key;
if (!is_inited_) {
ret = OB_NOT_INIT;
LOG_WARN("backup data clean do not init", K(ret));
} else if (!clean_info.is_valid() || OB_SYS_TENANT_ID != clean_info.tenant_id_ ||
ObBackupCleanInfoStatus::PREPARE != clean_info.status_) {
} else if (!clean_info.is_valid() || !log_archive_round.is_valid() || !clean_element.is_valid()) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("get sys tenant delete clog round and piece get invalid argument", K(ret), K(clean_info));
} else {
for (int64_t i = 0; OB_SUCC(ret) && i < clean_element.log_archive_round_array_.count(); ++i) {
const ObLogArchiveRound &log_archive_round = clean_element.log_archive_round_array_.at(i);
if (!is_delete_inorder) {
break;
} else if (clean_info.is_delete_backup_set() && 0 != log_archive_round.start_piece_id_) {
// do nothing
LOG_WARN("argument is invalid", K(ret), K(clean_info), K(log_archive_round), K(clean_element));
} else {
for (int64_t j = 0; OB_SUCC(ret) && is_delete_inorder && j < log_archive_round.piece_infos_.count(); ++j) {
const ObSimplePieceInfo &simple_piece_info = log_archive_round.piece_infos_.at(j);
if (simple_piece_info.max_ts_ > clog_gc_snapshot ||
if (simple_piece_info.max_ts_ > clean_info.clog_gc_snapshot_ ||
ObBackupPieceStatus::BACKUP_PIECE_FROZEN != simple_piece_info.status_ ||
ObBackupFileStatus::BACKUP_FILE_COPYING == simple_piece_info.file_status_ ||
simple_piece_info.copies_num_ < backup_copies) {
......@@ -2461,9 +2444,9 @@ int ObBackupDataClean::get_sys_tenant_prepare_clog_round_and_piece(const share::
ObBackupPieceInfoKey piece_info_key;
piece_info_key.backup_piece_id_ = simple_piece_info.backup_piece_id_;
piece_info_key.copy_id_ = log_archive_round.copy_id_;
piece_info_key.incarnation_ = incarnation;
piece_info_key.incarnation_ = clean_element.incarnation_;
piece_info_key.round_id_ = log_archive_round.log_archive_round_;
piece_info_key.tenant_id_ = tenant_id;
piece_info_key.tenant_id_ = clean_info.tenant_id_;
simple_piece_key.reset();
simple_piece_key.incarnation_ = piece_info_key.incarnation_;
......@@ -2499,12 +2482,28 @@ int ObBackupDataClean::get_sys_tenant_prepare_clog_round_and_piece(const share::
}
}
}
return ret;
}
int ObBackupDataClean::get_sys_tenant_prepare_clog_round(const share::ObBackupCleanInfo &clean_info,
const ObLogArchiveRound &log_archive_round, const ObBackupDataCleanElement &clean_element, bool &is_delete_inorder,
common::ObIArray<ObLogArchiveRound> &log_archive_rounds)
{
int ret = OB_SUCCESS;
const int64_t backup_copies = clean_element.backup_dest_option_.backup_copies_;
const bool overwrite_key = true;
ObSimpleArchiveRound simple_archive_round;
int piece_num = log_archive_round.piece_infos_.count();
if (OB_FAIL(ret)) {
if (!is_inited_) {
ret = OB_NOT_INIT;
LOG_WARN("backup data clean do not init", K(ret));
} else if (!clean_info.is_valid() || !log_archive_round.is_valid() || !clean_element.is_valid()) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("argument is invalid", K(ret), K(clean_info), K(log_archive_round), K(clean_element));
} else if (ObLogArchiveStatus::STOP != log_archive_round.log_archive_status_) {
// do nothing
} else if (log_archive_round.checkpoint_ts_ > clog_gc_snapshot || log_archive_round.copies_num_ < backup_copies) {
} else if (log_archive_round.checkpoint_ts_ > clean_info.clog_gc_snapshot_ ||
log_archive_round.copies_num_ < backup_copies) {
is_delete_inorder = false;
} else if (piece_num < 0) {
ret = OB_ERR_UNEXPECTED;
......@@ -2514,7 +2513,7 @@ int ObBackupDataClean::get_sys_tenant_prepare_clog_round_and_piece(const share::
is_delete_inorder = true;
} else {
const ObSimplePieceInfo &simple_piece_info = log_archive_round.piece_infos_.at(piece_num - 1);
if (simple_piece_info.max_ts_ > clog_gc_snapshot) {
if (simple_piece_info.max_ts_ > clean_info.clog_gc_snapshot_) {
is_delete_inorder = false;
}
}
......@@ -2530,8 +2529,8 @@ int ObBackupDataClean::get_sys_tenant_prepare_clog_round_and_piece(const share::
simple_archive_round.copy_id_ = log_archive_round.copy_id_;
if (OB_FAIL(sys_tenant_deleted_backup_round_.set_refactored_1(simple_archive_round, overwrite_key))) {
LOG_WARN("failed to set sys tenant deleted backup round", K(ret), K(simple_archive_round));
} else if (FALSE_IT(trace_length = ObCurTraceId::get_trace_id()->to_string(
trace_id, common::OB_MAX_TRACE_ID_BUFFER_SIZE))) {
} else if (FALSE_IT(trace_length =
ObCurTraceId::get_trace_id()->to_string(trace_id, common::OB_MAX_TRACE_ID_BUFFER_SIZE))) {
} else if (trace_length > OB_MAX_TRACE_ID_BUFFER_SIZE) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("failed to get trace id", K(ret), K(*ObCurTraceId::get_trace_id()));
......@@ -2550,6 +2549,39 @@ int ObBackupDataClean::get_sys_tenant_prepare_clog_round_and_piece(const share::
}
}
}
return ret;
}
int ObBackupDataClean::get_sys_tenant_prepare_clog_round_and_piece(const share::ObBackupCleanInfo &clean_info,
const ObBackupDataCleanElement &clean_element, common::ObIArray<ObLogArchiveRound> &log_archive_rounds,
common::ObIArray<ObBackupPieceInfoKey> &backup_piece_keys)
{
int ret = OB_SUCCESS;
log_archive_rounds.reset();
backup_piece_keys.reset();
ObLogArchiveBackupInfoMgr log_info_mgr;
bool is_delete_inorder = true;
if (!is_inited_) {
ret = OB_NOT_INIT;
LOG_WARN("backup data clean do not init", K(ret));
} else if (!clean_info.is_valid() || OB_SYS_TENANT_ID != clean_info.tenant_id_ ||
ObBackupCleanInfoStatus::PREPARE != clean_info.status_) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("get sys tenant delete clog round and piece get invalid argument", K(ret), K(clean_info));
} else {
for (int64_t i = 0; OB_SUCC(ret) && i < clean_element.log_archive_round_array_.count(); ++i) {
const ObLogArchiveRound &log_archive_round = clean_element.log_archive_round_array_.at(i);
if (!is_delete_inorder) {
break;
} else if (clean_info.is_delete_backup_set() && 0 != log_archive_round.start_piece_id_) {
// do nothing
} else if (OB_FAIL(get_sys_tenant_prepare_clog_piece(
clean_info, log_archive_round, clean_element, is_delete_inorder, backup_piece_keys))) {
LOG_WARN("get sys tenant delete clog piece", K(ret), K(clean_info), K(log_archive_round));
} else if (OB_FAIL(get_sys_tenant_prepare_clog_round(
clean_info, log_archive_round, clean_element, is_delete_inorder, log_archive_rounds))) {
LOG_WARN("get sys tenant delete clog round", K(ret), K(clean_info), K(log_archive_round), K(backup_piece_keys));
}
}
}
return ret;
......
......@@ -172,6 +172,18 @@ private:
const ObBackupDataCleanElement &clean_element,
common::ObIArray<ObLogArchiveRound> &log_archive_rounds,
common::ObIArray<ObBackupPieceInfoKey> &backup_piece_keys);
int get_sys_tenant_prepare_clog_round(
const share::ObBackupCleanInfo &clean_info,
const ObLogArchiveRound &log_archive_round,
const ObBackupDataCleanElement &clean_element,
bool &is_delete_inorder,
common::ObIArray<ObLogArchiveRound> &log_archive_rounds);
int get_sys_tenant_prepare_clog_piece(
const share::ObBackupCleanInfo &clean_info,
const ObLogArchiveRound &log_archive_round,
const ObBackupDataCleanElement &clean_element,
bool &is_delete_inorder,
common::ObIArray<ObBackupPieceInfoKey> &backup_piece_keys);
int get_sys_tenant_doing_clog_round_and_piece(
const share::ObBackupCleanInfo &clean_info,
const ObBackupDataCleanElement &clean_element,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册