From 2a8f9bf09541346df638bae2f25ad89119ba15d3 Mon Sep 17 00:00:00 2001 From: WenJinyu <596324105@qq.com> Date: Tue, 28 Dec 2021 12:12:46 +0800 Subject: [PATCH] auto_delete wakeup and add error code --- src/rootserver/ob_backup_data_clean.cpp | 63 +++++++++++++++---------- src/rootserver/ob_root_service.cpp | 45 ++++++++++++++++++ src/rootserver/ob_root_service.h | 1 + src/share/backup/ob_backup_struct.h | 1 + src/share/ob_errno.cpp | 8 ++++ src/share/ob_errno.def | 1 + src/share/ob_errno.h | 4 ++ 7 files changed, 99 insertions(+), 24 deletions(-) diff --git a/src/rootserver/ob_backup_data_clean.cpp b/src/rootserver/ob_backup_data_clean.cpp index 87c2894e7..999c104c2 100644 --- a/src/rootserver/ob_backup_data_clean.cpp +++ b/src/rootserver/ob_backup_data_clean.cpp @@ -974,7 +974,7 @@ int ObBackupDataClean::mark_sys_tenant_backup_meta_data_deleting() } else if (sys_clean_info.is_backup_set_clean() && !sys_clean_tenant.has_clean_backup_set(sys_clean_info.backup_set_id_, sys_clean_info.copy_id_)) { ret = OB_BACKUP_DELETE_BACKUP_SET_NOT_ALLOWED; - LOG_WARN("can not clean backup set", K(ret), K(sys_clean_info), K(sys_clean_tenant)); + LOG_WARN("can not clean backup set, because backup set is not existt", K(ret), K(sys_clean_info), K(sys_clean_tenant)); } if (OB_SUCC(ret)) { @@ -1361,7 +1361,11 @@ int ObBackupDataClean::add_delete_backup_set(const share::ObBackupCleanInfo &cle if (ObTenantBackupTaskInfo::FINISH != task_info.status_) { if (task_info.backup_set_id_ == clean_info.backup_set_id_) { ret = OB_BACKUP_DELETE_BACKUP_SET_NOT_ALLOWED; - LOG_WARN("backup set do not allow clean", K(ret), K(clean_info), K(cluster_max_backup_set_id), K(task_info)); + LOG_WARN("backup set do not allow clean, because status of backup set is not finish", + K(ret), + K(clean_info), + K(cluster_max_backup_set_id), + K(task_info)); } } else if (task_info.backup_set_id_ == clean_info.backup_set_id_) { delete_backup_info = task_info; @@ -1399,7 +1403,7 @@ int ObBackupDataClean::add_delete_backup_set(const share::ObBackupCleanInfo &cle (delete_backup_info.backup_dest_ == backup_dest_ || delete_backup_info.backup_dest_ == backup_backup_dest_)) { ret = OB_BACKUP_DELETE_BACKUP_SET_NOT_ALLOWED; - LOG_WARN("backup set do not allow clean", + LOG_WARN("backup set do not allow clean, because of need to keep the last succeed backup set", K(ret), K(clean_info), K(cluster_max_backup_set_id), @@ -1409,7 +1413,7 @@ int ObBackupDataClean::add_delete_backup_set(const share::ObBackupCleanInfo &cle LOG_WARN("failed to get backup set file copies num", K(ret), K(delete_backup_info)); } else if (copies_num < backup_dest_option.backup_copies_) { ret = OB_BACKUP_DELETE_BACKUP_SET_NOT_ALLOWED; - LOG_WARN("backup set do not allow clean", + LOG_WARN("backup set do not allow clean, because current finish copies_num is less than backup_copies in backup_dest_option", K(ret), K(clean_info), K(cluster_max_backup_set_id), @@ -1432,7 +1436,7 @@ int ObBackupDataClean::add_delete_backup_set(const share::ObBackupCleanInfo &cle clean_tenant.clog_gc_snapshot_ = INT64_MAX; } else { ret = OB_BACKUP_DELETE_BACKUP_SET_NOT_ALLOWED; - LOG_WARN("backup set do not allow clean", + LOG_WARN("backup set do not allow clean, because of need to keep last succeed backup set", K(ret), K(clean_info), K(cluster_max_backup_set_id), @@ -1901,9 +1905,12 @@ int ObBackupDataClean::add_delete_backup_piece(const share::ObBackupCleanInfo &c OB_FAIL(get_backup_piece_file_copies_num(backup_piece_info, copies_num))) { LOG_WARN("failed to get backup piece file copies num", K(ret), K(backup_piece_info)); } else if (copies_num < backup_dest_option.backup_copies_) { - // TODO(muwei.ym) change error code - ret = OB_INVALID_ARGUMENT; - LOG_WARN("failed to delete backup piece", K(ret), K(backup_piece_info)); + ret = OB_BACKUP_DELETE_BACKUP_PIECE_NOT_ALLOWED; + LOG_WARN("piece is not allowed to be deleted, because current finish copies_num is less than backup_copies in backup_dest_option", + K(ret), + K(copies_num), + K_(backup_dest_option.backup_copies), + K(backup_piece_info)); } else { int64_t start_replay_log_ts = 0; for (int64_t i = 0; i < task_infos.count() && !found_backup_set; ++i) { @@ -1919,17 +1926,19 @@ int ObBackupDataClean::add_delete_backup_piece(const share::ObBackupCleanInfo &c if (start_replay_log_ts >= backup_piece_info.max_ts_) { LOG_INFO("found suitable backup set, can delete backup piece", K(backup_piece_info)); } else { - // TODO(muwei.ym) change error code - ret = OB_INVALID_ARGUMENT; - LOG_WARN("failed to delete backup piece", K(ret), K(backup_piece_info), K(start_replay_log_ts)); + ret = OB_BACKUP_DELETE_BACKUP_PIECE_NOT_ALLOWED; + LOG_WARN("piece is not allowed to be deleted, because it is found that the dependent start_replay_log_ts " + "of backup set is less than the max_ts of piece", + K(ret), + K(backup_piece_info), + K(start_replay_log_ts)); } } else { if (clean_tenant.simple_clean_tenant_.is_deleted_) { LOG_INFO("tenant is deleted, can delete backup piece directly", K(backup_piece_info)); } else { - // TODO(muwei.ym) change error code - ret = OB_INVALID_ARGUMENT; - LOG_WARN("failed to delete backup piece", K(ret), K(backup_piece_info)); + ret = OB_BACKUP_DELETE_BACKUP_PIECE_NOT_ALLOWED; + LOG_WARN("piece is not allowed to be deleted, because no valid backup_set is found", K(ret), K(backup_piece_info)); } } } @@ -1992,9 +2001,12 @@ int ObBackupDataClean::add_delete_backup_round(const share::ObBackupCleanInfo &c OB_FAIL(get_backup_round_copies_num(log_archive_info, copies_num))) { LOG_WARN("failed to get backup round copies num", K(ret), K(log_archive_info)); } else if (copies_num < backup_dest_option.backup_copies_) { - // TODO(muwei.ym) change error code - ret = OB_INVALID_ARGUMENT; - LOG_WARN("failed to delete backup piece", K(ret), K(log_archive_info)); + ret = OB_BACKUP_DELETE_BACKUP_PIECE_NOT_ALLOWED; + LOG_WARN("round is not allowed to be deleted, because current finish copies_num is less than backup_copies in backup_dest_option", + K(ret), + K(copies_num), + K_(backup_dest_option.backup_copies), + K(log_archive_info)); } else { int64_t start_replay_log_ts = 0; for (int64_t i = 0; i < task_infos.count() && !found_backup_set; ++i) { @@ -2010,17 +2022,19 @@ int ObBackupDataClean::add_delete_backup_round(const share::ObBackupCleanInfo &c if (start_replay_log_ts >= log_archive_info.status_.checkpoint_ts_) { LOG_INFO("found suitable backup set, can delete backup round", K(log_archive_info)); } else { - // TODO(muwei.ym) change error code - ret = OB_INVALID_ARGUMENT; - LOG_WARN("failed to delete backup piece", K(ret), K(log_archive_info), K(start_replay_log_ts)); + ret = OB_BACKUP_DELETE_BACKUP_PIECE_NOT_ALLOWED; + LOG_WARN("round is not allowed to be deleted, because it is found that the dependent start_replay_log_ts " + "of backup set is less than the max_ts of round", + K(ret), + K(log_archive_info), + K(start_replay_log_ts)); } } else { if (clean_tenant.simple_clean_tenant_.is_deleted_) { LOG_INFO("tenant is deleted, can delete backup round directly", K(log_archive_info)); } else { - // TODO(muwei.ym) change error code - ret = OB_INVALID_ARGUMENT; - LOG_WARN("failed to delete backup round", K(ret), K(log_archive_info)); + ret = OB_BACKUP_DELETE_BACKUP_PIECE_NOT_ALLOWED; + LOG_WARN("round is not allowed to be deleted, because no valid backup_set is found", K(ret), K(log_archive_info)); } } } @@ -6111,7 +6125,8 @@ bool ObBackupDataClean::is_result_need_retry(const int32_t result) const int64_t MAX_RETRY_COUNT = 64; if (OB_NOT_INIT != result && OB_INVALID_ARGUMENT != result && OB_ERR_SYS != result && OB_INIT_TWICE != result && OB_ERR_UNEXPECTED != result && OB_TENANT_HAS_BEEN_DROPPED != result && OB_NOT_SUPPORTED != result && - OB_BACKUP_DELETE_BACKUP_SET_NOT_ALLOWED != result && OB_SUCCESS != result && OB_CANCELED != result && + OB_BACKUP_DELETE_BACKUP_SET_NOT_ALLOWED != result && OB_BACKUP_DELETE_BACKUP_PIECE_NOT_ALLOWED != result && + OB_SUCCESS != result && OB_CANCELED != result && retry_count_ < MAX_RETRY_COUNT) { // do nothing // TODO() Need to consider the limit of the number of retry diff --git a/src/rootserver/ob_root_service.cpp b/src/rootserver/ob_root_service.cpp index 3dd4e6e26..9fd0cff5c 100644 --- a/src/rootserver/ob_root_service.cpp +++ b/src/rootserver/ob_root_service.cpp @@ -9762,6 +9762,49 @@ int ObRootService::set_config_pre_hook(obrpc::ObAdminSetConfigArg& arg) return ret; } + +int ObRootService::wakeup_auto_delete(const obrpc::ObAdminSetConfigItem *item) +{ + int ret = OB_SUCCESS; + ObBackupDestOpt new_opt; + if (!inited_) { + ret = OB_NOT_INIT; + LOG_WARN("not init", K(ret)); + } else if (NULL == item) { + ret = OB_INVALID_ARGUMENT; + LOG_WARN("item is null", K(ret)); + } else if (0 == STRCMP(item->name_.ptr(), OB_STR_BACKUP_DEST_OPT)) { + if (OB_FAIL(new_opt.init(false/* is_backup_backup */))) { + LOG_WARN("failed init backup dest option", K(ret), KPC(item)); + } else if (true == new_opt.auto_delete_obsolete_backup_ && 0 != new_opt.recovery_window_) { + backup_auto_delete_.wakeup(); + LOG_INFO("backup_dest_option parameters updated, wakeup backup_auto_delete", KPC(item)); + } + } else if (0 == STRCMP(item->name_.ptr(), OB_STR_BACKUP_BACKUP_DEST_OPT)) { + if (OB_FAIL(new_opt.init(true/* is_backup_backup */))) { + LOG_WARN("failed init backup backup dest option", K(ret), KPC(item)); + } else if (true == new_opt.auto_delete_obsolete_backup_ && 0 != new_opt.recovery_window_) { + backup_auto_delete_.wakeup(); + LOG_INFO("backup_backup_dest_option parameters updated, wakeup backup_auto_delete", KPC(item)); + } + } else if (0 == STRCMP(item->name_.ptr(), OB_STR_AUTO_DELETE_EXPIRED_BACKUP)) { + ObString value(item->value_.ptr()); + ObString false_str("FALSE"); + if (0 != value.case_compare(false_str)) { + backup_auto_delete_.wakeup(); + LOG_INFO("auto_delete_expired_backup parameters updated, wakeup backup_auto_delete", KPC(item)); + } + } else if (0 == STRCMP(item->name_.ptr(), OB_STR_BACKUP_RECORVERTY_WINDOW)) { + ObString value(item->value_.ptr()); + ObString zero_str("0"); + if (0 != value.case_compare(zero_str)) { + backup_auto_delete_.wakeup(); + LOG_INFO("backup_recovery_window parameters updated, wakeup backup_auto_delete", KPC(item)); + } + } + return ret; +} + int ObRootService::set_config_post_hook(const obrpc::ObAdminSetConfigArg& arg) { int ret = OB_SUCCESS; @@ -9811,6 +9854,8 @@ int ObRootService::set_config_post_hook(const obrpc::ObAdminSetConfigArg& arg) } else if (0 == STRCMP(item->name_.ptr(), SCHEMA_HISTORY_RECYCLE_INTERVAL)) { schema_history_recycler_.wakeup(); LOG_INFO("schema_history_recycle_interval parameters updated, wakeup schema_history_recycler", KPC(item)); + } else if (OB_FAIL(wakeup_auto_delete(item))) { + LOG_WARN("failed to wakeup auto delete", K(ret), KPC(item)); } } return ret; diff --git a/src/rootserver/ob_root_service.h b/src/rootserver/ob_root_service.h index 2445800c0..55dad2be7 100644 --- a/src/rootserver/ob_root_service.h +++ b/src/rootserver/ob_root_service.h @@ -1122,6 +1122,7 @@ public: int set_config_pre_hook(obrpc::ObAdminSetConfigArg& arg); // arg is readonly after take effect int set_config_post_hook(const obrpc::ObAdminSetConfigArg& arg); + int wakeup_auto_delete(const obrpc::ObAdminSetConfigItem *item); // @see ObReplicaControlCleanTask int submit_replica_control_clean_task(); diff --git a/src/share/backup/ob_backup_struct.h b/src/share/backup/ob_backup_struct.h index 99ee0a258..1088e9757 100644 --- a/src/share/backup/ob_backup_struct.h +++ b/src/share/backup/ob_backup_struct.h @@ -165,6 +165,7 @@ const char* const OB_STR_FULL_BACKUP = "full"; const char* const OB_STR_INC_BACKUP = "inc"; const char* const OB_STR_AUTO_DELETE_EXPIRED_BACKUP = "auto_delete_expired_backup"; const char* const OB_STR_AUTO_UPDATE_RESERVED_BACKUP_TIMESTAMP = "_auto_update_reserved_backup_timestamp"; +const char *const OB_STR_BACKUP_RECORVERTY_WINDOW = "backup_recovery_window"; const char* const OB_STR_BACKUP_INNER_TABLE_VERSION = "inner_table_version"; const char* const OB_BACKUP_ENCRYPTION_MODE_SESSION_STR = "__ob_backup_encryption_mode__"; diff --git a/src/share/ob_errno.cpp b/src/share/ob_errno.cpp index 59b82318c..a741394a4 100644 --- a/src/share/ob_errno.cpp +++ b/src/share/ob_errno.cpp @@ -14008,6 +14008,14 @@ static struct ObStrErrorInit ORACLE_ERRNO[-OB_ARCHIVE_LOG_NOT_CONTINUES_WITH_DATA] = 600; ORACLE_STR_ERROR[-OB_ARCHIVE_LOG_NOT_CONTINUES_WITH_DATA] = "ORA-00600: internal error code, arguments: -9064, the archive log and backup data are not continuous"; ORACLE_STR_USER_ERROR[-OB_ARCHIVE_LOG_NOT_CONTINUES_WITH_DATA] = "ORA-00600: internal error code, arguments: -9064, the archive log and backup data are not continuous"; + ERROR_NAME[-OB_BACKUP_DELETE_BACKUP_PIECE_NOT_ALLOWED] = "OB_BACKUP_DELETE_BACKUP_PIECE_NOT_ALLOWED"; + MYSQL_ERRNO[-OB_BACKUP_DELETE_BACKUP_PIECE_NOT_ALLOWED] = -1; + SQLSTATE[-OB_BACKUP_DELETE_BACKUP_PIECE_NOT_ALLOWED] = "HY000"; + STR_ERROR[-OB_BACKUP_DELETE_BACKUP_PIECE_NOT_ALLOWED] = "deleting backup piece is not allowed"; + STR_USER_ERROR[-OB_BACKUP_DELETE_BACKUP_PIECE_NOT_ALLOWED] = "deleting backup piece is not allowed"; + ORACLE_ERRNO[-OB_BACKUP_DELETE_BACKUP_PIECE_NOT_ALLOWED] = 600; + ORACLE_STR_ERROR[-OB_BACKUP_DELETE_BACKUP_PIECE_NOT_ALLOWED] = "ORA-00600: internal error code, arguments: -9069, deleting backup piece is not allowed"; + ORACLE_STR_USER_ERROR[-OB_BACKUP_DELETE_BACKUP_PIECE_NOT_ALLOWED] = "ORA-00600: internal error code, arguments: -9069, deleting backup piece is not allowed"; ERROR_NAME[-OB_NO_SUCH_FILE_OR_DIRECTORY] = "OB_NO_SUCH_FILE_OR_DIRECTORY"; ERROR_CAUSE[-OB_NO_SUCH_FILE_OR_DIRECTORY] = "Internal Error"; ERROR_SOLUTION[-OB_NO_SUCH_FILE_OR_DIRECTORY] = "Contact OceanBase Support"; diff --git a/src/share/ob_errno.def b/src/share/ob_errno.def index e3d7044fb..89e14c87e 100644 --- a/src/share/ob_errno.def +++ b/src/share/ob_errno.def @@ -1543,6 +1543,7 @@ DEFINE_ERROR_DEP(OB_IO_LIMIT, -9061, -1, "HY000", "IO limit"); DEFINE_ERROR(OB_BACKUP_BACKUP_REACH_COPY_LIMIT, -9062, -1, "HY000", "reach backup backup copy limit"); DEFINE_ERROR(OB_BACKUP_IO_PROHIBITED, -9063, -1, "HY000", "backup io is prohibited"); DEFINE_ERROR(OB_ARCHIVE_LOG_NOT_CONTINUES_WITH_DATA, -9064, -1, "HY000", "the archive log and backup data are not continuous"); +DEFINE_ERROR(OB_BACKUP_DELETE_BACKUP_PIECE_NOT_ALLOWED, -9069, -1, "HY000", "deleting backup piece is not allowed"); //////////////////////////////////////////////////////////////// //error code for STORAGE3.0 -9100 ~ diff --git a/src/share/ob_errno.h b/src/share/ob_errno.h index 650e6336c..2d646b18d 100644 --- a/src/share/ob_errno.h +++ b/src/share/ob_errno.h @@ -9,6 +9,7 @@ * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. * See the Mulan PubL v2 for more details. */ + // DO NOT EDIT. This file is automatically generated from `ob_errno.def'. #ifndef OCEANBASE_LIB_OB_ERRNO_H_ @@ -1206,6 +1207,7 @@ constexpr int OB_CANNOT_SET_BACKUP_REGION = -9057; constexpr int OB_CANNOT_SET_BACKUP_ZONE = -9058; constexpr int OB_BACKUP_BACKUP_REACH_MAX_BACKUP_TIMES = -9059; constexpr int OB_ARCHIVE_LOG_NOT_CONTINUES_WITH_DATA = -9064; +constexpr int OB_BACKUP_DELETE_BACKUP_PIECE_NOT_ALLOWED = -9069; constexpr int OB_NO_SUCH_FILE_OR_DIRECTORY = -9100; constexpr int OB_FILE_OR_DIRECTORY_EXIST = -9101; constexpr int OB_ERR_DUPLICATE_HAVING_CLAUSE_IN_TABLE_EXPRESSION = -9501; @@ -2636,6 +2638,7 @@ constexpr int OB_ERR_INVALID_DATE_MSG_FMT_V2 = -4219; #define OB_BACKUP_BACKUP_REACH_COPY_LIMIT__USER_ERROR_MSG "reach backup backup copy limit" #define OB_BACKUP_IO_PROHIBITED__USER_ERROR_MSG "backup io is prohibited" #define OB_ARCHIVE_LOG_NOT_CONTINUES_WITH_DATA__USER_ERROR_MSG "the archive log and backup data are not continuous" +#define OB_BACKUP_DELETE_BACKUP_PIECE_NOT_ALLOWED__USER_ERROR_MSG "deleting backup piece is not allowed" #define OB_NO_SUCH_FILE_OR_DIRECTORY__USER_ERROR_MSG "no such file or directory" #define OB_FILE_OR_DIRECTORY_EXIST__USER_ERROR_MSG "file or directory already exist" #define OB_ERR_DUPLICATE_HAVING_CLAUSE_IN_TABLE_EXPRESSION__USER_ERROR_MSG "Duplicate having-clause in table expression" @@ -4066,6 +4069,7 @@ constexpr int OB_ERR_INVALID_DATE_MSG_FMT_V2 = -4219; #define OB_BACKUP_BACKUP_REACH_COPY_LIMIT__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -9062, reach backup backup copy limit" #define OB_BACKUP_IO_PROHIBITED__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -9063, backup io is prohibited" #define OB_ARCHIVE_LOG_NOT_CONTINUES_WITH_DATA__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -9064, the archive log and backup data are not continuous" +#define OB_BACKUP_DELETE_BACKUP_PIECE_NOT_ALLOWED__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -9069, deleting backup piece is not allowed" #define OB_NO_SUCH_FILE_OR_DIRECTORY__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -9100, no such file or directory" #define OB_FILE_OR_DIRECTORY_EXIST__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -9101, file or directory already exist" #define OB_ERR_DUPLICATE_HAVING_CLAUSE_IN_TABLE_EXPRESSION__ORA_USER_ERROR_MSG "PLS-00119: Duplicate having-clause in table expression" -- GitLab