From b1ec5d3524d8d982b12445a869e57fc2e0b072d4 Mon Sep 17 00:00:00 2001 From: godyangfight Date: Thu, 2 Dec 2021 10:30:28 +0800 Subject: [PATCH] patch backup related bug fix to open source --- .../ob_backup_auto_delete_expired_backup.cpp | 16 +- .../backup/ob_log_archive_backup_info_mgr.cpp | 515 +++++++++--------- ...artition_base_data_physical_restore_v2.cpp | 348 ++++++------ ..._partition_base_data_physical_restore_v2.h | 173 +++--- src/storage/ob_partition_backup.cpp | 24 +- src/storage/ob_partition_base_data_backup.cpp | 13 +- src/storage/ob_partition_migrator.cpp | 27 +- 7 files changed, 581 insertions(+), 535 deletions(-) diff --git a/src/rootserver/backup/ob_backup_auto_delete_expired_backup.cpp b/src/rootserver/backup/ob_backup_auto_delete_expired_backup.cpp index 04f5b47ba..56265da04 100644 --- a/src/rootserver/backup/ob_backup_auto_delete_expired_backup.cpp +++ b/src/rootserver/backup/ob_backup_auto_delete_expired_backup.cpp @@ -56,9 +56,9 @@ ObBackupAutoDeleteExpiredData::ObBackupAutoDeleteExpiredData() ObBackupAutoDeleteExpiredData::~ObBackupAutoDeleteExpiredData() {} -int ObBackupAutoDeleteExpiredData::init(common::ObServerConfig& cfg, ObMySQLProxy& sql_proxy, - share::schema::ObMultiVersionSchemaService& schema_service, ObBackupDataClean& backup_data_clean, - share::ObIBackupLeaseService& backup_lease_service) +int ObBackupAutoDeleteExpiredData::init(common::ObServerConfig &cfg, ObMySQLProxy &sql_proxy, + share::schema::ObMultiVersionSchemaService &schema_service, ObBackupDataClean &backup_data_clean, + share::ObIBackupLeaseService &backup_lease_service) { int ret = OB_SUCCESS; const int backup_auto_delete_thread_cnt = 1; @@ -156,7 +156,7 @@ void ObBackupAutoDeleteExpiredData::run3() } int ObBackupAutoDeleteExpiredData::check_can_auto_handle_backup( - const bool is_auto, const int64_t backup_recovery_window, bool& can_auto_delete) + const bool is_auto, const int64_t backup_recovery_window, bool &can_auto_delete) { int ret = OB_SUCCESS; can_auto_delete = true; @@ -172,7 +172,7 @@ int ObBackupAutoDeleteExpiredData::check_can_auto_handle_backup( } int ObBackupAutoDeleteExpiredData::get_last_succeed_delete_obsolete_snapshot( - int64_t& last_succ_delete_obsolete_snapshot) + int64_t &last_succ_delete_obsolete_snapshot) { int ret = OB_SUCCESS; ObBackupInfoManager backup_info_manager; @@ -221,6 +221,10 @@ int ObBackupAutoDeleteExpiredData::schedule_auto_delete_expired_data(const int64 int64_t last_succ_delete_obsolete_snapshot = 0; const int64_t now_ts = ObTimeUtil::current_time(); ObBackupDataCleanScheduler backup_data_clean_scheduler; + const int64_t MAX_INTERVAL = 24L * 60L * 60L * 1000L * 1000L; // 24h + const int64_t AUTO_CLEAN_INTERVAL = + (backup_recovery_window / 2) < MAX_INTERVAL ? (backup_recovery_window / 2) : MAX_INTERVAL; + if (!is_inited_) { ret = OB_NOT_INIT; LOG_WARN("backup auto delete expired data do not init", K(ret)); @@ -229,7 +233,7 @@ int ObBackupAutoDeleteExpiredData::schedule_auto_delete_expired_data(const int64 LOG_WARN("schedule auto delete expired data get invalid argument", K(ret), K(backup_recovery_window)); } else if (OB_FAIL(get_last_succeed_delete_obsolete_snapshot(last_succ_delete_obsolete_snapshot))) { LOG_WARN("failed to get last succ delete obsolete snapshot", K(ret), K(last_succ_delete_obsolete_snapshot)); - } else if (now_ts - last_succ_delete_obsolete_snapshot < backup_recovery_window / 2) { + } else if (now_ts - last_succ_delete_obsolete_snapshot < AUTO_CLEAN_INTERVAL) { switch_delete_obsolete_action(); if (delete_obsolete_action_ != ObBackupDeleteObsoleteAction::NONE) { wakeup(); diff --git a/src/share/backup/ob_log_archive_backup_info_mgr.cpp b/src/share/backup/ob_log_archive_backup_info_mgr.cpp index 9a0bc6418..5575ef406 100644 --- a/src/share/backup/ob_log_archive_backup_info_mgr.cpp +++ b/src/share/backup/ob_log_archive_backup_info_mgr.cpp @@ -58,11 +58,11 @@ int64_t ObExternLogArchiveBackupInfo::get_write_buf_size() const return size; } -int ObExternLogArchiveBackupInfo::write_buf(char* buf, const int64_t buf_len, int64_t& pos) const +int ObExternLogArchiveBackupInfo::write_buf(char *buf, const int64_t buf_len, int64_t &pos) const { int ret = OB_SUCCESS; const int64_t need_size = get_write_buf_size(); - ObBackupCommonHeader* common_header = nullptr; + ObBackupCommonHeader *common_header = nullptr; if (OB_ISNULL(buf) || buf_len - pos < need_size) { ret = OB_INVALID_ARGUMENT; @@ -90,7 +90,7 @@ int ObExternLogArchiveBackupInfo::write_buf(char* buf, const int64_t buf_len, in return ret; } -int ObExternLogArchiveBackupInfo::read_buf(const char* buf, const int64_t buf_len) +int ObExternLogArchiveBackupInfo::read_buf(const char *buf, const int64_t buf_len) { int ret = OB_SUCCESS; @@ -99,7 +99,7 @@ int ObExternLogArchiveBackupInfo::read_buf(const char* buf, const int64_t buf_le LOG_WARN("invalid args", K(ret), KP(buf), K(buf_len)); } else { int64_t pos = 0; - const ObBackupCommonHeader* common_header = reinterpret_cast(buf + pos); + const ObBackupCommonHeader *common_header = reinterpret_cast(buf + pos); pos += common_header->header_length_; if (OB_FAIL(common_header->check_header_checksum())) { LOG_WARN("failed to check common header", K(ret)); @@ -115,7 +115,7 @@ int ObExternLogArchiveBackupInfo::read_buf(const char* buf, const int64_t buf_le return ret; } -int ObExternLogArchiveBackupInfo::update(const ObTenantLogArchiveStatus& status) +int ObExternLogArchiveBackupInfo::update(const ObTenantLogArchiveStatus &status) { int ret = OB_SUCCESS; @@ -129,7 +129,7 @@ int ObExternLogArchiveBackupInfo::update(const ObTenantLogArchiveStatus& status) FLOG_INFO("add first new status", K(status)); } } else { - ObTenantLogArchiveStatus& last = status_array_.at(status_array_.count() - 1); + ObTenantLogArchiveStatus &last = status_array_.at(status_array_.count() - 1); if (last.incarnation_ != status.incarnation_) { ret = OB_NOT_SUPPORTED; @@ -166,7 +166,7 @@ int ObExternLogArchiveBackupInfo::update(const ObTenantLogArchiveStatus& status) return ret; } -int ObExternLogArchiveBackupInfo::get_last(ObTenantLogArchiveStatus& status) +int ObExternLogArchiveBackupInfo::get_last(ObTenantLogArchiveStatus &status) { int ret = OB_SUCCESS; status.reset(); @@ -180,14 +180,14 @@ int ObExternLogArchiveBackupInfo::get_last(ObTenantLogArchiveStatus& status) } int ObExternLogArchiveBackupInfo::get_log_archive_status( - const int64_t restore_timestamp, ObTenantLogArchiveStatus& status) + const int64_t restore_timestamp, ObTenantLogArchiveStatus &status) { int ret = OB_LOG_ARCHIVE_BACKUP_INFO_NOT_EXIST; status.reset(); for (int64_t i = 0; i < status_array_.count(); ++i) { - const ObTenantLogArchiveStatus& cur_status = status_array_.at(i); + const ObTenantLogArchiveStatus &cur_status = status_array_.at(i); if (cur_status.start_ts_ <= restore_timestamp && restore_timestamp <= cur_status.checkpoint_ts_) { status = status_array_.at(i); ret = OB_SUCCESS; @@ -201,7 +201,7 @@ int ObExternLogArchiveBackupInfo::get_log_archive_status( return ret; } -int ObExternLogArchiveBackupInfo::get_log_archive_status(ObIArray& status_array) +int ObExternLogArchiveBackupInfo::get_log_archive_status(ObIArray &status_array) { int ret = OB_SUCCESS; if (OB_FAIL(status_array.assign(status_array_))) { @@ -210,13 +210,13 @@ int ObExternLogArchiveBackupInfo::get_log_archive_status(ObIArray& round_ids) +int ObExternLogArchiveBackupInfo::mark_log_archive_deleted(const ObIArray &round_ids) { int ret = OB_SUCCESS; for (int64_t i = 0; OB_SUCC(ret) && i < round_ids.count(); ++i) { const int64_t round_id = round_ids.at(i); for (int64_t j = 0; OB_SUCC(ret) && j < status_array_.count(); ++j) { - ObTenantLogArchiveStatus& tenant_archive_status = status_array_.at(j); + ObTenantLogArchiveStatus &tenant_archive_status = status_array_.at(j); if (tenant_archive_status.round_ != round_id) { // do nothing } else { @@ -228,13 +228,13 @@ int ObExternLogArchiveBackupInfo::mark_log_archive_deleted(const ObIArray& round_ids) +int ObExternLogArchiveBackupInfo::delete_marked_log_archive_info(const common::ObIArray &round_ids) { int ret = OB_SUCCESS; for (int64_t i = 0; OB_SUCC(ret) && i < round_ids.count(); ++i) { const int64_t round_id = round_ids.at(i); for (int64_t j = status_array_.count() - 1; OB_SUCC(ret) && j >= 0; --j) { - ObTenantLogArchiveStatus& tenant_archive_status = status_array_.at(j); + ObTenantLogArchiveStatus &tenant_archive_status = status_array_.at(j); if (tenant_archive_status.is_mark_deleted_ && round_id == tenant_archive_status.round_) { if (OB_FAIL(status_array_.remove(j))) { LOG_WARN("failed to remove tenant archive status", K(ret), K(tenant_archive_status)); @@ -276,11 +276,11 @@ int64_t ObExternalBackupPieceInfo::get_write_buf_size() const return size; } -int ObExternalBackupPieceInfo::write_buf(char* buf, const int64_t buf_len, int64_t& pos) const +int ObExternalBackupPieceInfo::write_buf(char *buf, const int64_t buf_len, int64_t &pos) const { int ret = OB_SUCCESS; const int64_t need_size = get_write_buf_size(); - ObBackupCommonHeader* common_header = nullptr; + ObBackupCommonHeader *common_header = nullptr; if (OB_ISNULL(buf) || buf_len - pos < need_size) { ret = OB_INVALID_ARGUMENT; @@ -308,7 +308,7 @@ int ObExternalBackupPieceInfo::write_buf(char* buf, const int64_t buf_len, int64 return ret; } -int ObExternalBackupPieceInfo::read_buf(const char* buf, const int64_t buf_len) +int ObExternalBackupPieceInfo::read_buf(const char *buf, const int64_t buf_len) { int ret = OB_SUCCESS; @@ -317,7 +317,7 @@ int ObExternalBackupPieceInfo::read_buf(const char* buf, const int64_t buf_len) LOG_WARN("invalid args", K(ret), KP(buf), K(buf_len)); } else { int64_t pos = 0; - const ObBackupCommonHeader* common_header = reinterpret_cast(buf + pos); + const ObBackupCommonHeader *common_header = reinterpret_cast(buf + pos); pos += common_header->header_length_; if (OB_FAIL(common_header->check_header_checksum())) { LOG_WARN("failed to check common header", K(ret)); @@ -333,7 +333,7 @@ int ObExternalBackupPieceInfo::read_buf(const char* buf, const int64_t buf_len) return ret; } -int ObExternalBackupPieceInfo::update(const share::ObBackupPieceInfo& piece) // update or insert +int ObExternalBackupPieceInfo::update(const share::ObBackupPieceInfo &piece) // update or insert { int ret = OB_SUCCESS; common::ObSArray tmp_array; @@ -344,7 +344,7 @@ int ObExternalBackupPieceInfo::update(const share::ObBackupPieceInfo& piece) // } for (int64_t i = 0; OB_SUCC(ret) && i < piece_array_.count(); ++i) { - share::ObBackupPieceInfo& cur_piece = piece_array_.at(i); + share::ObBackupPieceInfo &cur_piece = piece_array_.at(i); if (piece.key_ == cur_piece.key_) { is_added = true; FLOG_INFO("update exist piece for external piece info", K(cur_piece), K(piece)); @@ -393,7 +393,7 @@ int ObExternalBackupPieceInfo::update(const share::ObBackupPieceInfo& piece) // return ret; } -int ObExternalBackupPieceInfo::get_piece_array(common::ObIArray& piece_array) +int ObExternalBackupPieceInfo::get_piece_array(common::ObIArray &piece_array) { int ret = OB_SUCCESS; piece_array.reset(); @@ -405,15 +405,15 @@ int ObExternalBackupPieceInfo::get_piece_array(common::ObIArray& piece_keys) // update or insert + const common::ObIArray &piece_keys) // update or insert { int ret = OB_SUCCESS; const ObBackupFileStatus::STATUS dest_file_status = ObBackupFileStatus::BACKUP_FILE_DELETING; for (int64_t i = 0; OB_SUCC(ret) && i < piece_keys.count(); ++i) { - const ObBackupPieceInfoKey& piece_key = piece_keys.at(i); + const ObBackupPieceInfoKey &piece_key = piece_keys.at(i); for (int64_t j = 0; OB_SUCC(ret) && j < piece_array_.count(); ++j) { - ObBackupPieceInfo& cur_piece = piece_array_.at(j); - const ObBackupPieceInfoKey& cur_piece_key = cur_piece.key_; + ObBackupPieceInfo &cur_piece = piece_array_.at(j); + const ObBackupPieceInfoKey &cur_piece_key = cur_piece.key_; if (cur_piece_key == piece_key) { if (ObBackupFileStatus::BACKUP_FILE_DELETING == cur_piece.file_status_ || ObBackupFileStatus::BACKUP_FILE_DELETED == cur_piece.file_status_) { @@ -428,15 +428,15 @@ int ObExternalBackupPieceInfo::mark_deleting( return ret; } -int ObExternalBackupPieceInfo::mark_deleted(const common::ObIArray& piece_keys) +int ObExternalBackupPieceInfo::mark_deleted(const common::ObIArray &piece_keys) { int ret = OB_SUCCESS; const ObBackupFileStatus::STATUS dest_file_status = ObBackupFileStatus::BACKUP_FILE_DELETED; for (int64_t i = 0; OB_SUCC(ret) && i < piece_keys.count(); ++i) { - const ObBackupPieceInfoKey& piece_key = piece_keys.at(i); + const ObBackupPieceInfoKey &piece_key = piece_keys.at(i); for (int64_t j = 0; OB_SUCC(ret) && j < piece_array_.count(); ++j) { - ObBackupPieceInfo& cur_piece = piece_array_.at(j); - const ObBackupPieceInfoKey& cur_piece_key = cur_piece.key_; + ObBackupPieceInfo &cur_piece = piece_array_.at(j); + const ObBackupPieceInfoKey &cur_piece_key = cur_piece.key_; if (cur_piece_key == piece_key) { if (ObBackupFileStatus::BACKUP_FILE_DELETED == cur_piece.file_status_) { // do nothing @@ -454,15 +454,15 @@ int ObExternalBackupPieceInfo::mark_deleted(const common::ObIArray& tenant_ids) + common::ObISQLClient &sql_proxy, common::ObIArray &tenant_ids) { int ret = OB_SUCCESS; ObSqlString sql; @@ -1210,7 +1210,7 @@ int ObLogArchiveBackupInfoMgr::get_all_active_log_archive_tenants( SMART_VAR(ObMySQLProxy::ReadResult, res) { - sqlclient::ObMySQLResult* result = NULL; + sqlclient::ObMySQLResult *result = NULL; if (OB_FAIL(sql.assign_fmt("select tenant_id from %s", OB_ALL_BACKUP_LOG_ARCHIVE_STATUS_V2_TNAME))) { LOG_WARN("failed to assign sql", K(ret)); } else if (OB_FAIL(sql_proxy.read(res, sql.ptr()))) { @@ -1240,13 +1240,13 @@ int ObLogArchiveBackupInfoMgr::get_all_active_log_archive_tenants( } int ObLogArchiveBackupInfoMgr::update_log_archive_backup_info_( - common::ObISQLClient& sql_client, const ObLogArchiveBackupInfo& info) + common::ObISQLClient &sql_client, const ObLogArchiveBackupInfo &info) { int ret = OB_SUCCESS; ObSqlString sql; int64_t affected_rows = -1; - const char* status_str = ObLogArchiveStatus::get_str(info.status_.status_); - const char* dest_name = is_backup_backup_ ? OB_STR_BACKUP_BACKUP_DEST : OB_STR_BACKUP_DEST; + const char *status_str = ObLogArchiveStatus::get_str(info.status_.status_); + const char *dest_name = is_backup_backup_ ? OB_STR_BACKUP_BACKUP_DEST : OB_STR_BACKUP_DEST; if (is_backup_backup_) { // do nothing @@ -1287,13 +1287,13 @@ int ObLogArchiveBackupInfoMgr::update_log_archive_backup_info_( } int ObLogArchiveBackupInfoMgr::update_log_archive_status_( - common::ObISQLClient& sql_client, const ObLogArchiveBackupInfo& info) + common::ObISQLClient &sql_client, const ObLogArchiveBackupInfo &info) { int ret = OB_SUCCESS; ObSqlString sql; int64_t affected_rows = -1; ObDMLSqlSplicer dml_splicer; - const char* status_str = ObLogArchiveStatus::get_str(info.status_.status_); + const char *status_str = ObLogArchiveStatus::get_str(info.status_.status_); const uint64_t real_tenant_id = get_real_tenant_id(info.status_.tenant_id_); if (!info.is_valid() || is_backup_backup_) { @@ -1333,7 +1333,7 @@ int ObLogArchiveBackupInfoMgr::update_log_archive_status_( } int ObLogArchiveBackupInfoMgr::update_extern_log_archive_backup_info( - const ObLogArchiveBackupInfo& info, share::ObIBackupLeaseService& backup_lease_service) + const ObLogArchiveBackupInfo &info, share::ObIBackupLeaseService &backup_lease_service) { int ret = OB_SUCCESS; ObClusterBackupDest cluster_backup_dest; @@ -1375,7 +1375,7 @@ int ObLogArchiveBackupInfoMgr::update_extern_log_archive_backup_info( } int ObLogArchiveBackupInfoMgr::get_extern_backup_info_path_( - const ObClusterBackupDest& cluster_backup_dest, const uint64_t tenant_id, share::ObBackupPath& path) + const ObClusterBackupDest &cluster_backup_dest, const uint64_t tenant_id, share::ObBackupPath &path) { int ret = OB_SUCCESS; @@ -1392,7 +1392,7 @@ int ObLogArchiveBackupInfoMgr::get_extern_backup_info_path_( } int ObLogArchiveBackupInfoMgr::read_extern_log_archive_backup_info( - const ObClusterBackupDest& cluster_backup_dest, const uint64_t tenant_id, ObExternLogArchiveBackupInfo& info) + const ObClusterBackupDest &cluster_backup_dest, const uint64_t tenant_id, ObExternLogArchiveBackupInfo &info) { int ret = OB_SUCCESS; ObBackupPath path; @@ -1410,13 +1410,13 @@ int ObLogArchiveBackupInfoMgr::read_extern_log_archive_backup_info( return ret; } -int ObLogArchiveBackupInfoMgr::write_extern_log_archive_backup_info(const ObClusterBackupDest& cluster_backup_dest, - const uint64_t tenant_id, const ObExternLogArchiveBackupInfo& info, - share::ObIBackupLeaseService& backup_lease_service) +int ObLogArchiveBackupInfoMgr::write_extern_log_archive_backup_info(const ObClusterBackupDest &cluster_backup_dest, + const uint64_t tenant_id, const ObExternLogArchiveBackupInfo &info, + share::ObIBackupLeaseService &backup_lease_service) { int ret = OB_SUCCESS; ObBackupPath path; - char* buf = nullptr; + char *buf = nullptr; int64_t buf_size = info.get_write_buf_size(); ObArenaAllocator allocator; ObStorageUtil util(false /*need retry*/); @@ -1426,7 +1426,7 @@ int ObLogArchiveBackupInfoMgr::write_extern_log_archive_backup_info(const ObClus if (!info.is_valid() || OB_INVALID_TENANT_ID == tenant_id || !cluster_backup_dest.is_valid()) { ret = OB_INVALID_ARGUMENT; LOG_WARN("invalid args", K(ret), K(info), K(tenant_id), K(cluster_backup_dest)); - } else if (OB_ISNULL(buf = reinterpret_cast(allocator.alloc(buf_size)))) { + } else if (OB_ISNULL(buf = reinterpret_cast(allocator.alloc(buf_size)))) { ret = OB_ALLOCATE_MEMORY_FAILED; LOG_WARN("failed to alloc buf", K(ret), K(buf_size)); } else if (OB_FAIL(info.write_buf(buf, buf_size, pos))) { @@ -1449,14 +1449,14 @@ int ObLogArchiveBackupInfoMgr::write_extern_log_archive_backup_info(const ObClus return ret; } -int ObLogArchiveBackupInfoMgr::get_log_archive_history_info(common::ObISQLClient& sql_client, const uint64_t tenant_id, +int ObLogArchiveBackupInfoMgr::get_log_archive_history_info(common::ObISQLClient &sql_client, const uint64_t tenant_id, const int64_t archive_round, const int64_t copy_id, const bool for_update, - ObLogArchiveBackupInfo& archive_backup_info) + ObLogArchiveBackupInfo &archive_backup_info) { int ret = OB_SUCCESS; ObSqlString sql; ObMySQLProxy::ReadResult res; - sqlclient::ObMySQLResult* result = NULL; + sqlclient::ObMySQLResult *result = NULL; ObArray archive_backup_infos; archive_backup_info.reset(); @@ -1515,13 +1515,13 @@ int ObLogArchiveBackupInfoMgr::get_log_archive_history_info(common::ObISQLClient return ret; } -int ObLogArchiveBackupInfoMgr::get_log_archive_history_infos(common::ObISQLClient& sql_client, const uint64_t tenant_id, - const bool for_update, common::ObIArray& infos) +int ObLogArchiveBackupInfoMgr::get_log_archive_history_infos(common::ObISQLClient &sql_client, const uint64_t tenant_id, + const bool for_update, common::ObIArray &infos) { int ret = OB_SUCCESS; ObSqlString sql; ObMySQLProxy::ReadResult res; - sqlclient::ObMySQLResult* result = NULL; + sqlclient::ObMySQLResult *result = NULL; if (tenant_id == OB_INVALID_ID) { ret = OB_INVALID_ARGUMENT; @@ -1556,12 +1556,12 @@ int ObLogArchiveBackupInfoMgr::get_log_archive_history_infos(common::ObISQLClien } int ObLogArchiveBackupInfoMgr::get_all_log_archive_history_infos( - common::ObISQLClient& sql_client, common::ObIArray& infos) + common::ObISQLClient &sql_client, common::ObIArray &infos) { int ret = OB_SUCCESS; ObSqlString sql; ObMySQLProxy::ReadResult res; - sqlclient::ObMySQLResult* result = NULL; + sqlclient::ObMySQLResult *result = NULL; if (OB_FAIL(sql.assign_fmt("select %s,%s,%s,%s, time_to_usec(%s) %s, time_to_usec(%s) %s, %s,%s,%s,%s from %s", OB_STR_TENANT_ID, @@ -1589,13 +1589,13 @@ int ObLogArchiveBackupInfoMgr::get_all_log_archive_history_infos( return ret; } -int ObLogArchiveBackupInfoMgr::get_same_round_log_archive_history_infos(common::ObISQLClient& sql_client, - const int64_t round, const bool for_update, common::ObIArray& infos) +int ObLogArchiveBackupInfoMgr::get_same_round_log_archive_history_infos(common::ObISQLClient &sql_client, + const int64_t round, const bool for_update, common::ObIArray &infos) { int ret = OB_SUCCESS; ObSqlString sql; ObMySQLProxy::ReadResult res; - sqlclient::ObMySQLResult* result = NULL; + sqlclient::ObMySQLResult *result = NULL; if (round < 0) { ret = OB_INVALID_ARGUMENT; @@ -1630,7 +1630,7 @@ int ObLogArchiveBackupInfoMgr::get_same_round_log_archive_history_infos(common:: } int ObLogArchiveBackupInfoMgr::inner_get_log_archvie_history_infos( - sqlclient::ObMySQLResult& result, common::ObIArray& infos) + sqlclient::ObMySQLResult &result, common::ObIArray &infos) { int ret = OB_SUCCESS; while (OB_SUCC(ret)) { @@ -1656,13 +1656,13 @@ int ObLogArchiveBackupInfoMgr::inner_get_log_archvie_history_infos( } int ObLogArchiveBackupInfoMgr::parse_log_archvie_history_status_( - common::sqlclient::ObMySQLResult& result, ObLogArchiveBackupInfo& info) + common::sqlclient::ObMySQLResult &result, ObLogArchiveBackupInfo &info) { int ret = OB_SUCCESS; char backup_dest[share::OB_MAX_BACKUP_DEST_LENGTH] = ""; int64_t tmp_real_str_len = 0; int64_t tmp_compatible = 0; - ObTenantLogArchiveStatus& status = info.status_; + ObTenantLogArchiveStatus &status = info.status_; UNUSED(tmp_real_str_len); EXTRACT_INT_FIELD_MYSQL(result, OB_STR_TENANT_ID, status.tenant_id_, uint64_t); @@ -1706,11 +1706,11 @@ int ObLogArchiveBackupInfoMgr::parse_log_archvie_history_status_( } int ObLogArchiveBackupInfoMgr::inner_read_extern_log_archive_backup_info( - const ObBackupPath& path, const char* storage_info, ObExternLogArchiveBackupInfo& info) + const ObBackupPath &path, const char *storage_info, ObExternLogArchiveBackupInfo &info) { int ret = OB_SUCCESS; int64_t file_length = 0; - char* buf = nullptr; + char *buf = nullptr; int64_t read_size = 0; ObArenaAllocator allocator; ObStorageUtil util(false /*need_retry*/); @@ -1726,7 +1726,7 @@ int ObLogArchiveBackupInfoMgr::inner_read_extern_log_archive_backup_info( } } else if (0 == file_length) { FLOG_INFO("extern log archive backup info is empty", K(ret), K(storage_info), K(path)); - } else if (OB_ISNULL(buf = reinterpret_cast(allocator.alloc(file_length)))) { + } else if (OB_ISNULL(buf = reinterpret_cast(allocator.alloc(file_length)))) { ret = OB_ALLOCATE_MEMORY_FAILED; LOG_WARN("failed to alloc buf", K(ret), K(file_length), K(path)); } else if (OB_FAIL(util.read_single_file(path.get_ptr(), storage_info, buf, file_length, read_size))) { @@ -1743,8 +1743,8 @@ int ObLogArchiveBackupInfoMgr::inner_read_extern_log_archive_backup_info( } int ObLogArchiveBackupInfoMgr::mark_extern_log_archive_backup_info_deleted( - const ObClusterBackupDest& cluster_backup_dest, const uint64_t tenant_id, - const common::ObIArray& round_ids, share::ObIBackupLeaseService& backup_lease_service) + const ObClusterBackupDest &cluster_backup_dest, const uint64_t tenant_id, + const common::ObIArray &round_ids, share::ObIBackupLeaseService &backup_lease_service) { int ret = OB_SUCCESS; ObExternLogArchiveBackupInfo info; @@ -1776,8 +1776,8 @@ int ObLogArchiveBackupInfoMgr::mark_extern_log_archive_backup_info_deleted( } int ObLogArchiveBackupInfoMgr::delete_marked_extern_log_archive_backup_info( - const ObClusterBackupDest& current_backup_dest, const uint64_t tenant_id, - const common::ObIArray& round_ids, bool& is_empty, share::ObIBackupLeaseService& backup_lease_service) + const ObClusterBackupDest ¤t_backup_dest, const uint64_t tenant_id, + const common::ObIArray &round_ids, bool &is_empty, share::ObIBackupLeaseService &backup_lease_service) { int ret = OB_SUCCESS; ObExternLogArchiveBackupInfo info; @@ -1813,13 +1813,13 @@ int ObLogArchiveBackupInfoMgr::delete_marked_extern_log_archive_backup_info( // for backup backup int ObLogArchiveBackupInfoMgr::get_all_backup_backup_log_archive_status( - common::ObISQLClient& sql_client, const bool for_update, common::ObIArray& infos) + common::ObISQLClient &sql_client, const bool for_update, common::ObIArray &infos) { int ret = OB_SUCCESS; infos.reset(); ObSqlString sql; ObMySQLProxy::ReadResult res; - sqlclient::ObMySQLResult* result = NULL; + sqlclient::ObMySQLResult *result = NULL; if (!is_backup_backup_) { ret = OB_INVALID_ARGUMENT; LOG_WARN("can only deal with copy"); @@ -1861,13 +1861,13 @@ int ObLogArchiveBackupInfoMgr::get_all_backup_backup_log_archive_status( return ret; } -int ObLogArchiveBackupInfoMgr::get_backup_backup_log_archive_round_list(common::ObISQLClient& sql_client, - const int64_t log_archive_round, const bool for_update, common::ObIArray& infos) +int ObLogArchiveBackupInfoMgr::get_backup_backup_log_archive_round_list(common::ObISQLClient &sql_client, + const int64_t log_archive_round, const bool for_update, common::ObIArray &infos) { int ret = OB_SUCCESS; ObSqlString sql; ObMySQLProxy::ReadResult res; - sqlclient::ObMySQLResult* result = NULL; + sqlclient::ObMySQLResult *result = NULL; if (!is_backup_backup_) { ret = OB_INVALID_ARGUMENT; @@ -1919,7 +1919,7 @@ int ObLogArchiveBackupInfoMgr::get_backup_backup_log_archive_round_list(common:: } int ObLogArchiveBackupInfoMgr::mark_log_archive_history_info_deleted( - const ObLogArchiveBackupInfo& info, common::ObISQLClient& sql_proxy) + const ObLogArchiveBackupInfo &info, common::ObISQLClient &sql_proxy) { int ret = OB_SUCCESS; ObSqlString sql; @@ -1954,7 +1954,7 @@ int ObLogArchiveBackupInfoMgr::mark_log_archive_history_info_deleted( } int ObLogArchiveBackupInfoMgr::delete_log_archive_info( - const ObLogArchiveBackupInfo& info, common::ObISQLClient& sql_client) + const ObLogArchiveBackupInfo &info, common::ObISQLClient &sql_client) { int ret = OB_SUCCESS; int64_t affected_rows = -1; @@ -1979,7 +1979,7 @@ int ObLogArchiveBackupInfoMgr::delete_log_archive_info( return ret; } -int ObLogArchiveBackupInfoMgr::delete_all_backup_backup_log_archive_info(common::ObISQLClient& sql_client) +int ObLogArchiveBackupInfoMgr::delete_all_backup_backup_log_archive_info(common::ObISQLClient &sql_client) { int ret = OB_SUCCESS; int64_t affected_rows = -1; @@ -1996,7 +1996,7 @@ int ObLogArchiveBackupInfoMgr::delete_all_backup_backup_log_archive_info(common: } int ObLogArchiveBackupInfoMgr::delete_backup_backup_log_archive_info( - const uint64_t tenant_id, common::ObISQLClient& sql_client) + const uint64_t tenant_id, common::ObISQLClient &sql_client) { int ret = OB_SUCCESS; int64_t affected_rows = -1; @@ -2013,14 +2013,14 @@ int ObLogArchiveBackupInfoMgr::delete_backup_backup_log_archive_info( } int ObLogArchiveBackupInfoMgr::get_all_same_round_in_progress_backup_info( - common::ObISQLClient& sql_client, const int64_t round, common::ObIArray& info_list) + common::ObISQLClient &sql_client, const int64_t round, common::ObIArray &info_list) { int ret = OB_SUCCESS; info_list.reset(); ObSqlString sql; ObMySQLProxy::ReadResult res; ObDMLSqlSplicer dml; - sqlclient::ObMySQLResult* result = NULL; + sqlclient::ObMySQLResult *result = NULL; if (round < 0) { ret = OB_INVALID_ARGUMENT; @@ -2069,15 +2069,15 @@ int ObLogArchiveBackupInfoMgr::get_all_same_round_in_progress_backup_info( return ret; } -int ObLogArchiveBackupInfoMgr::get_all_same_round_log_archive_infos(common::ObISQLClient& sql_client, - const uint64_t tenant_id, const int64_t round, common::ObIArray& info_list) +int ObLogArchiveBackupInfoMgr::get_all_same_round_log_archive_infos(common::ObISQLClient &sql_client, + const uint64_t tenant_id, const int64_t round, common::ObIArray &info_list) { int ret = OB_SUCCESS; info_list.reset(); ObSqlString sql; ObMySQLProxy::ReadResult res; ObDMLSqlSplicer dml; - sqlclient::ObMySQLResult* result = NULL; + sqlclient::ObMySQLResult *result = NULL; if (OB_INVALID_ID == tenant_id || round < 0) { ret = OB_INVALID_ARGUMENT; @@ -2122,8 +2122,8 @@ int ObLogArchiveBackupInfoMgr::get_all_same_round_log_archive_infos(common::ObIS return ret; } -int ObLogArchiveBackupInfoMgr::get_backup_piece_list(common::ObISQLClient& sql_client, const uint64_t tenant_id, - const int64_t copy_id, common::ObIArray& info_list) +int ObLogArchiveBackupInfoMgr::get_backup_piece_list(common::ObISQLClient &sql_client, const uint64_t tenant_id, + const int64_t copy_id, common::ObIArray &info_list) { int ret = OB_SUCCESS; info_list.reset(); @@ -2143,8 +2143,8 @@ int ObLogArchiveBackupInfoMgr::get_backup_piece_list(common::ObISQLClient& sql_c return ret; } -int ObLogArchiveBackupInfoMgr::check_has_round_mode_archive_in_dest(common::ObISQLClient& sql_client, - const share::ObBackupDest& backup_dest, const uint64_t tenant_id, bool& has_round_mode) +int ObLogArchiveBackupInfoMgr::check_has_round_mode_archive_in_dest(common::ObISQLClient &sql_client, + const share::ObBackupDest &backup_dest, const uint64_t tenant_id, bool &has_round_mode) { int ret = OB_SUCCESS; has_round_mode = false; @@ -2172,8 +2172,8 @@ int ObLogArchiveBackupInfoMgr::check_has_round_mode_archive_in_dest(common::ObIS return ret; } -int ObLogArchiveBackupInfoMgr::check_has_piece_mode_archive_in_dest(common::ObISQLClient& sql_client, - const share::ObBackupDest& backup_dest, const uint64_t tenant_id, bool& has_piece_mode) +int ObLogArchiveBackupInfoMgr::check_has_piece_mode_archive_in_dest(common::ObISQLClient &sql_client, + const share::ObBackupDest &backup_dest, const uint64_t tenant_id, bool &has_piece_mode) { int ret = OB_SUCCESS; has_piece_mode = false; @@ -2201,8 +2201,8 @@ int ObLogArchiveBackupInfoMgr::check_has_piece_mode_archive_in_dest(common::ObIS return ret; } -int ObLogArchiveBackupInfoMgr::get_backup_piece_tenant_list(common::ObISQLClient& sql_client, - const int64_t backup_piece_id, const int64_t copy_id, common::ObIArray& info_list) +int ObLogArchiveBackupInfoMgr::get_backup_piece_tenant_list(common::ObISQLClient &sql_client, + const int64_t backup_piece_id, const int64_t copy_id, common::ObIArray &info_list) { int ret = OB_SUCCESS; info_list.reset(); @@ -2225,7 +2225,7 @@ int ObLogArchiveBackupInfoMgr::get_backup_piece_tenant_list(common::ObISQLClient int ObLogArchiveBackupInfoMgr::get_backup_piece_copy_list(const int64_t incarnation, const uint64_t tenant_id, const int64_t round_id, const int64_t piece_id, const ObBackupBackupCopyIdLevel copy_id_level, - common::ObISQLClient& sql_client, common::ObIArray& info_list) + common::ObISQLClient &sql_client, common::ObIArray &info_list) { int ret = OB_SUCCESS; ObSqlString sql; @@ -2257,13 +2257,13 @@ int ObLogArchiveBackupInfoMgr::get_backup_piece_copy_list(const int64_t incarnat } int ObLogArchiveBackupInfoMgr::get_all_cluster_level_backup_piece_copy_count(const int64_t incarnation, - const uint64_t tenant_id, const int64_t round_id, const int64_t piece_id, common::ObISQLClient& sql_client, - int64_t& copy_count) + const uint64_t tenant_id, const int64_t round_id, const int64_t piece_id, common::ObISQLClient &sql_client, + int64_t ©_count) { int ret = OB_SUCCESS; ObSqlString sql; copy_count = 0; - sqlclient::ObMySQLResult* result = NULL; + sqlclient::ObMySQLResult *result = NULL; SMART_VAR(ObMySQLProxy::ReadResult, res) { if (OB_FAIL( @@ -2295,8 +2295,8 @@ int ObLogArchiveBackupInfoMgr::get_all_cluster_level_backup_piece_copy_count(con return ret; } -int ObLogArchiveBackupInfoMgr::get_max_backup_piece(common::ObISQLClient& sql_client, const int64_t incarnation, - const uint64_t tenant_id, const int64_t copy_id, share::ObBackupPieceInfo& piece) +int ObLogArchiveBackupInfoMgr::get_max_backup_piece(common::ObISQLClient &sql_client, const int64_t incarnation, + const uint64_t tenant_id, const int64_t copy_id, share::ObBackupPieceInfo &piece) { int ret = OB_SUCCESS; ObSqlString sql; @@ -2325,9 +2325,9 @@ int ObLogArchiveBackupInfoMgr::get_max_backup_piece(common::ObISQLClient& sql_cl return ret; } -int ObLogArchiveBackupInfoMgr::get_min_available_backup_piece_id_in_backup_dest(const share::ObBackupDest& backup_dest, - const int64_t incarnation, const uint64_t tenant_id, const int64_t copy_id, common::ObISQLClient& sql_client, - int64_t& piece_id) +int ObLogArchiveBackupInfoMgr::get_min_available_backup_piece_id_in_backup_dest(const share::ObBackupDest &backup_dest, + const int64_t incarnation, const uint64_t tenant_id, const int64_t copy_id, common::ObISQLClient &sql_client, + int64_t &piece_id) { int ret = OB_SUCCESS; ObSqlString sql; @@ -2362,8 +2362,8 @@ int ObLogArchiveBackupInfoMgr::get_min_available_backup_piece_id_in_backup_dest( } int ObLogArchiveBackupInfoMgr::check_has_incomplete_file_info_smaller_than_backup_piece_id(const int64_t incarnation, - const uint64_t tenant_id, const int64_t backup_piece_id, const share::ObBackupDest& backup_dest, - common::ObISQLClient& sql_client, bool& has_incomplete) + const uint64_t tenant_id, const int64_t backup_piece_id, const share::ObBackupDest &backup_dest, + common::ObISQLClient &sql_client, bool &has_incomplete) { int ret = OB_SUCCESS; has_incomplete = false; @@ -2394,8 +2394,8 @@ int ObLogArchiveBackupInfoMgr::check_has_incomplete_file_info_smaller_than_backu return ret; } -int ObLogArchiveBackupInfoMgr::get_max_frozen_backup_piece(common::ObISQLClient& sql_client, const int64_t incarnation, - const uint64_t tenant_id, const int64_t copy_id, share::ObBackupPieceInfo& piece) +int ObLogArchiveBackupInfoMgr::get_max_frozen_backup_piece(common::ObISQLClient &sql_client, const int64_t incarnation, + const uint64_t tenant_id, const int64_t copy_id, share::ObBackupPieceInfo &piece) { int ret = OB_SUCCESS; ObSqlString sql; @@ -2424,8 +2424,8 @@ int ObLogArchiveBackupInfoMgr::get_max_frozen_backup_piece(common::ObISQLClient& return ret; } -int ObLogArchiveBackupInfoMgr::get_last_piece_in_round(common::ObISQLClient& sql_client, const int64_t incarnation, - const uint64_t tenant_id, const int64_t round_id, share::ObBackupPieceInfo& piece) +int ObLogArchiveBackupInfoMgr::get_last_piece_in_round(common::ObISQLClient &sql_client, const int64_t incarnation, + const uint64_t tenant_id, const int64_t round_id, share::ObBackupPieceInfo &piece) { int ret = OB_SUCCESS; ObSqlString sql; @@ -2451,9 +2451,9 @@ int ObLogArchiveBackupInfoMgr::get_last_piece_in_round(common::ObISQLClient& sql return ret; } -int ObLogArchiveBackupInfoMgr::get_external_backup_piece_info(const share::ObBackupPath& path, - const common::ObString& storage_info, share::ObExternalBackupPieceInfo& info, - share::ObIBackupLeaseService& lease_service) +int ObLogArchiveBackupInfoMgr::get_external_backup_piece_info(const share::ObBackupPath &path, + const common::ObString &storage_info, share::ObExternalBackupPieceInfo &info, + share::ObIBackupLeaseService &lease_service) { int ret = OB_SUCCESS; ObBackupFileSpinLock lock; @@ -2471,11 +2471,11 @@ int ObLogArchiveBackupInfoMgr::get_external_backup_piece_info(const share::ObBac } int ObLogArchiveBackupInfoMgr::sync_backup_backup_piece_info(const uint64_t tenant_id, - const ObClusterBackupDest& src_backup_dest, const ObClusterBackupDest& dst_backup_dest, - share::ObIBackupLeaseService& lease_service) + const ObClusterBackupDest &src_backup_dest, const ObClusterBackupDest &dst_backup_dest, + share::ObIBackupLeaseService &lease_service) { int ret = OB_SUCCESS; - char* buf = NULL; + char *buf = NULL; ObBackupPath src_path, dst_path; ObStorageUtil util(false /*need_retry*/); int64_t file_length = 0; @@ -2496,7 +2496,7 @@ int ObLogArchiveBackupInfoMgr::sync_backup_backup_piece_info(const uint64_t tena LOG_WARN("failed to get file length", K(ret), K(src_path)); } else if (0 == file_length) { FLOG_INFO("external backup piece file is empty", K(ret), K(src_path)); - } else if (OB_ISNULL(buf = reinterpret_cast(allocator.alloc(file_length)))) { + } else if (OB_ISNULL(buf = reinterpret_cast(allocator.alloc(file_length)))) { ret = OB_ALLOCATE_MEMORY_FAILED; LOG_WARN("failed to alloc buf", K(ret), K(file_length), K(src_path)); } else if (OB_FAIL(util.read_single_file( @@ -2512,12 +2512,12 @@ int ObLogArchiveBackupInfoMgr::sync_backup_backup_piece_info(const uint64_t tena } int ObLogArchiveBackupInfoMgr::parse_backup_backup_log_archive_status_( - sqlclient::ObMySQLResult& result, ObLogArchiveBackupInfo& info) + sqlclient::ObMySQLResult &result, ObLogArchiveBackupInfo &info) { int ret = OB_SUCCESS; int real_length = 0; char value_str[OB_INNER_TABLE_DEFAULT_VALUE_LENTH] = {0}; - ObTenantLogArchiveStatus& status = info.status_; + ObTenantLogArchiveStatus &status = info.status_; UNUSED(real_length); // only used for EXTRACT_STRBUF_FIELD_MYSQL EXTRACT_INT_FIELD_MYSQL(result, OB_STR_TENANT_ID, status.tenant_id_, uint64_t); EXTRACT_INT_FIELD_MYSQL(result, OB_STR_INCARNATION, status.incarnation_, int64_t); @@ -2545,12 +2545,12 @@ int ObLogArchiveBackupInfoMgr::parse_backup_backup_log_archive_status_( } int ObLogArchiveBackupInfoMgr::parse_his_backup_backup_log_archive_status_( - sqlclient::ObMySQLResult& result, ObLogArchiveBackupInfo& info) + sqlclient::ObMySQLResult &result, ObLogArchiveBackupInfo &info) { int ret = OB_SUCCESS; int real_length = 0; char value_str[OB_INNER_TABLE_DEFAULT_VALUE_LENTH] = {0}; - ObTenantLogArchiveStatus& status = info.status_; + ObTenantLogArchiveStatus &status = info.status_; EXTRACT_INT_FIELD_MYSQL(result, OB_STR_TENANT_ID, status.tenant_id_, uint64_t); EXTRACT_INT_FIELD_MYSQL(result, OB_STR_INCARNATION, status.incarnation_, int64_t); @@ -2568,9 +2568,9 @@ int ObLogArchiveBackupInfoMgr::parse_his_backup_backup_log_archive_status_( return ret; } -const char* ObLogArchiveBackupInfoMgr::get_cur_table_name_() const +const char *ObLogArchiveBackupInfoMgr::get_cur_table_name_() const { - const char* name = NULL; + const char *name = NULL; if (is_backup_backup_) { name = OB_ALL_BACKUP_BACKUP_LOG_ARCHIVE_STATUS_V2_TNAME; } else { @@ -2579,9 +2579,9 @@ const char* ObLogArchiveBackupInfoMgr::get_cur_table_name_() const return name; } -const char* ObLogArchiveBackupInfoMgr::get_his_table_name_() const +const char *ObLogArchiveBackupInfoMgr::get_his_table_name_() const { - const char* name = NULL; + const char *name = NULL; if (is_backup_backup_) { name = OB_ALL_BACKUP_BACKUP_LOG_ARCHIVE_STATUS_HISTORY_TNAME; } else { @@ -2601,8 +2601,8 @@ uint64_t ObLogArchiveBackupInfoMgr::get_real_tenant_id(const uint64_t normal_ten return real_tenant_id; } -int ObLogArchiveBackupInfoMgr::get_non_frozen_backup_piece(common::ObISQLClient& sql_client, const bool for_update, - const ObLogArchiveBackupInfo& info, ObNonFrozenBackupPieceInfo& non_frozen_piece) +int ObLogArchiveBackupInfoMgr::get_non_frozen_backup_piece(common::ObISQLClient &sql_client, const bool for_update, + const ObLogArchiveBackupInfo &info, ObNonFrozenBackupPieceInfo &non_frozen_piece) { int ret = OB_SUCCESS; non_frozen_piece.reset(); @@ -2626,14 +2626,14 @@ int ObLogArchiveBackupInfoMgr::get_non_frozen_backup_piece(common::ObISQLClient& return ret; } -int ObLogArchiveBackupInfoMgr::get_non_frozen_backup_piece_(common::ObISQLClient& sql_client, const bool for_update, - const share::ObBackupPieceInfoKey& cur_key, ObNonFrozenBackupPieceInfo& non_frozen_piece) +int ObLogArchiveBackupInfoMgr::get_non_frozen_backup_piece_(common::ObISQLClient &sql_client, const bool for_update, + const share::ObBackupPieceInfoKey &cur_key, ObNonFrozenBackupPieceInfo &non_frozen_piece) { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; ObSqlString sql; ObMySQLProxy::ReadResult res; - sqlclient::ObMySQLResult* result = NULL; + sqlclient::ObMySQLResult *result = NULL; int64_t prev_piece_id = 0; non_frozen_piece.reset(); @@ -2704,13 +2704,13 @@ int ObLogArchiveBackupInfoMgr::get_non_frozen_backup_piece_(common::ObISQLClient } int ObLogArchiveBackupInfoMgr::get_backup_piece_list_( - common::ObISQLClient& proxy, const common::ObSqlString& sql, common::ObIArray& piece_list) + common::ObISQLClient &proxy, const common::ObSqlString &sql, common::ObIArray &piece_list) { int ret = OB_SUCCESS; piece_list.reset(); SMART_VAR(ObMySQLProxy::MySQLResult, res) { - sqlclient::ObMySQLResult* result = NULL; + sqlclient::ObMySQLResult *result = NULL; if (OB_UNLIKELY(!sql.is_valid())) { ret = OB_INVALID_ARGUMENT; LOG_WARN("invalid arguments", KR(ret), K(sql)); @@ -2740,7 +2740,7 @@ int ObLogArchiveBackupInfoMgr::get_backup_piece_list_( return ret; } -int ObLogArchiveBackupInfoMgr::parse_backup_piece_(sqlclient::ObMySQLResult& result, ObBackupPieceInfo& info) +int ObLogArchiveBackupInfoMgr::parse_backup_piece_(sqlclient::ObMySQLResult &result, ObBackupPieceInfo &info) { int ret = OB_SUCCESS; int real_length = 0; @@ -2799,8 +2799,8 @@ int ObLogArchiveBackupInfoMgr::parse_backup_piece_(sqlclient::ObMySQLResult& res return ret; } -int ObLogArchiveBackupInfoMgr::get_non_frozen_backup_piece(common::ObISQLClient& sql_client, const bool for_update, - const share::ObBackupPieceInfoKey& cur_key, share::ObNonFrozenBackupPieceInfo& piece) +int ObLogArchiveBackupInfoMgr::get_non_frozen_backup_piece(common::ObISQLClient &sql_client, const bool for_update, + const share::ObBackupPieceInfoKey &cur_key, share::ObNonFrozenBackupPieceInfo &piece) { int ret = OB_SUCCESS; piece.reset(); @@ -2814,14 +2814,14 @@ int ObLogArchiveBackupInfoMgr::get_non_frozen_backup_piece(common::ObISQLClient& return ret; } -int ObLogArchiveBackupInfoMgr::get_backup_piece(common::ObISQLClient& sql_client, const bool for_update, - const share::ObBackupPieceInfoKey& cur_key, share::ObBackupPieceInfo& piece) +int ObLogArchiveBackupInfoMgr::get_backup_piece(common::ObISQLClient &sql_client, const bool for_update, + const share::ObBackupPieceInfoKey &cur_key, share::ObBackupPieceInfo &piece) { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; ObSqlString sql; ObMySQLProxy::ReadResult res; - sqlclient::ObMySQLResult* result = NULL; + sqlclient::ObMySQLResult *result = NULL; piece.reset(); if (!cur_key.is_valid()) { @@ -2870,7 +2870,7 @@ int ObLogArchiveBackupInfoMgr::get_backup_piece(common::ObISQLClient& sql_client } int ObLogArchiveBackupInfoMgr::update_backup_piece( - ObMySQLTransaction& trans, const ObNonFrozenBackupPieceInfo& non_frozen_piece) + ObMySQLTransaction &trans, const ObNonFrozenBackupPieceInfo &non_frozen_piece) { int ret = OB_SUCCESS; @@ -2888,7 +2888,7 @@ int ObLogArchiveBackupInfoMgr::update_backup_piece( } int ObLogArchiveBackupInfoMgr::update_backup_piece( - common::ObISQLClient& sql_client, const share::ObBackupPieceInfo& piece) + common::ObISQLClient &sql_client, const share::ObBackupPieceInfo &piece) { int ret = OB_SUCCESS; ObSqlString sql; @@ -2939,7 +2939,7 @@ int ObLogArchiveBackupInfoMgr::update_backup_piece( // update tenant_clog_piece_info/cluster_clog_piece_info and single piece info int ObLogArchiveBackupInfoMgr::update_external_backup_piece( - const share::ObNonFrozenBackupPieceInfo& piece, share::ObIBackupLeaseService& backup_lease_service) + const share::ObNonFrozenBackupPieceInfo &piece, share::ObIBackupLeaseService &backup_lease_service) { int ret = OB_SUCCESS; const bool is_backup_backup = false; @@ -2971,7 +2971,7 @@ int ObLogArchiveBackupInfoMgr::update_external_backup_piece( } int ObLogArchiveBackupInfoMgr::update_external_backup_piece( - const ObBackupPieceInfo& piece, share::ObIBackupLeaseService& backup_lease_service) + const ObBackupPieceInfo &piece, share::ObIBackupLeaseService &backup_lease_service) { int ret = OB_SUCCESS; const bool is_backup_backup = false; @@ -2983,8 +2983,8 @@ int ObLogArchiveBackupInfoMgr::update_external_backup_piece( } int ObLogArchiveBackupInfoMgr::update_external_backup_backup_piece( - const share::ObClusterBackupDest& cluster_backup_dest, const ObBackupPieceInfo& piece, - share::ObIBackupLeaseService& backup_lease_service) + const share::ObClusterBackupDest &cluster_backup_dest, const ObBackupPieceInfo &piece, + share::ObIBackupLeaseService &backup_lease_service) { int ret = OB_SUCCESS; const bool is_backup_backup = true; @@ -2998,7 +2998,7 @@ int ObLogArchiveBackupInfoMgr::update_external_backup_backup_piece( } int ObLogArchiveBackupInfoMgr::update_external_single_backup_piece_info( - const ObBackupPieceInfo& piece, share::ObIBackupLeaseService& backup_lease_service) + const ObBackupPieceInfo &piece, share::ObIBackupLeaseService &backup_lease_service) { int ret = OB_SUCCESS; if (OB_FAIL(write_external_single_backup_piece_info_(piece, backup_lease_service))) { @@ -3009,7 +3009,7 @@ int ObLogArchiveBackupInfoMgr::update_external_single_backup_piece_info( // for cluster or tenant int ObLogArchiveBackupInfoMgr::update_external_backup_piece_( - const ObBackupPieceInfo& piece, bool is_backup_backup, share::ObIBackupLeaseService& backup_lease_service) + const ObBackupPieceInfo &piece, bool is_backup_backup, share::ObIBackupLeaseService &backup_lease_service) { int ret = OB_SUCCESS; ObClusterBackupDest cluster_backup_dest; @@ -3026,7 +3026,7 @@ int ObLogArchiveBackupInfoMgr::update_external_backup_piece_( // for cluster or tenant int ObLogArchiveBackupInfoMgr::update_external_backup_piece_( - const ObNonFrozenBackupPieceInfo& piece, bool is_backup_backup, share::ObIBackupLeaseService& backup_lease_service) + const ObNonFrozenBackupPieceInfo &piece, bool is_backup_backup, share::ObIBackupLeaseService &backup_lease_service) { int ret = OB_SUCCESS; ObClusterBackupDest cluster_backup_dest; @@ -3042,8 +3042,8 @@ int ObLogArchiveBackupInfoMgr::update_external_backup_piece_( return ret; } -int ObLogArchiveBackupInfoMgr::update_external_backup_piece_(const share::ObClusterBackupDest& cluster_backup_dest, - const ObBackupPieceInfo piece, bool is_backup_backup, share::ObIBackupLeaseService& backup_lease_service) +int ObLogArchiveBackupInfoMgr::update_external_backup_piece_(const share::ObClusterBackupDest &cluster_backup_dest, + const ObBackupPieceInfo piece, bool is_backup_backup, share::ObIBackupLeaseService &backup_lease_service) { int ret = OB_SUCCESS; ObExternalBackupPieceInfo external_info; @@ -3069,9 +3069,9 @@ int ObLogArchiveBackupInfoMgr::update_external_backup_piece_(const share::ObClus return ret; } -int ObLogArchiveBackupInfoMgr::update_external_backup_piece_(const share::ObClusterBackupDest& cluster_backup_dest, - const share::ObNonFrozenBackupPieceInfo& piece, bool is_backup_backup, - share::ObIBackupLeaseService& backup_lease_service) +int ObLogArchiveBackupInfoMgr::update_external_backup_piece_(const share::ObClusterBackupDest &cluster_backup_dest, + const share::ObNonFrozenBackupPieceInfo &piece, bool is_backup_backup, + share::ObIBackupLeaseService &backup_lease_service) { int ret = OB_SUCCESS; ObExternalBackupPieceInfo external_info; @@ -3098,12 +3098,12 @@ int ObLogArchiveBackupInfoMgr::update_external_backup_piece_(const share::ObClus } return ret; } -int ObLogArchiveBackupInfoMgr::inner_write_extern_log_archive_backup_piece_info_(const ObBackupPath& path, - const char* storage_info, const share::ObExternalBackupPieceInfo& info, - share::ObIBackupLeaseService& backup_lease_service) +int ObLogArchiveBackupInfoMgr::inner_write_extern_log_archive_backup_piece_info_(const ObBackupPath &path, + const char *storage_info, const share::ObExternalBackupPieceInfo &info, + share::ObIBackupLeaseService &backup_lease_service) { int ret = OB_SUCCESS; - char* buf = nullptr; + char *buf = nullptr; int64_t buf_size = info.get_write_buf_size(); ObArenaAllocator allocator; ObStorageUtil util(false /*need retry*/); @@ -3113,7 +3113,7 @@ int ObLogArchiveBackupInfoMgr::inner_write_extern_log_archive_backup_piece_info_ if (!info.is_valid() || OB_ISNULL(storage_info) || path.is_empty()) { ret = OB_INVALID_ARGUMENT; LOG_WARN("invalid args", K(ret), K(info), K(storage_info), K(path)); - } else if (OB_ISNULL(buf = reinterpret_cast(allocator.alloc(buf_size)))) { + } else if (OB_ISNULL(buf = reinterpret_cast(allocator.alloc(buf_size)))) { ret = OB_ALLOCATE_MEMORY_FAILED; LOG_WARN("failed to alloc buf", K(ret), K(buf_size)); } else if (OB_FAIL(info.write_buf(buf, buf_size, pos))) { @@ -3134,12 +3134,12 @@ int ObLogArchiveBackupInfoMgr::inner_write_extern_log_archive_backup_piece_info_ return ret; } -int ObLogArchiveBackupInfoMgr::inner_read_external_backup_piece_info_(const ObBackupPath& path, - const char* storage_info, ObExternalBackupPieceInfo& info, share::ObIBackupLeaseService& backup_lease_service) +int ObLogArchiveBackupInfoMgr::inner_read_external_backup_piece_info_(const ObBackupPath &path, + const char *storage_info, ObExternalBackupPieceInfo &info, share::ObIBackupLeaseService &backup_lease_service) { int ret = OB_SUCCESS; int64_t file_length = 0; - char* buf = nullptr; + char *buf = nullptr; int64_t read_size = 0; ObArenaAllocator allocator; ObStorageUtil util(false /*need_retry*/); @@ -3156,7 +3156,7 @@ int ObLogArchiveBackupInfoMgr::inner_read_external_backup_piece_info_(const ObBa } } else if (0 == file_length) { FLOG_INFO("external log archive backup piece info is empty", K(ret), K(storage_info), K(path)); - } else if (OB_ISNULL(buf = reinterpret_cast(allocator.alloc(file_length)))) { + } else if (OB_ISNULL(buf = reinterpret_cast(allocator.alloc(file_length)))) { ret = OB_ALLOCATE_MEMORY_FAILED; LOG_WARN("failed to alloc buf", K(ret), K(file_length), K(path)); } else if (OB_FAIL(backup_lease_service.check_lease())) { @@ -3174,8 +3174,8 @@ int ObLogArchiveBackupInfoMgr::inner_read_external_backup_piece_info_(const ObBa return ret; } -int ObLogArchiveBackupInfoMgr::get_external_backup_piece_path_(const ObClusterBackupDest& cluster_backup_dest, - const uint64_t tenant_id, const bool is_backup_backup, ObBackupPath& path) +int ObLogArchiveBackupInfoMgr::get_external_backup_piece_path_(const ObClusterBackupDest &cluster_backup_dest, + const uint64_t tenant_id, const bool is_backup_backup, ObBackupPath &path) { int ret = OB_SUCCESS; @@ -3195,7 +3195,7 @@ int ObLogArchiveBackupInfoMgr::get_external_backup_piece_path_(const ObClusterBa // for single piece of tenant int ObLogArchiveBackupInfoMgr::write_external_single_backup_piece_info_( - const ObBackupPieceInfo& piece, share::ObIBackupLeaseService& backup_lease_service) + const ObBackupPieceInfo &piece, share::ObIBackupLeaseService &backup_lease_service) { int ret = OB_SUCCESS; ObBackupPath path; @@ -3204,15 +3204,15 @@ int ObLogArchiveBackupInfoMgr::write_external_single_backup_piece_info_( ObArenaAllocator allocator; ObStorageUtil util(false /*need retry*/); int64_t pos = 0; - char* buf = nullptr; - ObBackupCommonHeader* common_header = nullptr; + char *buf = nullptr; + ObBackupCommonHeader *common_header = nullptr; if (!path.is_empty() || !piece.is_valid()) { ret = OB_INVALID_ARGUMENT; LOG_WARN("invalid args", K(ret), K(path), K(piece)); } else if (OB_FAIL(cluster_backup_dest.set(piece.backup_dest_.ptr(), piece.key_.incarnation_))) { LOG_WARN("failed to set cluster backup dest", K(ret), K(piece)); - } else if (OB_ISNULL(buf = reinterpret_cast(allocator.alloc(buf_len)))) { + } else if (OB_ISNULL(buf = reinterpret_cast(allocator.alloc(buf_len)))) { ret = OB_ALLOCATE_MEMORY_FAILED; LOG_WARN("failed to alloc buf", K(ret), K(buf_len)); } else { @@ -3261,12 +3261,12 @@ int ObLogArchiveBackupInfoMgr::write_external_single_backup_piece_info_( return ret; } -int ObLogArchiveBackupInfoMgr::read_external_single_backup_piece_info(const ObBackupPath& path, - const ObString& storage_info, ObBackupPieceInfo& piece, share::ObIBackupLeaseService& backup_lease_service) +int ObLogArchiveBackupInfoMgr::read_external_single_backup_piece_info(const ObBackupPath &path, + const ObString &storage_info, ObBackupPieceInfo &piece, share::ObIBackupLeaseService &backup_lease_service) { int ret = OB_SUCCESS; int64_t file_length = 0; - char* buf = nullptr; + char *buf = nullptr; int64_t read_size = 0; ObArenaAllocator allocator; ObStorageUtil util(false /*need_retry*/); @@ -3285,7 +3285,7 @@ int ObLogArchiveBackupInfoMgr::read_external_single_backup_piece_info(const ObBa } else if (0 == file_length || file_length < sizeof(ObBackupCommonHeader)) { ret = OB_ERR_UNEXPECTED; LOG_WARN("single piece info file is not incomplete", K(ret), K(path), K(storage_info)); - } else if (OB_ISNULL(buf = reinterpret_cast(allocator.alloc(file_length)))) { + } else if (OB_ISNULL(buf = reinterpret_cast(allocator.alloc(file_length)))) { ret = OB_ALLOCATE_MEMORY_FAILED; LOG_WARN("failed to alloc buf", K(ret), K(file_length), K(path)); } else if (OB_FAIL(backup_lease_service.check_lease())) { @@ -3297,7 +3297,7 @@ int ObLogArchiveBackupInfoMgr::read_external_single_backup_piece_info(const ObBa LOG_WARN("read file length not match", K(ret), K(file_length), K(read_size), K(path)); } else { int64_t pos = 0; - const ObBackupCommonHeader* common_header = reinterpret_cast(buf + pos); + const ObBackupCommonHeader *common_header = reinterpret_cast(buf + pos); pos += common_header->header_length_; if (OB_FAIL(common_header->check_header_checksum())) { LOG_WARN("failed to check common header", K(ret)); @@ -3316,14 +3316,14 @@ int ObLogArchiveBackupInfoMgr::read_external_single_backup_piece_info(const ObBa return ret; } -int ObLogArchiveBackupInfoMgr::get_round_backup_piece_infos(common::ObISQLClient& sql_client, const bool for_update, +int ObLogArchiveBackupInfoMgr::get_round_backup_piece_infos(common::ObISQLClient &sql_client, const bool for_update, const uint64_t tenant_id, const int64_t incarnation, const int64_t log_archive_round, const bool is_backup_backup, - common::ObIArray& piece_infos) + common::ObIArray &piece_infos) { int ret = OB_SUCCESS; ObSqlString sql; ObMySQLProxy::ReadResult res; - sqlclient::ObMySQLResult* result = NULL; + sqlclient::ObMySQLResult *result = NULL; piece_infos.reset(); if (tenant_id == OB_INVALID_ID || incarnation <= 0 || log_archive_round <= 0) { @@ -3376,13 +3376,13 @@ int ObLogArchiveBackupInfoMgr::get_round_backup_piece_infos(common::ObISQLClient return ret; } -int ObLogArchiveBackupInfoMgr::get_backup_log_archive_history_infos(common::ObISQLClient& sql_client, - const uint64_t tenant_id, const bool for_update, common::ObIArray& infos) +int ObLogArchiveBackupInfoMgr::get_backup_log_archive_history_infos(common::ObISQLClient &sql_client, + const uint64_t tenant_id, const bool for_update, common::ObIArray &infos) { int ret = OB_SUCCESS; ObSqlString sql; ObMySQLProxy::ReadResult res; - sqlclient::ObMySQLResult* result = NULL; + sqlclient::ObMySQLResult *result = NULL; if (tenant_id == OB_INVALID_ID) { ret = OB_INVALID_ARGUMENT; @@ -3418,13 +3418,13 @@ int ObLogArchiveBackupInfoMgr::get_backup_log_archive_history_infos(common::ObIS return ret; } -int ObLogArchiveBackupInfoMgr::get_original_backup_log_piece_infos(common::ObISQLClient& sql_client, - const bool for_update, const uint64_t tenant_id, common::ObIArray& piece_infos) +int ObLogArchiveBackupInfoMgr::get_original_backup_log_piece_infos(common::ObISQLClient &sql_client, + const bool for_update, const uint64_t tenant_id, common::ObIArray &piece_infos) { int ret = OB_SUCCESS; ObSqlString sql; ObMySQLProxy::ReadResult res; - sqlclient::ObMySQLResult* result = NULL; + sqlclient::ObMySQLResult *result = NULL; const int64_t incarnation = OB_START_INCARNATION; piece_infos.reset(); const ObBackupFileStatus::STATUS file_status = ObBackupFileStatus::BACKUP_FILE_DELETED; @@ -3475,8 +3475,8 @@ int ObLogArchiveBackupInfoMgr::get_original_backup_log_piece_infos(common::ObISQ // piece n // And backup backup log use piece as basic cell to backup data. // Inorder to deal with this condition, we use some piece infos to get round information for compatibility -int ObLogArchiveBackupInfoMgr::get_backup_log_archive_info_from_original_piece_infos(common::ObISQLClient& sql_client, - const uint64_t tenant_id, const bool for_update, common::ObIArray& infos) +int ObLogArchiveBackupInfoMgr::get_backup_log_archive_info_from_original_piece_infos(common::ObISQLClient &sql_client, + const uint64_t tenant_id, const bool for_update, common::ObIArray &infos) { int ret = OB_SUCCESS; infos.reset(); @@ -3497,7 +3497,7 @@ int ObLogArchiveBackupInfoMgr::get_backup_log_archive_info_from_original_piece_i LOG_WARN("backup piece infos can not sort", K(ret), K(piece_infos)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < piece_infos.count(); ++i) { - const ObBackupPieceInfo& backup_piece = piece_infos.at(i); + const ObBackupPieceInfo &backup_piece = piece_infos.at(i); if (0 == i) { if (OB_FAIL(trans_log_archive_info_from_piece_info_(backup_piece, log_archive_info))) { LOG_WARN("failed to trans log archive info from piece info", K(ret), K(backup_piece)); @@ -3537,9 +3537,9 @@ int ObLogArchiveBackupInfoMgr::get_backup_log_archive_info_from_original_piece_i return ret; } -int ObLogArchiveBackupInfoMgr::get_backup_log_archive_info_from_piece_info(common::ObISQLClient& sql_client, +int ObLogArchiveBackupInfoMgr::get_backup_log_archive_info_from_piece_info(common::ObISQLClient &sql_client, const uint64_t tenant_id, const int64_t piece_id, const int64_t copy_id, const bool for_update, - ObLogArchiveBackupInfo& info) + ObLogArchiveBackupInfo &info) { int ret = OB_SUCCESS; info.reset(); @@ -3558,7 +3558,7 @@ int ObLogArchiveBackupInfoMgr::get_backup_log_archive_info_from_piece_info(commo } int ObLogArchiveBackupInfoMgr::trans_log_archive_info_from_piece_info_( - const ObBackupPieceInfo& piece_info, ObLogArchiveBackupInfo& log_archive_info) + const ObBackupPieceInfo &piece_info, ObLogArchiveBackupInfo &log_archive_info) { int ret = OB_SUCCESS; log_archive_info.reset(); @@ -3587,13 +3587,13 @@ int ObLogArchiveBackupInfoMgr::trans_log_archive_info_from_piece_info_( return ret; } -int ObLogArchiveBackupInfoMgr::get_backup_piece(common::ObISQLClient& sql_client, const bool for_update, - const uint64_t tenant_id, const int64_t backup_piece_id, const int64_t copy_id, ObBackupPieceInfo& piece_info) +int ObLogArchiveBackupInfoMgr::get_backup_piece(common::ObISQLClient &sql_client, const bool for_update, + const uint64_t tenant_id, const int64_t backup_piece_id, const int64_t copy_id, ObBackupPieceInfo &piece_info) { int ret = OB_SUCCESS; ObSqlString sql; ObMySQLProxy::ReadResult res; - sqlclient::ObMySQLResult* result = NULL; + sqlclient::ObMySQLResult *result = NULL; piece_info.reset(); if (!sql_client.is_active() || tenant_id == OB_INVALID_ID || backup_piece_id < 0 || copy_id < 0) { @@ -3625,13 +3625,13 @@ int ObLogArchiveBackupInfoMgr::get_backup_piece(common::ObISQLClient& sql_client return ret; } -int ObLogArchiveBackupInfoMgr::get_tenant_ids_with_piece_id(common::ObISQLClient& sql_client, - const int64_t backup_piece_id, const int64_t copy_id, common::ObIArray& tenant_ids) +int ObLogArchiveBackupInfoMgr::get_tenant_ids_with_piece_id(common::ObISQLClient &sql_client, + const int64_t backup_piece_id, const int64_t copy_id, common::ObIArray &tenant_ids) { int ret = OB_SUCCESS; ObSqlString sql; ObMySQLProxy::ReadResult res; - sqlclient::ObMySQLResult* result = NULL; + sqlclient::ObMySQLResult *result = NULL; tenant_ids.reset(); if (!sql_client.is_active() || backup_piece_id < 0 || copy_id < 0) { @@ -3671,15 +3671,15 @@ int ObLogArchiveBackupInfoMgr::get_tenant_ids_with_piece_id(common::ObISQLClient return ret; } -int ObLogArchiveBackupInfoMgr::get_tenant_ids_with_round_id(common::ObISQLClient& sql_client, const bool for_update, - const int64_t backup_round_id, const int64_t copy_id, common::ObIArray& tenant_ids) +int ObLogArchiveBackupInfoMgr::get_tenant_ids_with_round_id(common::ObISQLClient &sql_client, const bool for_update, + const int64_t backup_round_id, const int64_t copy_id, common::ObIArray &tenant_ids) { int ret = OB_SUCCESS; ObSqlString sql; ObMySQLProxy::ReadResult res; - sqlclient::ObMySQLResult* result = NULL; + sqlclient::ObMySQLResult *result = NULL; tenant_ids.reset(); - const char* table_name = NULL; + const char *table_name = NULL; if (!sql_client.is_active() || backup_round_id < 0 || copy_id < 0) { ret = OB_INVALID_ARGUMENT; @@ -3721,13 +3721,13 @@ int ObLogArchiveBackupInfoMgr::get_tenant_ids_with_round_id(common::ObISQLClient return ret; } -int ObLogArchiveBackupInfoMgr::get_backup_tenant_ids_with_snapshot(common::ObISQLClient& sql_client, - const int64_t snapshot_version, const bool is_backup_backup, common::ObIArray& tenant_ids) +int ObLogArchiveBackupInfoMgr::get_backup_tenant_ids_with_snapshot(common::ObISQLClient &sql_client, + const int64_t snapshot_version, const bool is_backup_backup, common::ObIArray &tenant_ids) { int ret = OB_SUCCESS; ObSqlString sql; ObMySQLProxy::ReadResult res; - sqlclient::ObMySQLResult* result = NULL; + sqlclient::ObMySQLResult *result = NULL; tenant_ids.reset(); if (!sql_client.is_active() || snapshot_version < 0) { @@ -3767,9 +3767,9 @@ int ObLogArchiveBackupInfoMgr::get_backup_tenant_ids_with_snapshot(common::ObISQ return ret; } -int ObLogArchiveBackupInfoMgr::mark_extern_backup_piece_deleting(const ObClusterBackupDest& cluster_backup_dest, - const uint64_t tenant_id, const common::ObIArray& piece_keys, - const bool is_backup_backup, share::ObIBackupLeaseService& backup_lease_service) +int ObLogArchiveBackupInfoMgr::mark_extern_backup_piece_deleting(const ObClusterBackupDest &cluster_backup_dest, + const uint64_t tenant_id, const common::ObIArray &piece_keys, + const bool is_backup_backup, share::ObIBackupLeaseService &backup_lease_service) { int ret = OB_SUCCESS; ObExternalBackupPieceInfo external_info; @@ -3796,9 +3796,9 @@ int ObLogArchiveBackupInfoMgr::mark_extern_backup_piece_deleting(const ObCluster return ret; } -int ObLogArchiveBackupInfoMgr::mark_extern_backup_piece_deleted(const ObClusterBackupDest& current_backup_dest, - const uint64_t tenant_id, const common::ObIArray& piece_keys, - const bool is_backup_backup, bool& is_all_deleted, share::ObIBackupLeaseService& backup_lease_service) +int ObLogArchiveBackupInfoMgr::mark_extern_backup_piece_deleted(const ObClusterBackupDest ¤t_backup_dest, + const uint64_t tenant_id, const common::ObIArray &piece_keys, + const bool is_backup_backup, bool &is_all_deleted, share::ObIBackupLeaseService &backup_lease_service) { int ret = OB_SUCCESS; ObExternalBackupPieceInfo external_info; @@ -3828,7 +3828,7 @@ int ObLogArchiveBackupInfoMgr::mark_extern_backup_piece_deleted(const ObClusterB } int ObLogArchiveBackupInfoMgr::get_extern_backup_info_path( - const ObClusterBackupDest& cluster_backup_dest, const uint64_t tenant_id, share::ObBackupPath& path) + const ObClusterBackupDest &cluster_backup_dest, const uint64_t tenant_id, share::ObBackupPath &path) { int ret = OB_SUCCESS; if (OB_FAIL(get_extern_backup_info_path_(cluster_backup_dest, tenant_id, path))) { @@ -3837,8 +3837,8 @@ int ObLogArchiveBackupInfoMgr::get_extern_backup_info_path( return ret; } -int ObLogArchiveBackupInfoMgr::get_external_backup_piece_path(const ObClusterBackupDest& cluster_backup_dest, - const uint64_t tenant_id, const bool is_backup_backup, share::ObBackupPath& path) +int ObLogArchiveBackupInfoMgr::get_external_backup_piece_path(const ObClusterBackupDest &cluster_backup_dest, + const uint64_t tenant_id, const bool is_backup_backup, share::ObBackupPath &path) { int ret = OB_SUCCESS; if (OB_FAIL(get_external_backup_piece_path_(cluster_backup_dest, tenant_id, is_backup_backup, path))) { @@ -3848,7 +3848,7 @@ int ObLogArchiveBackupInfoMgr::get_external_backup_piece_path(const ObClusterBac } int ObLogArchiveBackupInfoMgr::delete_extern_backup_info_file( - const ObClusterBackupDest& cluster_backup_dest, const uint64_t tenant_id) + const ObClusterBackupDest &cluster_backup_dest, const uint64_t tenant_id) { int ret = OB_SUCCESS; ObStorageUtil util(false /*need_retry*/); @@ -3876,7 +3876,7 @@ int ObLogArchiveBackupInfoMgr::delete_extern_backup_info_file( } int ObLogArchiveBackupInfoMgr::update_extern_backup_info_file_timestamp( - const ObClusterBackupDest& cluster_backup_dest, const uint64_t tenant_id) + const ObClusterBackupDest &cluster_backup_dest, const uint64_t tenant_id) { int ret = OB_SUCCESS; ObBackupPath path; @@ -3898,8 +3898,8 @@ int ObLogArchiveBackupInfoMgr::update_extern_backup_info_file_timestamp( return ret; } -int ObLogArchiveBackupInfoMgr::delete_extern_backup_piece_file(const ObClusterBackupDest& cluster_backup_dest, - const uint64_t tenant_id, const bool is_backup_backup, share::ObIBackupLeaseService& backup_lease_service) +int ObLogArchiveBackupInfoMgr::delete_extern_backup_piece_file(const ObClusterBackupDest &cluster_backup_dest, + const uint64_t tenant_id, const bool is_backup_backup, share::ObIBackupLeaseService &backup_lease_service) { int ret = OB_SUCCESS; ObStorageUtil util(false /*need_retry*/); @@ -3924,12 +3924,14 @@ int ObLogArchiveBackupInfoMgr::delete_extern_backup_piece_file(const ObClusterBa LOG_WARN("log archive info is not empty, cannot delete it", K(ret), K(cluster_backup_dest), K(tenant_id)); } else if (OB_FAIL(util.del_file(path.get_ptr(), cluster_backup_dest.get_storage_info()))) { LOG_WARN("failed to delete file", K(ret), K(path), K(cluster_backup_dest)); + } else { + LOG_INFO("succeed to delete extern backup piece file", K(path), K(external_info)); } return ret; } int ObLogArchiveBackupInfoMgr::update_extern_backup_piece_file_timestamp( - const ObClusterBackupDest& cluster_backup_dest, const uint64_t tenant_id, const bool is_backup_backup) + const ObClusterBackupDest &cluster_backup_dest, const uint64_t tenant_id, const bool is_backup_backup) { int ret = OB_SUCCESS; ObBackupPath path; @@ -3951,9 +3953,9 @@ int ObLogArchiveBackupInfoMgr::update_extern_backup_piece_file_timestamp( return ret; } -int ObLogArchiveBackupInfoMgr::get_tenant_backup_piece_infos(common::ObISQLClient& sql_client, +int ObLogArchiveBackupInfoMgr::get_tenant_backup_piece_infos(common::ObISQLClient &sql_client, const int64_t incarnation, const uint64_t tenant_id, const int64_t round_id, const int64_t piece_id, - common::ObIArray& piece_infos) + common::ObIArray &piece_infos) { int ret = OB_SUCCESS; ObSqlString sql; @@ -3977,15 +3979,15 @@ int ObLogArchiveBackupInfoMgr::get_tenant_backup_piece_infos(common::ObISQLClien } int ObLogArchiveBackupInfoMgr::get_max_backup_piece_id_in_backup_dest( - const share::ObBackupBackupCopyIdLevel copy_id_level, const share::ObBackupDest& backup_dest, - const uint64_t tenant_id, common::ObISQLClient& sql_client, int64_t& max_piece_id) + const share::ObBackupBackupCopyIdLevel copy_id_level, const share::ObBackupDest &backup_dest, + const uint64_t tenant_id, common::ObISQLClient &sql_client, int64_t &max_piece_id) { int ret = OB_SUCCESS; max_piece_id = 0; int64_t left_copy_id = 0; int64_t right_copy_id = 0; ObSqlString sql; - sqlclient::ObMySQLResult* result = NULL; + sqlclient::ObMySQLResult *result = NULL; char backup_dest_str[OB_MAX_BACKUP_DEST_LENGTH] = ""; SMART_VAR(ObMySQLProxy::ReadResult, res) { @@ -4024,7 +4026,7 @@ int ObLogArchiveBackupInfoMgr::get_max_backup_piece_id_in_backup_dest( } bool ObLogArchiveBackupInfoMgr::CompareBackupPieceInfo::operator()( - const share::ObBackupPieceInfo& lhs, const share::ObBackupPieceInfo& rhs) + const share::ObBackupPieceInfo &lhs, const share::ObBackupPieceInfo &rhs) { bool b_ret = false; result_ = OB_SUCCESS; @@ -4053,13 +4055,9 @@ bool ObLogArchiveBackupInfoMgr::CompareBackupPieceInfo::operator()( return b_ret; } -int ObLogArchiveBackupInfoMgr::get_tenant_backup_piece_infos_with_file_status( - common::ObISQLClient &sql_client, - const int64_t incarnation, - const uint64_t tenant_id, - const ObBackupFileStatus::STATUS &file_status, - const bool is_backup_backup, - common::ObIArray &piece_infos) +int ObLogArchiveBackupInfoMgr::get_tenant_backup_piece_infos_with_file_status(common::ObISQLClient &sql_client, + const int64_t incarnation, const uint64_t tenant_id, const ObBackupFileStatus::STATUS &file_status, + const bool is_backup_backup, common::ObIArray &piece_infos) { int ret = OB_SUCCESS; ObSqlString sql; @@ -4068,9 +4066,12 @@ int ObLogArchiveBackupInfoMgr::get_tenant_backup_piece_infos_with_file_status( if (OB_INVALID_ID == tenant_id || incarnation <= 0 || !ObBackupFileStatus::is_valid(file_status)) { ret = OB_INVALID_ARGUMENT; LOG_WARN("invalid args", KR(ret), K(tenant_id), K(incarnation), K(file_status)); - } else if (OB_FAIL(sql.assign_fmt( - "SELECT * FROM %s WHERE incarnation = %ld AND tenant_id = %lu AND file_status = '%s'", - OB_ALL_BACKUP_PIECE_FILES_TNAME, incarnation, tenant_id, ObBackupFileStatus::get_str(file_status)))) { + } else if (OB_FAIL( + sql.assign_fmt("SELECT * FROM %s WHERE incarnation = %ld AND tenant_id = %lu AND file_status = '%s'", + OB_ALL_BACKUP_PIECE_FILES_TNAME, + incarnation, + tenant_id, + ObBackupFileStatus::get_str(file_status)))) { LOG_WARN("failed to assign sql", KR(ret), K(incarnation), K(tenant_id)); } else if (is_backup_backup) { if (OB_FAIL(sql.append_fmt(" AND copy_id > 0"))) { diff --git a/src/storage/backup/ob_partition_base_data_physical_restore_v2.cpp b/src/storage/backup/ob_partition_base_data_physical_restore_v2.cpp index 3691f8861..7b66f64b0 100644 --- a/src/storage/backup/ob_partition_base_data_physical_restore_v2.cpp +++ b/src/storage/backup/ob_partition_base_data_physical_restore_v2.cpp @@ -53,9 +53,9 @@ void ObPartitionBaseDataMetaRestoreReaderV2::reset() schema_version_ = OB_INVALID_VERSION; } -int ObPartitionBaseDataMetaRestoreReaderV2::init(const common::ObPartitionKey& pkey, - const ObPhysicalRestoreArg& restore_info, const ObPhyRestoreMacroIndexStoreV2& macro_indexs, - const ObBackupPartitionStoreMetaInfo& partition_store_meta_info, const int64_t schema_version) +int ObPartitionBaseDataMetaRestoreReaderV2::init(const common::ObPartitionKey &pkey, + const ObPhysicalRestoreArg &restore_info, const ObPhyRestoreMacroIndexStoreV2 ¯o_indexs, + const ObBackupPartitionStoreMetaInfo &partition_store_meta_info, const int64_t schema_version) { int ret = OB_SUCCESS; ObPartitionKey src_pkey; @@ -84,12 +84,12 @@ int ObPartitionBaseDataMetaRestoreReaderV2::init(const common::ObPartitionKey& p return ret; } -int ObPartitionBaseDataMetaRestoreReaderV2::fetch_partition_meta(ObPGPartitionStoreMeta& partition_store_meta) +int ObPartitionBaseDataMetaRestoreReaderV2::fetch_partition_meta(ObPGPartitionStoreMeta &partition_store_meta) { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; uint64_t backup_table_id = 0; - const ObPGPartitionStoreMeta* backup_partition_store_meta = NULL; + const ObPGPartitionStoreMeta *backup_partition_store_meta = NULL; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; STORAGE_LOG(WARN, "not inited", K(ret)); @@ -123,7 +123,7 @@ int ObPartitionBaseDataMetaRestoreReaderV2::fetch_partition_meta(ObPGPartitionSt } int ObPartitionBaseDataMetaRestoreReaderV2::trans_table_key( - const ObITable::TableKey& table_key, ObITable::TableKey& backup_table_key) + const ObITable::TableKey &table_key, ObITable::TableKey &backup_table_key) { int ret = OB_SUCCESS; uint64_t backup_index_id = 0; @@ -146,7 +146,7 @@ int ObPartitionBaseDataMetaRestoreReaderV2::trans_table_key( } int ObPartitionBaseDataMetaRestoreReaderV2::get_backup_sstable_meta_info( - const ObITable::TableKey& backup_table_key, const ObBackupSSTableMetaInfo*& backup_sstable_meta_info) + const ObITable::TableKey &backup_table_key, const ObBackupSSTableMetaInfo *&backup_sstable_meta_info) { int ret = OB_SUCCESS; backup_sstable_meta_info = NULL; @@ -157,7 +157,7 @@ int ObPartitionBaseDataMetaRestoreReaderV2::get_backup_sstable_meta_info( STORAGE_LOG(WARN, "not inited", K(ret)); } else { for (int64_t i = 0; i < partition_store_meta_info_->sstable_meta_info_array_.count() && !found; ++i) { - const ObBackupSSTableMetaInfo& tmp_sstable_meta_info = partition_store_meta_info_->sstable_meta_info_array_.at(i); + const ObBackupSSTableMetaInfo &tmp_sstable_meta_info = partition_store_meta_info_->sstable_meta_info_array_.at(i); if (backup_table_key == tmp_sstable_meta_info.table_key_) { backup_sstable_meta_info = &(partition_store_meta_info_->sstable_meta_info_array_.at(i)); found = true; @@ -175,7 +175,7 @@ int ObPartitionBaseDataMetaRestoreReaderV2::get_backup_sstable_meta_info( } int ObPartitionBaseDataMetaRestoreReaderV2::get_backup_table_keys( - const uint64_t backup_index_id, ObIArray& table_keys) + const uint64_t backup_index_id, ObIArray &table_keys) { int ret = OB_SUCCESS; if (OB_UNLIKELY(!is_inited_)) { @@ -183,7 +183,7 @@ int ObPartitionBaseDataMetaRestoreReaderV2::get_backup_table_keys( STORAGE_LOG(WARN, "not inited", K(ret)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < partition_store_meta_info_->sstable_meta_info_array_.count(); ++i) { - const ObITable::TableKey& table_key = partition_store_meta_info_->sstable_meta_info_array_.at(i).table_key_; + const ObITable::TableKey &table_key = partition_store_meta_info_->sstable_meta_info_array_.at(i).table_key_; if (table_key.table_id_ == backup_index_id) { if (table_key.is_complement_minor_sstable() && !table_key.log_ts_range_.is_empty()) { // do nothing @@ -197,12 +197,12 @@ int ObPartitionBaseDataMetaRestoreReaderV2::get_backup_table_keys( } int ObPartitionBaseDataMetaRestoreReaderV2::fetch_sstable_meta( - const ObITable::TableKey& table_key, blocksstable::ObSSTableBaseMeta& sstable_meta) + const ObITable::TableKey &table_key, blocksstable::ObSSTableBaseMeta &sstable_meta) { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; ObITable::TableKey backup_table_key; - const ObBackupSSTableMetaInfo* backup_sstable_meta_info = NULL; + const ObBackupSSTableMetaInfo *backup_sstable_meta_info = NULL; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; @@ -238,12 +238,12 @@ int ObPartitionBaseDataMetaRestoreReaderV2::fetch_sstable_meta( } int ObPartitionBaseDataMetaRestoreReaderV2::fetch_sstable_pair_list( - const ObITable::TableKey& table_key, common::ObIArray& pair_list) + const ObITable::TableKey &table_key, common::ObIArray &pair_list) { int ret = OB_SUCCESS; ObITable::TableKey backup_table_key; - const common::ObArray* index_list = NULL; - const ObBackupSSTableMetaInfo* backup_sstable_meta_info = NULL; + const common::ObArray *index_list = NULL; + const ObBackupSSTableMetaInfo *backup_sstable_meta_info = NULL; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; @@ -280,7 +280,7 @@ int ObPartitionBaseDataMetaRestoreReaderV2::fetch_sstable_pair_list( STORAGE_LOG(WARN, "index list should not be NULL", K(ret), K(table_key), K(backup_table_key), KP(index_list)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < index_list->count(); ++i) { - const ObBackupTableMacroIndex& backup_macro_index = index_list->at(i); + const ObBackupTableMacroIndex &backup_macro_index = index_list->at(i); if (!backup_macro_index.is_valid()) { ret = OB_INVALID_ARGUMENT; STORAGE_LOG( @@ -298,12 +298,12 @@ int ObPartitionBaseDataMetaRestoreReaderV2::fetch_sstable_pair_list( return ret; } -int ObPartitionBaseDataMetaRestoreReaderV2::prepare(const common::ObPartitionKey& pkey) +int ObPartitionBaseDataMetaRestoreReaderV2::prepare(const common::ObPartitionKey &pkey) { int ret = OB_SUCCESS; ObIPartitionGroupGuard guard; ObPGPartitionGuard pg_partition_guard; - ObPartitionStorage* partition_storage = NULL; + ObPartitionStorage *partition_storage = NULL; if (OB_FAIL(ObPartitionService::get_instance().get_partition(pkey, guard))) { STORAGE_LOG(WARN, "fail to get partition", K(ret), K(pkey)); @@ -315,7 +315,7 @@ int ObPartitionBaseDataMetaRestoreReaderV2::prepare(const common::ObPartitionKey } else if (OB_ISNULL(pg_partition_guard.get_pg_partition())) { ret = OB_ERR_UNEXPECTED; STORAGE_LOG(WARN, "pg_partition is null ", K(ret), K(pkey)); - } else if (OB_ISNULL(partition_storage = reinterpret_cast( + } else if (OB_ISNULL(partition_storage = reinterpret_cast( pg_partition_guard.get_pg_partition()->get_storage()))) { ret = OB_ERR_UNEXPECTED; STORAGE_LOG(WARN, "Unexpected error, the partition storage is NULL", K(ret), K(pkey)); @@ -326,7 +326,7 @@ int ObPartitionBaseDataMetaRestoreReaderV2::prepare(const common::ObPartitionKey return ret; } -int ObPartitionBaseDataMetaRestoreReaderV2::fetch_all_table_ids(common::ObIArray& table_id_array) +int ObPartitionBaseDataMetaRestoreReaderV2::fetch_all_table_ids(common::ObIArray &table_id_array) { int ret = OB_SUCCESS; uint64_t index_id = 0; @@ -339,7 +339,7 @@ int ObPartitionBaseDataMetaRestoreReaderV2::fetch_all_table_ids(common::ObIArray STORAGE_LOG(WARN, "failed to create backup table id set", K(ret), K(*partition_store_meta_info_)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < partition_store_meta_info_->sstable_meta_info_array_.count(); ++i) { - const ObITable::TableKey& backup_table_key = + const ObITable::TableKey &backup_table_key = partition_store_meta_info_->sstable_meta_info_array_.at(i).table_key_; if (OB_FAIL(backup_table_id_set.set_refactored(backup_table_key.table_id_))) { if (OB_HASH_EXIST == ret) { @@ -372,7 +372,7 @@ int ObPartitionBaseDataMetaRestoreReaderV2::fetch_all_table_ids(common::ObIArray } int ObPartitionBaseDataMetaRestoreReaderV2::fetch_table_keys( - const uint64_t index_id, obrpc::ObFetchTableInfoResult& table_res) + const uint64_t index_id, obrpc::ObFetchTableInfoResult &table_res) { int ret = OB_SUCCESS; int64_t min_multi_version_start = INT64_MAX; @@ -387,7 +387,7 @@ int ObPartitionBaseDataMetaRestoreReaderV2::fetch_table_keys( STORAGE_LOG(WARN, "failed to get backup table keys", K(ret), K(backup_index_id)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < table_res.table_keys_.count(); ++i) { - ObITable::TableKey& table_key = table_res.table_keys_.at(i); + ObITable::TableKey &table_key = table_res.table_keys_.at(i); table_key.pkey_ = pkey_; table_key.table_id_ = index_id; if (table_key.is_minor_sstable()) { @@ -412,11 +412,11 @@ int ObPartitionBaseDataMetaRestoreReaderV2::fetch_table_keys( return ret; } -int ObPartitionBaseDataMetaRestoreReaderV2::do_filter_tables(ObIArray& table_ids) +int ObPartitionBaseDataMetaRestoreReaderV2::do_filter_tables(ObIArray &table_ids) { int ret = OB_SUCCESS; ObSchemaGetterGuard schema_guard; - ObMultiVersionSchemaService& schema_service = ObMultiVersionSchemaService::get_instance(); + ObMultiVersionSchemaService &schema_service = ObMultiVersionSchemaService::get_instance(); ObArray restore_tables; bool filtered = false; const int64_t tenant_id = pkey_.get_tenant_id(); @@ -432,7 +432,7 @@ int ObPartitionBaseDataMetaRestoreReaderV2::do_filter_tables(ObIArray& for (int i = 0; OB_SUCC(ret) && i < table_ids.count(); ++i) { uint64_t table_id = table_ids.at(i); is_exist = false; - const ObTableSchema* table_schema = NULL; + const ObTableSchema *table_schema = NULL; bool need_skip = false; if (is_trans_table_id(table_id)) { is_exist = true; @@ -482,9 +482,9 @@ ObPhysicalBaseMetaRestoreReaderV2::ObPhysicalBaseMetaRestoreReaderV2() table_key_() {} -int ObPhysicalBaseMetaRestoreReaderV2::init(common::ObInOutBandwidthThrottle& bandwidth_throttle, - const ObPhysicalRestoreArg& restore_info, const ObITable::TableKey& table_key, - ObIPartitionGroupMetaRestoreReader& reader) +int ObPhysicalBaseMetaRestoreReaderV2::init(common::ObInOutBandwidthThrottle &bandwidth_throttle, + const ObPhysicalRestoreArg &restore_info, const ObITable::TableKey &table_key, + ObIPartitionGroupMetaRestoreReader &reader) { int ret = OB_SUCCESS; @@ -504,7 +504,7 @@ int ObPhysicalBaseMetaRestoreReaderV2::init(common::ObInOutBandwidthThrottle& ba return ret; } -int ObPhysicalBaseMetaRestoreReaderV2::fetch_sstable_meta(ObSSTableBaseMeta& sstable_meta) +int ObPhysicalBaseMetaRestoreReaderV2::fetch_sstable_meta(ObSSTableBaseMeta &sstable_meta) { int ret = OB_SUCCESS; @@ -520,7 +520,7 @@ int ObPhysicalBaseMetaRestoreReaderV2::fetch_sstable_meta(ObSSTableBaseMeta& sst return ret; } -int ObPhysicalBaseMetaRestoreReaderV2::fetch_macro_block_list(ObIArray& macro_block_list) +int ObPhysicalBaseMetaRestoreReaderV2::fetch_macro_block_list(ObIArray ¯o_block_list) { int ret = OB_SUCCESS; @@ -546,15 +546,16 @@ ObPartitionMacroBlockRestoreReaderV2::ObPartitionMacroBlockRestoreReaderV2() bandwidth_throttle_(nullptr), backup_pgkey_(), backup_table_key_(), - allocator_() + allocator_(), + restore_info_(nullptr) {} ObPartitionMacroBlockRestoreReaderV2::~ObPartitionMacroBlockRestoreReaderV2() {} -int ObPartitionMacroBlockRestoreReaderV2::init(common::ObInOutBandwidthThrottle& bandwidth_throttle, - common::ObIArray& list, const ObPhysicalRestoreArg& restore_info, - const ObPhyRestoreMacroIndexStoreV2& macro_indexs, const ObITable::TableKey& table_key) +int ObPartitionMacroBlockRestoreReaderV2::init(common::ObInOutBandwidthThrottle &bandwidth_throttle, + common::ObIArray &list, const ObPhysicalRestoreArg &restore_info, + const ObPhyRestoreMacroIndexStoreV2 ¯o_indexs, const ObITable::TableKey &table_key) { int ret = OB_SUCCESS; uint64_t backup_table_id = 0; @@ -604,6 +605,7 @@ int ObPartitionMacroBlockRestoreReaderV2::init(common::ObInOutBandwidthThrottle& bandwidth_throttle_ = &bandwidth_throttle; backup_table_key_ = table_key; backup_table_key_.table_id_ = backup_index_id; + restore_info_ = &restore_info; if (OB_FAIL(backup_table_key_.pkey_.init(backup_table_id, table_key.pkey_.get_partition_id(), 0))) { STORAGE_LOG(WARN, "failed to init backup partition key", K(ret), K(table_key)); @@ -614,14 +616,14 @@ int ObPartitionMacroBlockRestoreReaderV2::init(common::ObInOutBandwidthThrottle& return ret; } -int ObPartitionMacroBlockRestoreReaderV2::get_next_macro_block(blocksstable::ObFullMacroBlockMeta& meta, - blocksstable::ObBufferReader& data, blocksstable::MacroBlockId& src_macro_id) +int ObPartitionMacroBlockRestoreReaderV2::get_next_macro_block(blocksstable::ObFullMacroBlockMeta &meta, + blocksstable::ObBufferReader &data, blocksstable::MacroBlockId &src_macro_id) { int ret = OB_SUCCESS; ObBackupPath path; ObBackupTableMacroIndex macro_index; - ObMacroBlockSchemaInfo* new_schema = nullptr; - ObMacroBlockMetaV2* new_meta = nullptr; + ObMacroBlockSchemaInfo *new_schema = nullptr; + ObMacroBlockMetaV2 *new_meta = nullptr; allocator_.reuse(); src_macro_id.reset(); // src_macro_id only used for fast migrator on ofs @@ -657,7 +659,7 @@ int ObPartitionMacroBlockRestoreReaderV2::get_next_macro_block(blocksstable::ObF } int ObPartitionMacroBlockRestoreReaderV2::trans_macro_block( - const uint64_t table_id, blocksstable::ObMacroBlockMetaV2& meta, blocksstable::ObBufferReader& data) + const uint64_t table_id, blocksstable::ObMacroBlockMetaV2 &meta, blocksstable::ObBufferReader &data) { int ret = OB_SUCCESS; ObMacroBlockCommonHeader common_header; @@ -690,8 +692,8 @@ int ObPartitionMacroBlockRestoreReaderV2::trans_macro_block( "need_size", sizeof(ObSSTableMacroBlockHeader)); } else { - ObSSTableMacroBlockHeader* sstable_macro_block_header = - reinterpret_cast(data.data() + pos); + ObSSTableMacroBlockHeader *sstable_macro_block_header = + reinterpret_cast(data.data() + pos); meta.table_id_ = table_id; sstable_macro_block_header->table_id_ = meta.table_id_; sstable_macro_block_header->data_version_ = meta.data_version_; @@ -702,7 +704,7 @@ int ObPartitionMacroBlockRestoreReaderV2::trans_macro_block( } int ObPartitionMacroBlockRestoreReaderV2::get_macro_block_path( - const ObBackupTableMacroIndex& macro_index, ObBackupPath& path) + const ObBackupTableMacroIndex ¯o_index, ObBackupPath &path) { int ret = OB_SUCCESS; path.reset(); @@ -713,13 +715,35 @@ int ObPartitionMacroBlockRestoreReaderV2::get_macro_block_path( ret = OB_INVALID_ARGUMENT; STORAGE_LOG(WARN, "get macro block path get invalid argument", K(ret), K(macro_index)); } else if (backup_table_key_.is_major_sstable()) { - if (OB_FAIL(ObBackupPathUtil::get_major_macro_block_file_path(simple_path_, - backup_pgkey_.get_table_id(), - backup_pgkey_.get_partition_id(), - macro_index.backup_set_id_, - macro_index.sub_task_id_, - path))) { - STORAGE_LOG(WARN, "fail to get meta file path", K(ret)); + ObSimpleBackupSetPath simple_backup_set_path; + ObArray path_list; + const int64_t backup_set_id = macro_index.backup_set_id_; + bool found = false; + + if (OB_FAIL(restore_info_->get_restore_set_list(path_list))) { + STORAGE_LOG(WARN, "failed to get restore set list", K(ret)); + } else { + for (int64_t i = 0; i < path_list.count() && !found; ++i) { + const ObSimpleBackupSetPath &path = path_list.at(i); + if (backup_set_id == path.backup_set_id_) { + simple_backup_set_path = path; + found = true; + } + } + if (!found) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("failed to find backup path", K(ret), K(path_list), K(macro_index)); + } + } + + if (OB_FAIL(ret)) { + } else if (OB_FAIL(ObBackupPathUtil::get_major_macro_block_file_path(simple_backup_set_path, + backup_pgkey_.get_table_id(), + backup_pgkey_.get_partition_id(), + backup_set_id, + macro_index.sub_task_id_, + path))) { + LOG_WARN("fail to get major macro block file path", K(ret), K(simple_backup_set_path), K(macro_index)); } } else if (backup_table_key_.is_minor_sstable()) { if (OB_FAIL(ObBackupPathUtil::get_minor_macro_block_file_path(simple_path_, @@ -764,7 +788,7 @@ void ObPartitionGroupMetaRestoreReaderV2::reset() bandwidth_throttle_ = NULL; last_read_size_ = 0; for (MetaReaderMap::iterator iter = partition_reader_map_.begin(); iter != partition_reader_map_.end(); ++iter) { - ObPartitionBaseDataMetaRestoreReaderV2* meta_reader = iter->second; + ObPartitionBaseDataMetaRestoreReaderV2 *meta_reader = iter->second; if (NULL != meta_reader) { meta_reader->~ObPartitionBaseDataMetaRestoreReaderV2(); } @@ -775,18 +799,18 @@ void ObPartitionGroupMetaRestoreReaderV2::reset() schema_version_ = 0; } -int ObPartitionGroupMetaRestoreReaderV2::init(common::ObInOutBandwidthThrottle& bandwidth_throttle, - const ObPhysicalRestoreArg& restore_info, const ObPhyRestoreMetaIndexStore& meta_indexs, - const ObPhyRestoreMacroIndexStoreV2& macro_indexs) +int ObPartitionGroupMetaRestoreReaderV2::init(common::ObInOutBandwidthThrottle &bandwidth_throttle, + const ObPhysicalRestoreArg &restore_info, const ObPhyRestoreMetaIndexStore &meta_indexs, + const ObPhyRestoreMacroIndexStoreV2 ¯o_indexs) { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; const uint64_t tenant_id = restore_info.pg_key_.get_tenant_id(); - ObIPartitionGroup* partition_group = NULL; + ObIPartitionGroup *partition_group = NULL; ObIPartitionGroupGuard pg_guard; int64_t restore_schema_version = OB_INVALID_VERSION; int64_t current_schema_version = OB_INVALID_VERSION; - const ObPartitionKey& pg_key = restore_info.pg_key_; + const ObPartitionKey &pg_key = restore_info.pg_key_; if (OB_UNLIKELY(is_inited_)) { ret = OB_INIT_TWICE; @@ -846,7 +870,7 @@ int ObPartitionGroupMetaRestoreReaderV2::init(common::ObInOutBandwidthThrottle& return ret; } -int ObPartitionGroupMetaRestoreReaderV2::fetch_partition_group_meta(ObPartitionGroupMeta& pg_meta) +int ObPartitionGroupMetaRestoreReaderV2::fetch_partition_group_meta(ObPartitionGroupMeta &pg_meta) { int ret = OB_SUCCESS; @@ -864,7 +888,7 @@ int ObPartitionGroupMetaRestoreReaderV2::fetch_partition_group_meta(ObPartitionG } int ObPartitionGroupMetaRestoreReaderV2::trans_backup_pgmeta( - const ObPhysicalRestoreArg& restore_info, ObPartitionGroupMeta& backup_pg_meta) + const ObPhysicalRestoreArg &restore_info, ObPartitionGroupMeta &backup_pg_meta) { int ret = OB_SUCCESS; ObPartitionArray current_partitions; @@ -879,9 +903,9 @@ int ObPartitionGroupMetaRestoreReaderV2::trans_backup_pgmeta( } else if (OB_FAIL(trans_to_backup_partitions(restore_info, current_partitions, backup_pg_meta.partitions_))) { STORAGE_LOG(WARN, "failed to trans from backup partitions", K(ret), K(backup_pg_meta)); } else { - const ObSavedStorageInfoV2& cur_info = pg_meta_.storage_info_; + const ObSavedStorageInfoV2 &cur_info = pg_meta_.storage_info_; const int64_t cur_schema_version = cur_info.get_data_info().get_schema_version(); - ObSavedStorageInfoV2& backup_info = backup_pg_meta.storage_info_; + ObSavedStorageInfoV2 &backup_info = backup_pg_meta.storage_info_; backup_info.get_data_info().set_schema_version(cur_schema_version); STORAGE_LOG(INFO, "succeed trans backup pg meta", K(backup_pg_meta)); } @@ -889,7 +913,7 @@ int ObPartitionGroupMetaRestoreReaderV2::trans_backup_pgmeta( } int ObPartitionGroupMetaRestoreReaderV2::read_partition_meta( - const ObPartitionKey& pkey, const ObPhysicalRestoreArg& restore_info, ObPGPartitionStoreMeta& partition_store_meta) + const ObPartitionKey &pkey, const ObPhysicalRestoreArg &restore_info, ObPGPartitionStoreMeta &partition_store_meta) { int ret = OB_SUCCESS; bool found = false; @@ -904,7 +928,7 @@ int ObPartitionGroupMetaRestoreReaderV2::read_partition_meta( } else { for (int64_t i = 0; OB_SUCC(ret) && i < backup_pg_meta_info_.partition_store_meta_info_array_.count() && !found; ++i) { - const ObPGPartitionStoreMeta& tmp_partition_store_meta = + const ObPGPartitionStoreMeta &tmp_partition_store_meta = backup_pg_meta_info_.partition_store_meta_info_array_.at(i).partition_store_meta_; if (tmp_partition_store_meta.pkey_ == pkey) { if (OB_FAIL(partition_store_meta.assign(tmp_partition_store_meta))) { @@ -923,12 +947,12 @@ int ObPartitionGroupMetaRestoreReaderV2::read_partition_meta( } int ObPartitionGroupMetaRestoreReaderV2::create_pg_partition_if_need( - const ObPhysicalRestoreArg& restore_info, const ObPartitionGroupMeta& backup_pg_meta) + const ObPhysicalRestoreArg &restore_info, const ObPartitionGroupMeta &backup_pg_meta) { int ret = OB_SUCCESS; ObIPartitionGroupGuard pg_guard; - ObIPartitionGroup* pg = NULL; - const ObPartitionKey& pg_key = restore_info.pg_key_; + ObIPartitionGroup *pg = NULL; + const ObPartitionKey &pg_key = restore_info.pg_key_; if (OB_UNLIKELY(!restore_info.is_valid() || !backup_pg_meta.is_valid())) { ret = OB_INVALID_ARGUMENT; @@ -939,11 +963,11 @@ int ObPartitionGroupMetaRestoreReaderV2::create_pg_partition_if_need( ret = OB_ERR_UNEXPECTED; STORAGE_LOG(WARN, "partition group should not be null", K(ret), K(pg_key)); } else { - const ObSavedStorageInfoV2& storage_info = backup_pg_meta.storage_info_; + const ObSavedStorageInfoV2 &storage_info = backup_pg_meta.storage_info_; ObPGPartitionStoreMeta partition_meta; bool succ_create_partition = false; for (int64_t i = 0; OB_SUCC(ret) && i < backup_pg_meta.partitions_.count(); ++i) { - const ObPartitionKey& src_pkey = backup_pg_meta.partitions_.at(i); + const ObPartitionKey &src_pkey = backup_pg_meta.partitions_.at(i); ObPartitionKey dst_pkey; ObIPartitionGroupGuard guard; int tmp_ret = OB_SUCCESS; @@ -997,7 +1021,7 @@ int ObPartitionGroupMetaRestoreReaderV2::create_pg_partition_if_need( return ret; } -int ObPartitionGroupMetaRestoreReaderV2::prepare_pg_meta(const ObPhysicalRestoreArg& restore_info) +int ObPartitionGroupMetaRestoreReaderV2::prepare_pg_meta(const ObPhysicalRestoreArg &restore_info) { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; @@ -1028,7 +1052,7 @@ int ObPartitionGroupMetaRestoreReaderV2::prepare_pg_meta(const ObPhysicalRestore } int ObPartitionGroupMetaRestoreReaderV2::prepare( - const ObPhysicalRestoreArg& restore_info, const ObPhyRestoreMacroIndexStoreV2& macro_indexs) + const ObPhysicalRestoreArg &restore_info, const ObPhyRestoreMacroIndexStoreV2 ¯o_indexs) { int ret = OB_SUCCESS; @@ -1038,17 +1062,17 @@ int ObPartitionGroupMetaRestoreReaderV2::prepare( } else if (OB_FAIL(prepare_pg_meta(restore_info))) { STORAGE_LOG(WARN, "prepare pg meta fail", K(ret)); } else { - const ObPartitionArray& partitions = pg_meta_.partitions_; + const ObPartitionArray &partitions = pg_meta_.partitions_; if (0 == partitions.count()) { STORAGE_LOG(INFO, "empty pg, no partitions"); } else if (OB_FAIL(partition_reader_map_.create(partitions.count(), ObModIds::RESTORE))) { STORAGE_LOG(WARN, "failed to create partition reader map", K(ret)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < partitions.count(); ++i) { - const ObPartitionKey& pkey = partitions.at(i); - ObPartitionBaseDataMetaRestoreReaderV2* reader = NULL; - void* buf = NULL; - const ObBackupPartitionStoreMetaInfo* backup_partition_meta_info = NULL; + const ObPartitionKey &pkey = partitions.at(i); + ObPartitionBaseDataMetaRestoreReaderV2 *reader = NULL; + void *buf = NULL; + const ObBackupPartitionStoreMetaInfo *backup_partition_meta_info = NULL; if (OB_FAIL(get_backup_partition_meta_info(pkey, restore_info, backup_partition_meta_info))) { STORAGE_LOG(WARN, "failed to get backup partition meta info", K(ret), K(pkey)); } else if (OB_ISNULL(buf = allocator_.alloc(sizeof(ObPartitionBaseDataMetaRestoreReaderV2)))) { @@ -1076,7 +1100,7 @@ int ObPartitionGroupMetaRestoreReaderV2::prepare( } int ObPartitionGroupMetaRestoreReaderV2::get_partition_readers( - const ObPartitionArray& partitions, ObIArray& partition_reader_array) + const ObPartitionArray &partitions, ObIArray &partition_reader_array) { int ret = OB_SUCCESS; if (OB_UNLIKELY(!is_inited_)) { @@ -1084,8 +1108,8 @@ int ObPartitionGroupMetaRestoreReaderV2::get_partition_readers( STORAGE_LOG(WARN, "partition group meta restore reader do not init", K(ret)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < partitions.count(); ++i) { - const ObPartitionKey& pkey = partitions.at(i); - ObPartitionBaseDataMetaRestoreReaderV2* reader = NULL; + const ObPartitionKey &pkey = partitions.at(i); + ObPartitionBaseDataMetaRestoreReaderV2 *reader = NULL; if (OB_FAIL(partition_reader_map_.get_refactored(pkey, reader))) { STORAGE_LOG(WARN, "failed to get partition base data meta restore reader", K(ret), K(pkey)); } else if (OB_ISNULL(reader)) { @@ -1100,10 +1124,10 @@ int ObPartitionGroupMetaRestoreReaderV2::get_partition_readers( } int ObPartitionGroupMetaRestoreReaderV2::fetch_sstable_meta( - const ObITable::TableKey& table_key, blocksstable::ObSSTableBaseMeta& sstable_meta) + const ObITable::TableKey &table_key, blocksstable::ObSSTableBaseMeta &sstable_meta) { int ret = OB_SUCCESS; - ObPartitionBaseDataMetaRestoreReaderV2* reader = NULL; + ObPartitionBaseDataMetaRestoreReaderV2 *reader = NULL; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; @@ -1123,11 +1147,11 @@ int ObPartitionGroupMetaRestoreReaderV2::fetch_sstable_meta( } int ObPartitionGroupMetaRestoreReaderV2::fetch_sstable_pair_list( - const ObITable::TableKey& table_key, common::ObIArray& pair_list) + const ObITable::TableKey &table_key, common::ObIArray &pair_list) { int ret = OB_SUCCESS; ObArray backup_pair_list; - ObPartitionBaseDataMetaRestoreReaderV2* reader = NULL; + ObPartitionBaseDataMetaRestoreReaderV2 *reader = NULL; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; @@ -1147,12 +1171,12 @@ int ObPartitionGroupMetaRestoreReaderV2::fetch_sstable_pair_list( } int ObPartitionGroupMetaRestoreReaderV2::check_backup_partitions_in_pg( - const ObPhysicalRestoreArg& restore_info, ObPartitionGroupMeta& backup_pg_meta) + const ObPhysicalRestoreArg &restore_info, ObPartitionGroupMeta &backup_pg_meta) { int ret = OB_SUCCESS; ObHashSet restore_table_ids_set; ObSchemaGetterGuard schema_guard; - ObMultiVersionSchemaService& schema_service = ObMultiVersionSchemaService::get_instance(); + ObMultiVersionSchemaService &schema_service = ObMultiVersionSchemaService::get_instance(); const uint64_t tenant_id = restore_info.pg_key_.get_tenant_id(); const uint64_t tablegroup_id = restore_info.pg_key_.get_tablegroup_id(); ObArray table_ids; @@ -1194,7 +1218,7 @@ int ObPartitionGroupMetaRestoreReaderV2::check_backup_partitions_in_pg( if (OB_SUCC(ret)) { for (int64_t i = 0; OB_SUCC(ret) && i < table_ids.count(); ++i) { const uint64_t table_id = table_ids.at(i); - const ObTableSchema* table_schema = NULL; + const ObTableSchema *table_schema = NULL; int hash_ret = OB_SUCCESS; if (OB_FAIL(schema_guard.get_table_schema(table_id, table_schema))) { STORAGE_LOG(WARN, "failed to get table schema", K(ret), K(table_id)); @@ -1230,7 +1254,7 @@ int ObPartitionGroupMetaRestoreReaderV2::check_backup_partitions_in_pg( return ret; } -int ObPartitionGroupMetaRestoreReaderV2::get_restore_tenant_id(uint64_t& tenant_id) +int ObPartitionGroupMetaRestoreReaderV2::get_restore_tenant_id(uint64_t &tenant_id) { int ret = OB_SUCCESS; tenant_id = OB_INVALID_ID; @@ -1243,8 +1267,8 @@ int ObPartitionGroupMetaRestoreReaderV2::get_restore_tenant_id(uint64_t& tenant_ return ret; } -int ObPartitionGroupMetaRestoreReaderV2::get_backup_partition_meta_info(const ObPartitionKey& pkey, - const ObPhysicalRestoreArg& restore_info, const ObBackupPartitionStoreMetaInfo*& backup_partition_meta_info) +int ObPartitionGroupMetaRestoreReaderV2::get_backup_partition_meta_info(const ObPartitionKey &pkey, + const ObPhysicalRestoreArg &restore_info, const ObBackupPartitionStoreMetaInfo *&backup_partition_meta_info) { int ret = OB_SUCCESS; backup_partition_meta_info = NULL; @@ -1265,7 +1289,7 @@ int ObPartitionGroupMetaRestoreReaderV2::get_backup_partition_meta_info(const Ob backup_pkey.table_id_ = backup_table_id; for (int64_t i = 0; OB_SUCC(ret) && i < backup_pg_meta_info_.partition_store_meta_info_array_.count() && !found; ++i) { - const ObPartitionKey& tmp_key = + const ObPartitionKey &tmp_key = backup_pg_meta_info_.partition_store_meta_info_array_.at(i).partition_store_meta_.pkey_; if (backup_pkey == tmp_key) { backup_partition_meta_info = &(backup_pg_meta_info_.partition_store_meta_info_array_.at(i)); @@ -1281,7 +1305,7 @@ int ObPartitionGroupMetaRestoreReaderV2::get_backup_partition_meta_info(const Ob return ret; } -int ObPartitionGroupMetaRestoreReaderV2::get_restore_schema_version(int64_t& schema_version) +int ObPartitionGroupMetaRestoreReaderV2::get_restore_schema_version(int64_t &schema_version) { int ret = OB_SUCCESS; schema_version = OB_INVALID_VERSION; @@ -1295,13 +1319,13 @@ int ObPartitionGroupMetaRestoreReaderV2::get_restore_schema_version(int64_t& sch return ret; } -int ObPartitionGroupMetaRestoreReaderV2::trans_from_backup_partitions(const ObPhysicalRestoreArg& restore_info, - const common::ObPartitionArray& backup_partitions, common::ObPartitionArray& current_partitions) +int ObPartitionGroupMetaRestoreReaderV2::trans_from_backup_partitions(const ObPhysicalRestoreArg &restore_info, + const common::ObPartitionArray &backup_partitions, common::ObPartitionArray ¤t_partitions) { int ret = OB_SUCCESS; current_partitions.reset(); for (int64_t i = 0; OB_SUCC(ret) && i < backup_partitions.count(); ++i) { - const ObPartitionKey& backup_pkey = backup_partitions.at(i); + const ObPartitionKey &backup_pkey = backup_partitions.at(i); ObPartitionKey current_pkey = backup_pkey; if (OB_FAIL(restore_info.trans_from_backup_schema_id(backup_pkey.table_id_, current_pkey.table_id_))) { STORAGE_LOG(WARN, "failed to trans from backup schema id", K(ret), K(backup_pkey)); @@ -1312,13 +1336,13 @@ int ObPartitionGroupMetaRestoreReaderV2::trans_from_backup_partitions(const ObPh return ret; } -int ObPartitionGroupMetaRestoreReaderV2::trans_to_backup_partitions(const ObPhysicalRestoreArg& restore_info, - const common::ObPartitionArray& current_partitions, common::ObPartitionArray& backup_partitions) +int ObPartitionGroupMetaRestoreReaderV2::trans_to_backup_partitions(const ObPhysicalRestoreArg &restore_info, + const common::ObPartitionArray ¤t_partitions, common::ObPartitionArray &backup_partitions) { int ret = OB_SUCCESS; backup_partitions.reset(); for (int64_t i = 0; OB_SUCC(ret) && i < current_partitions.count(); ++i) { - const ObPartitionKey& current_pkey = current_partitions.at(i); + const ObPartitionKey ¤t_pkey = current_partitions.at(i); ObPartitionKey backup_pkey = current_pkey; if (OB_FAIL(restore_info.trans_to_backup_schema_id(current_pkey.table_id_, backup_pkey.table_id_))) { STORAGE_LOG(WARN, "failed to trans to backup schema id", K(ret), K(current_pkey)); @@ -1329,11 +1353,11 @@ int ObPartitionGroupMetaRestoreReaderV2::trans_to_backup_partitions(const ObPhys return ret; } -int ObPartitionGroupMetaRestoreReaderV2::do_filter_pg_partitions(const ObPGKey& pg_key, ObPartitionArray& partitions) +int ObPartitionGroupMetaRestoreReaderV2::do_filter_pg_partitions(const ObPGKey &pg_key, ObPartitionArray &partitions) { int ret = OB_SUCCESS; ObSchemaGetterGuard schema_guard; - ObMultiVersionSchemaService& schema_service = ObMultiVersionSchemaService::get_instance(); + ObMultiVersionSchemaService &schema_service = ObMultiVersionSchemaService::get_instance(); const bool check_dropped_partition = false; if (!pg_key.is_valid()) { @@ -1347,7 +1371,7 @@ int ObPartitionGroupMetaRestoreReaderV2::do_filter_pg_partitions(const ObPGKey& bool filtered = false; ObPartitionArray exist_partitions; for (int i = 0; OB_SUCC(ret) && i < partitions.count(); ++i) { - const ObPartitionKey& pkey = partitions.at(i); + const ObPartitionKey &pkey = partitions.at(i); if (pkey.is_trans_table()) { is_exist = true; } else if (OB_FAIL(schema_guard.check_partition_exist( @@ -1395,7 +1419,7 @@ void ObPGPartitionBaseDataMetaRestoreReaderV2::reset() } int ObPGPartitionBaseDataMetaRestoreReaderV2::init( - const ObPartitionArray& partitions, ObPartitionGroupMetaRestoreReaderV2* reader) + const ObPartitionArray &partitions, ObPartitionGroupMetaRestoreReaderV2 *reader) { int ret = OB_SUCCESS; uint64_t tenant_id = 0; @@ -1422,7 +1446,7 @@ int ObPGPartitionBaseDataMetaRestoreReaderV2::init( } int ObPGPartitionBaseDataMetaRestoreReaderV2::fetch_pg_partition_meta_info( - obrpc::ObPGPartitionMetaInfo& partition_meta_info) + obrpc::ObPGPartitionMetaInfo &partition_meta_info) { int ret = OB_SUCCESS; partition_meta_info.reset(); @@ -1433,7 +1457,7 @@ int ObPGPartitionBaseDataMetaRestoreReaderV2::fetch_pg_partition_meta_info( } else if (reader_index_ == partition_reader_array_.count()) { ret = OB_ITER_END; } else { - ObPartitionBaseDataMetaRestoreReaderV2* reader = partition_reader_array_.at(reader_index_); + ObPartitionBaseDataMetaRestoreReaderV2 *reader = partition_reader_array_.at(reader_index_); if (OB_ISNULL(reader)) { ret = OB_ERR_UNEXPECTED; STORAGE_LOG(WARN, "partition base data meta restore reader is NULL", K(ret), KP(reader), K(reader_index_)); @@ -1464,7 +1488,7 @@ int ObPGPartitionBaseDataMetaRestoreReaderV2::fetch_pg_partition_meta_info( } int ObPGPartitionBaseDataMetaRestoreReaderV2::check_sstable_table_ids_in_table( - const ObPartitionKey& pkey, const common::ObIArray& table_ids) + const ObPartitionKey &pkey, const common::ObIArray &table_ids) { int ret = OB_SUCCESS; ObHashSet table_ids_set; @@ -1472,7 +1496,7 @@ int ObPGPartitionBaseDataMetaRestoreReaderV2::check_sstable_table_ids_in_table( const uint64_t tenant_id = pkey.get_tenant_id(); ObArray index_stats; ObSchemaGetterGuard schema_guard; - ObMultiVersionSchemaService& schema_service = ObMultiVersionSchemaService::get_instance(); + ObMultiVersionSchemaService &schema_service = ObMultiVersionSchemaService::get_instance(); const int64_t MAX_BUCKET_SIZE = 1024; if (OB_UNLIKELY(!is_inited_)) { @@ -1508,7 +1532,7 @@ int ObPGPartitionBaseDataMetaRestoreReaderV2::check_sstable_table_ids_in_table( // local index table if (OB_SUCC(ret)) { for (int64_t i = 0; OB_SUCC(ret) && i < index_stats.count(); ++i) { - const ObIndexTableStat& index_stat = index_stats.at(i); + const ObIndexTableStat &index_stat = index_stats.at(i); const uint64_t index_table_id = index_stat.index_id_; if (OB_FAIL(check_sstable_ids_contain_schema_table_id(table_ids_set, index_table_id, schema_guard))) { STORAGE_LOG(WARN, "failed to check sstable ids contain schema table id", K(ret), K(index_table_id)); @@ -1520,8 +1544,8 @@ int ObPGPartitionBaseDataMetaRestoreReaderV2::check_sstable_table_ids_in_table( } int ObPGPartitionBaseDataMetaRestoreReaderV2::check_sstable_ids_contain_schema_table_id( - const hash::ObHashSet& table_ids_set, const uint64_t schema_table_id, - schema::ObSchemaGetterGuard& schema_guard) + const hash::ObHashSet &table_ids_set, const uint64_t schema_table_id, + schema::ObSchemaGetterGuard &schema_guard) { int ret = OB_SUCCESS; if (OB_UNLIKELY(!is_inited_)) { @@ -1532,7 +1556,7 @@ int ObPGPartitionBaseDataMetaRestoreReaderV2::check_sstable_ids_contain_schema_t int hash_ret = table_ids_set.exist_refactored(schema_table_id); if (OB_HASH_EXIST == hash_ret) { } else if (OB_HASH_NOT_EXIST == hash_ret) { - const ObTableSchema* table_schema = NULL; + const ObTableSchema *table_schema = NULL; if (OB_FAIL(schema_guard.get_table_schema(schema_table_id, table_schema))) { STORAGE_LOG(WARN, "failed to get table schema", K(ret), K(schema_table_id)); } else if (OB_ISNULL(table_schema)) { @@ -1582,7 +1606,7 @@ bool ObPhyRestoreMacroIndexStoreV2::is_inited() const } int ObPhyRestoreMacroIndexStoreV2::init( - const int64_t backup_task_id, const share::ObPhysicalRestoreArg& arg, const ObReplicaRestoreStatus& restore_status) + const int64_t backup_task_id, const share::ObPhysicalRestoreArg &arg, const ObReplicaRestoreStatus &restore_status) { int ret = OB_SUCCESS; ObStorageUtil util(true /*need retry*/); @@ -1631,8 +1655,8 @@ int ObPhyRestoreMacroIndexStoreV2::init( return ret; } -int ObPhyRestoreMacroIndexStoreV2::init_major_macro_index(const common::ObPartitionKey& backup_pg_key, - const ObBackupBaseDataPathInfo& path_info, const ObReplicaRestoreStatus& restore_status) +int ObPhyRestoreMacroIndexStoreV2::init_major_macro_index(const common::ObPartitionKey &backup_pg_key, + const ObBackupBaseDataPathInfo &path_info, const ObReplicaRestoreStatus &restore_status) { int ret = OB_SUCCESS; ObSimpleBackupSetPath simple_path; @@ -1644,8 +1668,8 @@ int ObPhyRestoreMacroIndexStoreV2::init_major_macro_index(const common::ObPartit return ret; } -int ObPhyRestoreMacroIndexStoreV2::init_major_macro_index(const common::ObPartitionKey& backup_pg_key, - const ObSimpleBackupSetPath& simple_path, const ObReplicaRestoreStatus& restore_status) +int ObPhyRestoreMacroIndexStoreV2::init_major_macro_index(const common::ObPartitionKey &backup_pg_key, + const ObSimpleBackupSetPath &simple_path, const ObReplicaRestoreStatus &restore_status) { int ret = OB_SUCCESS; bool is_exist = true; @@ -1685,8 +1709,8 @@ int ObPhyRestoreMacroIndexStoreV2::init_major_macro_index(const common::ObPartit } int ObPhyRestoreMacroIndexStoreV2::init_minor_macro_index(const int64_t backup_task_id, - const common::ObPartitionKey& backup_pg_key, const ObBackupBaseDataPathInfo& path_info, - const ObReplicaRestoreStatus& restore_status) + const common::ObPartitionKey &backup_pg_key, const ObBackupBaseDataPathInfo &path_info, + const ObReplicaRestoreStatus &restore_status) { int ret = OB_SUCCESS; ObSimpleBackupSetPath simple_path; @@ -1699,8 +1723,8 @@ int ObPhyRestoreMacroIndexStoreV2::init_minor_macro_index(const int64_t backup_t } int ObPhyRestoreMacroIndexStoreV2::init_minor_macro_index(const int64_t backup_task_id, - const common::ObPartitionKey& backup_pg_key, const ObSimpleBackupSetPath& simple_path, - const ObReplicaRestoreStatus& restore_status) + const common::ObPartitionKey &backup_pg_key, const ObSimpleBackupSetPath &simple_path, + const ObReplicaRestoreStatus &restore_status) { int ret = OB_SUCCESS; bool is_exist = true; @@ -1749,8 +1773,8 @@ int ObPhyRestoreMacroIndexStoreV2::init_minor_macro_index(const int64_t backup_t return ret; } -int ObPhyRestoreMacroIndexStoreV2::init(const int64_t backup_task_id, const common::ObPartitionKey& pkey, - const share::ObPhysicalBackupArg& arg, const ObBackupDataType& backup_data_type) +int ObPhyRestoreMacroIndexStoreV2::init(const int64_t backup_task_id, const common::ObPartitionKey &pkey, + const share::ObPhysicalBackupArg &arg, const ObBackupDataType &backup_data_type) { int ret = OB_SUCCESS; ObBackupBaseDataPathInfo path_info; @@ -1760,28 +1784,23 @@ int ObPhyRestoreMacroIndexStoreV2::init(const int64_t backup_task_id, const comm if (is_inited_) { ret = OB_INIT_TWICE; - STORAGE_LOG(WARN, "physical restore macro index store init twice", K(ret)); - } else if (backup_task_id < 0 || !pkey.is_valid() || OB_UNLIKELY(!arg.is_valid()) || !backup_data_type.is_valid()) { + STORAGE_LOG(WARN, "physcial restore macro index store init twice", K(ret)); + } else if (backup_task_id < 0 || !pkey.is_valid() || OB_UNLIKELY(!arg.is_valid()) || !backup_data_type.is_valid() || + backup_data_type.is_minor_backup()) { ret = OB_INVALID_ARGUMENT; STORAGE_LOG(WARN, - "init physical restore macro index get invalid argument", + "init physcial restore macro index get invalid argument", K(ret), K(backup_task_id), K(pkey), K(arg), K(backup_data_type)); - } else if (OB_FAIL(arg.get_backup_base_data_info(path_info))) { - STORAGE_LOG(WARN, "get backup base data info fail", K(ret)); } else if (OB_FAIL(index_map_.create(BUCKET_SIZE, ObModIds::RESTORE))) { STORAGE_LOG(WARN, "failed to create partition reader map", K(ret)); - } else if (backup_data_type.is_major_backup()) { - if (OB_FAIL(init_major_macro_index(pkey, path_info, restore_status))) { - STORAGE_LOG(WARN, "failed to init major macro index", K(ret), K(pkey), K(path_info)); - } - } else { - if (OB_FAIL(init_minor_macro_index(backup_task_id, pkey, path_info, restore_status))) { - STORAGE_LOG(WARN, "failed to init minor macro index", K(ret), K(backup_task_id), K(pkey)); - } + } else if (OB_FAIL(arg.get_prev_base_data_info(path_info))) { + STORAGE_LOG(WARN, "get backup base data info fail", K(ret)); + } else if (OB_FAIL(init_major_macro_index(pkey, path_info, restore_status))) { + STORAGE_LOG(WARN, "failed to init major macro index", K(ret), K(pkey), K(path_info)); } if (OB_SUCC(ret)) { @@ -1792,25 +1811,26 @@ int ObPhyRestoreMacroIndexStoreV2::init(const int64_t backup_task_id, const comm return ret; } -int ObPhyRestoreMacroIndexStoreV2::init_one_file(const ObString& path, const ObString& storage_info) +int ObPhyRestoreMacroIndexStoreV2::init_one_file(const ObString &path, const ObString &storage_info) { int ret = OB_SUCCESS; common::ObArenaAllocator allocator(ObModIds::RESTORE); - char* read_buf = NULL; + char *read_buf = NULL; int64_t read_size = 0; + if (OB_FAIL(ObRestoreFileUtil::read_one_file(path, storage_info, allocator, read_buf, read_size))) { STORAGE_LOG(WARN, "fail to read index file", K(ret), K(path)); } else if (read_size <= 0) { STORAGE_LOG(INFO, "may be empty block index file", K(ret), K(path)); } else { ObBufferReader buffer_reader(read_buf, read_size, 0); - const ObBackupCommonHeader* common_header = NULL; + const ObBackupCommonHeader *common_header = NULL; ObBackupTableMacroIndex macro_index; ObArray index_list; ObITable::TableKey cur_table_key; ObBackupTableKeyInfo table_key_info; int64_t sstable_macro_block_index = -1; - const ObITable::TableKey* table_key_ptr = NULL; + const ObITable::TableKey *table_key_ptr = NULL; while (OB_SUCC(ret) && buffer_reader.remain() > 0) { common_header = NULL; if (OB_FAIL(buffer_reader.get(common_header))) { @@ -1904,11 +1924,11 @@ int ObPhyRestoreMacroIndexStoreV2::init_one_file(const ObString& path, const ObS } int ObPhyRestoreMacroIndexStoreV2::add_sstable_index( - const ObITable::TableKey& table_key, const common::ObIArray& index_list) + const ObITable::TableKey &table_key, const common::ObIArray &index_list) { int ret = OB_SUCCESS; - void* buf = NULL; - ObArray* new_block_list = NULL; + void *buf = NULL; + ObArray *new_block_list = NULL; int64_t block_count = index_list.count(); if (!table_key.is_valid()) { @@ -1938,7 +1958,7 @@ int ObPhyRestoreMacroIndexStoreV2::add_sstable_index( } for (int i = 0; OB_SUCC(ret) && i < index_list.count(); ++i) { - const ObBackupTableMacroIndex& index = index_list.at(i); // check + const ObBackupTableMacroIndex &index = index_list.at(i); // check if (index.sstable_macro_index_ < new_block_list->count()) { // skip } else if (OB_UNLIKELY(index.sstable_macro_index_ != new_block_list->count())) { @@ -1959,11 +1979,11 @@ int ObPhyRestoreMacroIndexStoreV2::add_sstable_index( } int ObPhyRestoreMacroIndexStoreV2::get_macro_index_array( - const ObITable::TableKey& table_key, const common::ObArray*& index_list) const + const ObITable::TableKey &table_key, const common::ObArray *&index_list) const { int ret = OB_SUCCESS; index_list = NULL; - common::ObArray* tmp_list = NULL; + common::ObArray *tmp_list = NULL; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; STORAGE_LOG(WARN, "macro index store do not init", K(ret)); @@ -1979,11 +1999,11 @@ int ObPhyRestoreMacroIndexStoreV2::get_macro_index_array( } int ObPhyRestoreMacroIndexStoreV2::get_macro_index( - const ObITable::TableKey& table_key, const int64_t sstable_macro_idx, ObBackupTableMacroIndex& macro_index) const + const ObITable::TableKey &table_key, const int64_t sstable_macro_idx, ObBackupTableMacroIndex ¯o_index) const { int ret = OB_SUCCESS; macro_index.reset(); - common::ObArray* index_list = NULL; + common::ObArray *index_list = NULL; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; STORAGE_LOG(WARN, "macro index store do not init", K(ret)); @@ -2013,10 +2033,10 @@ int ObPhyRestoreMacroIndexStoreV2::get_macro_index( } int ObPhyRestoreMacroIndexStoreV2::get_sstable_pair_list( - const ObITable::TableKey& table_key, common::ObIArray& pair_list) const + const ObITable::TableKey &table_key, common::ObIArray &pair_list) const { int ret = OB_SUCCESS; - common::ObArray* index_list = NULL; + common::ObArray *index_list = NULL; pair_list.reuse(); if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; @@ -2048,11 +2068,11 @@ int ObPhyRestoreMacroIndexStoreV2::get_sstable_pair_list( } int ObPhyRestoreMacroIndexStoreV2::get_major_macro_index_array( - const uint64_t table_id, const common::ObArray*& index_list) const + const uint64_t table_id, const common::ObArray *&index_list) const { int ret = OB_SUCCESS; index_list = NULL; - common::ObArray* tmp_list = NULL; + common::ObArray *tmp_list = NULL; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; STORAGE_LOG(WARN, "macro index store do not init", K(ret)); @@ -2061,7 +2081,7 @@ int ObPhyRestoreMacroIndexStoreV2::get_major_macro_index_array( STORAGE_LOG(WARN, "get macro index array get invalid argument", K(ret), K(table_id)); } else { for (MacroIndexMap::const_iterator iter = index_map_.begin(); iter != index_map_.end(); ++iter) { - const ObITable::TableKey& table_key = iter->first; + const ObITable::TableKey &table_key = iter->first; if (!table_key.is_major_sstable()) { // do nothing } else if (table_id == table_key.table_id_) { @@ -2081,7 +2101,7 @@ int ObPhyRestoreMacroIndexStoreV2::get_major_macro_index_array( } int ObPhyRestoreMacroIndexStoreV2::get_table_key_ptr( - const ObITable::TableKey& table_key, const ObITable::TableKey*& table_key_ptr) + const ObITable::TableKey &table_key, const ObITable::TableKey *&table_key_ptr) { int ret = OB_SUCCESS; table_key_ptr = NULL; @@ -2091,7 +2111,7 @@ int ObPhyRestoreMacroIndexStoreV2::get_table_key_ptr( } else { bool found = false; for (int64_t i = 0; i < table_keys_ptr_.count() && !found; ++i) { - const ObITable::TableKey& tmp_table_key = *table_keys_ptr_.at(i); + const ObITable::TableKey &tmp_table_key = *table_keys_ptr_.at(i); if (tmp_table_key == table_key) { table_key_ptr = table_keys_ptr_.at(i); found = true; @@ -2099,12 +2119,12 @@ int ObPhyRestoreMacroIndexStoreV2::get_table_key_ptr( } if (!found) { - void* buf = allocator_.alloc(sizeof(ObITable::TableKey)); + void *buf = allocator_.alloc(sizeof(ObITable::TableKey)); if (NULL == buf) { ret = OB_ALLOCATE_MEMORY_FAILED; STORAGE_LOG(WARN, "fail to alloc memory", K(ret)); } else { - ObITable::TableKey* tmp_table_key_ptr = new (buf) ObITable::TableKey(); + ObITable::TableKey *tmp_table_key_ptr = new (buf) ObITable::TableKey(); *tmp_table_key_ptr = table_key; if (OB_FAIL(table_keys_ptr_.push_back(tmp_table_key_ptr))) { STORAGE_LOG(WARN, "failed to push table key into array", K(ret), K(*tmp_table_key_ptr)); @@ -2116,3 +2136,27 @@ int ObPhyRestoreMacroIndexStoreV2::get_table_key_ptr( } return ret; } + +int ObPhyRestoreMacroIndexStoreV2::check_table_exist(const ObITable::TableKey &table_key, bool &is_exist) const +{ + int ret = OB_SUCCESS; + is_exist = false; + if (!table_key.is_valid()) { + ret = OB_INVALID_ARGUMENT; + STORAGE_LOG(WARN, "check table exist get invalid argument", K(ret), K(table_key)); + } else { + for (MacroIndexMap::const_iterator iter = index_map_.begin(); OB_SUCC(ret) && iter != index_map_.end(); ++iter) { + const uint64_t table_id = iter->first.table_id_; + if (table_id == table_key.table_id_) { + if (OB_ISNULL(iter->second)) { + ret = OB_ERR_UNEXPECTED; + STORAGE_LOG(WARN, "index list should not be NULL", K(ret), K(table_key), KP(iter->second)); + } else { + is_exist = true; + break; + } + } + } + } + return ret; +} diff --git a/src/storage/backup/ob_partition_base_data_physical_restore_v2.h b/src/storage/backup/ob_partition_base_data_physical_restore_v2.h index 795c98c7b..a78cdba8b 100644 --- a/src/storage/backup/ob_partition_base_data_physical_restore_v2.h +++ b/src/storage/backup/ob_partition_base_data_physical_restore_v2.h @@ -30,18 +30,18 @@ public: ObPhyRestoreMacroIndexStoreV2(); virtual ~ObPhyRestoreMacroIndexStoreV2(); void reset(); - int init(const int64_t backup_task_id, const share::ObPhysicalRestoreArg& arg, - const ObReplicaRestoreStatus& restore_status); - int init(const int64_t backup_task_id, const common::ObPartitionKey& pkey, const share::ObPhysicalBackupArg& arg, - const ObBackupDataType& backup_data_type); + int init(const int64_t backup_task_id, const share::ObPhysicalRestoreArg &arg, + const ObReplicaRestoreStatus &restore_status); + int init(const int64_t backup_task_id, const common::ObPartitionKey &pkey, const share::ObPhysicalBackupArg &arg, + const ObBackupDataType &backup_data_type); int get_macro_index_array( - const ObITable::TableKey& table_key, const common::ObArray*& index_list) const; + const ObITable::TableKey &table_key, const common::ObArray *&index_list) const; int get_macro_index( - const ObITable::TableKey& table_key, const int64_t sstable_idx, ObBackupTableMacroIndex& macro_index) const; + const ObITable::TableKey &table_key, const int64_t sstable_idx, ObBackupTableMacroIndex ¯o_index) const; int get_sstable_pair_list( - const ObITable::TableKey& table_key, common::ObIArray& pair_list) const; + const ObITable::TableKey &table_key, common::ObIArray &pair_list) const; int get_major_macro_index_array( - const uint64_t index_table_id, const common::ObArray*& index_list) const; + const uint64_t index_table_id, const common::ObArray *&index_list) const; int64_t get_backup_task_id() const { return backup_task_id_; @@ -51,31 +51,33 @@ public: return PHY_RESTORE_MACRO_INDEX_STORE_V2; } virtual bool is_inited() const; + int check_table_exist(const ObITable::TableKey &table_key, bool &is_exist) const; TO_STRING_KV(K_(is_inited)); private: - int init_major_macro_index(const common::ObPartitionKey& backup_pg_key, const ObBackupBaseDataPathInfo& path_info, - const ObReplicaRestoreStatus& restore_status); - int init_major_macro_index(const common::ObPartitionKey& backup_pg_key, const ObSimpleBackupSetPath& simple_path, - const ObReplicaRestoreStatus& restore_status); - int init_minor_macro_index(const int64_t backup_task_id, const common::ObPartitionKey& backup_pg_key, - const ObBackupBaseDataPathInfo& path_info, const ObReplicaRestoreStatus& restore_status); - int init_minor_macro_index(const int64_t backup_task_id, const common::ObPartitionKey& backup_pg_key, - const ObSimpleBackupSetPath& simple_path, const ObReplicaRestoreStatus& restore_status); + int init_major_macro_index(const common::ObPartitionKey &backup_pg_key, const ObBackupBaseDataPathInfo &path_info, + const ObReplicaRestoreStatus &restore_status); + int init_major_macro_index(const common::ObPartitionKey &backup_pg_key, const ObSimpleBackupSetPath &simple_path, + const ObReplicaRestoreStatus &restore_status); + + int init_minor_macro_index(const int64_t backup_task_id, const common::ObPartitionKey &backup_pg_key, + const ObBackupBaseDataPathInfo &path_info, const ObReplicaRestoreStatus &restore_status); + int init_minor_macro_index(const int64_t backup_task_id, const common::ObPartitionKey &backup_pg_key, + const ObSimpleBackupSetPath &simple_path, const ObReplicaRestoreStatus &restore_status); int add_sstable_index( - const ObITable::TableKey& table_key, const common::ObIArray& index_list); - int init_one_file(const ObString& path, const ObString& storage_info); - int get_table_key_ptr(const ObITable::TableKey& table_key, const ObITable::TableKey*& table_key_ptr); + const ObITable::TableKey &table_key, const common::ObIArray &index_list); + int init_one_file(const ObString &path, const ObString &storage_info); + int get_table_key_ptr(const ObITable::TableKey &table_key, const ObITable::TableKey *&table_key_ptr); private: static const int64_t BUCKET_SIZE = 100000; // 10w - typedef common::hash::ObHashMap*> MacroIndexMap; + typedef common::hash::ObHashMap *> MacroIndexMap; bool is_inited_; common::ObArenaAllocator allocator_; MacroIndexMap index_map_; int64_t backup_task_id_; - ObArray table_keys_ptr_; + ObArray table_keys_ptr_; DISALLOW_COPY_AND_ASSIGN(ObPhyRestoreMacroIndexStoreV2); }; @@ -84,32 +86,32 @@ public: ObPartitionBaseDataMetaRestoreReaderV2(); virtual ~ObPartitionBaseDataMetaRestoreReaderV2(); void reset(); - int init(const common::ObPartitionKey& pkey, const ObPhysicalRestoreArg& restore_info, - const ObPhyRestoreMacroIndexStoreV2& macro_indexs, const ObBackupPartitionStoreMetaInfo& backup_pg_meta_info, + int init(const common::ObPartitionKey &pkey, const ObPhysicalRestoreArg &restore_info, + const ObPhyRestoreMacroIndexStoreV2 ¯o_indexs, const ObBackupPartitionStoreMetaInfo &backup_pg_meta_info, const int64_t schema_version); - int fetch_partition_meta(ObPGPartitionStoreMeta& partition_store_meta); - int fetch_sstable_meta(const ObITable::TableKey& table_key, blocksstable::ObSSTableBaseMeta& sstable_meta); + int fetch_partition_meta(ObPGPartitionStoreMeta &partition_store_meta); + int fetch_sstable_meta(const ObITable::TableKey &table_key, blocksstable::ObSSTableBaseMeta &sstable_meta); int fetch_sstable_pair_list( - const ObITable::TableKey& table_key, common::ObIArray& pair_list); - int fetch_all_table_ids(common::ObIArray& table_id_array); - int fetch_table_keys(const uint64_t index_id, obrpc::ObFetchTableInfoResult& table_res); + const ObITable::TableKey &table_key, common::ObIArray &pair_list); + int fetch_all_table_ids(common::ObIArray &table_id_array); + int fetch_table_keys(const uint64_t index_id, obrpc::ObFetchTableInfoResult &table_res); TO_STRING_KV( K_(pkey), K_(restore_info), K_(last_read_size), K_(partition_store_meta), K_(data_version), K_(schema_version)); private: - int prepare(const common::ObPartitionKey& pkey); - int trans_table_key(const ObITable::TableKey& table_Key, ObITable::TableKey& backup_table_key); + int prepare(const common::ObPartitionKey &pkey); + int trans_table_key(const ObITable::TableKey &table_Key, ObITable::TableKey &backup_table_key); int get_backup_sstable_meta_info( - const ObITable::TableKey& backup_table_key, const ObBackupSSTableMetaInfo*& backup_sstable_meta_info); - int get_backup_table_keys(const uint64_t backup_index_id, common::ObIArray& table_keys); - int do_filter_tables(common::ObIArray& table_ids); + const ObITable::TableKey &backup_table_key, const ObBackupSSTableMetaInfo *&backup_sstable_meta_info); + int get_backup_table_keys(const uint64_t backup_index_id, common::ObIArray &table_keys); + int do_filter_tables(common::ObIArray &table_ids); private: bool is_inited_; common::ObPartitionKey pkey_; - const ObPhysicalRestoreArg* restore_info_; - const ObPhyRestoreMacroIndexStoreV2* macro_indexs_; - const ObBackupPartitionStoreMetaInfo* partition_store_meta_info_; + const ObPhysicalRestoreArg *restore_info_; + const ObPhyRestoreMacroIndexStoreV2 *macro_indexs_; + const ObBackupPartitionStoreMetaInfo *partition_store_meta_info_; int64_t last_read_size_; ObPGPartitionStoreMeta partition_store_meta_; int64_t data_version_; @@ -123,10 +125,10 @@ public: ObPhysicalBaseMetaRestoreReaderV2(); virtual ~ObPhysicalBaseMetaRestoreReaderV2() {} - int init(common::ObInOutBandwidthThrottle& bandwidth_throttle, const ObPhysicalRestoreArg& restore_info, - const ObITable::TableKey& table_key, ObIPartitionGroupMetaRestoreReader& reader); - virtual int fetch_sstable_meta(blocksstable::ObSSTableBaseMeta& sstable_meta); - virtual int fetch_macro_block_list(common::ObIArray& macro_block_list); + int init(common::ObInOutBandwidthThrottle &bandwidth_throttle, const ObPhysicalRestoreArg &restore_info, + const ObITable::TableKey &table_key, ObIPartitionGroupMetaRestoreReader &reader); + virtual int fetch_sstable_meta(blocksstable::ObSSTableBaseMeta &sstable_meta); + virtual int fetch_macro_block_list(common::ObIArray ¯o_block_list); virtual Type get_type() const { return BASE_DATA_META_RESTORE_READER_V1; @@ -134,10 +136,10 @@ public: private: bool is_inited_; - const ObPhysicalRestoreArg* restore_info_; - ObIPartitionGroupMetaRestoreReader* reader_; + const ObPhysicalRestoreArg *restore_info_; + ObIPartitionGroupMetaRestoreReader *reader_; common::ObArenaAllocator allocator_; - common::ObInOutBandwidthThrottle* bandwidth_throttle_; + common::ObInOutBandwidthThrottle *bandwidth_throttle_; ObITable::TableKey table_key_; DISALLOW_COPY_AND_ASSIGN(ObPhysicalBaseMetaRestoreReaderV2); }; @@ -147,11 +149,11 @@ public: ObPartitionMacroBlockRestoreReaderV2(); virtual ~ObPartitionMacroBlockRestoreReaderV2(); void reset(); - int init(common::ObInOutBandwidthThrottle& bandwidth_throttle, common::ObIArray& list, - const ObPhysicalRestoreArg& restore_info, const ObPhyRestoreMacroIndexStoreV2& macro_indexs, - const ObITable::TableKey& table_key); - virtual int get_next_macro_block(blocksstable::ObFullMacroBlockMeta& meta, blocksstable::ObBufferReader& data, - blocksstable::MacroBlockId& src_macro_id); + int init(common::ObInOutBandwidthThrottle &bandwidth_throttle, common::ObIArray &list, + const ObPhysicalRestoreArg &restore_info, const ObPhyRestoreMacroIndexStoreV2 ¯o_indexs, + const ObITable::TableKey &table_key); + virtual int get_next_macro_block(blocksstable::ObFullMacroBlockMeta &meta, blocksstable::ObBufferReader &data, + blocksstable::MacroBlockId &src_macro_id); virtual Type get_type() const { return MACRO_BLOCK_RESTORE_READER_V2; @@ -163,8 +165,8 @@ public: private: int trans_macro_block( - const uint64_t table_id, blocksstable::ObMacroBlockMetaV2& meta, blocksstable::ObBufferReader& data); - int get_macro_block_path(const ObBackupTableMacroIndex& macro_index, share::ObBackupPath& path); + const uint64_t table_id, blocksstable::ObMacroBlockMetaV2 &meta, blocksstable::ObBufferReader &data); + int get_macro_block_path(const ObBackupTableMacroIndex ¯o_index, share::ObBackupPath &path); private: bool is_inited_; @@ -174,11 +176,12 @@ private: uint64_t table_id_; ObSimpleBackupSetPath simple_path_; ObBackupBaseDataPathInfo backup_path_info_; - const ObPhyRestoreMacroIndexStoreV2* macro_indexs_; - common::ObInOutBandwidthThrottle* bandwidth_throttle_; + const ObPhyRestoreMacroIndexStoreV2 *macro_indexs_; + common::ObInOutBandwidthThrottle *bandwidth_throttle_; ObPartitionKey backup_pgkey_; ObITable::TableKey backup_table_key_; common::ObArenaAllocator allocator_; + const ObPhysicalRestoreArg *restore_info_; DISALLOW_COPY_AND_ASSIGN(ObPartitionMacroBlockRestoreReaderV2); }; @@ -187,49 +190,49 @@ public: ObPartitionGroupMetaRestoreReaderV2(); virtual ~ObPartitionGroupMetaRestoreReaderV2(); void reset(); - int init(common::ObInOutBandwidthThrottle& bandwidth_throttle, const ObPhysicalRestoreArg& restore_info, - const ObPhyRestoreMetaIndexStore& meta_indexs, const ObPhyRestoreMacroIndexStoreV2& macro_indexs); - virtual int fetch_partition_group_meta(ObPartitionGroupMeta& pg_meta); + int init(common::ObInOutBandwidthThrottle &bandwidth_throttle, const ObPhysicalRestoreArg &restore_info, + const ObPhyRestoreMetaIndexStore &meta_indexs, const ObPhyRestoreMacroIndexStoreV2 ¯o_indexs); + virtual int fetch_partition_group_meta(ObPartitionGroupMeta &pg_meta); virtual int64_t get_data_size() const { return reader_.get_data_size(); } - virtual int fetch_sstable_meta(const ObITable::TableKey& table_key, blocksstable::ObSSTableBaseMeta& sstable_meta); + virtual int fetch_sstable_meta(const ObITable::TableKey &table_key, blocksstable::ObSSTableBaseMeta &sstable_meta); virtual int fetch_sstable_pair_list( - const ObITable::TableKey& table_key, common::ObIArray& pair_list); + const ObITable::TableKey &table_key, common::ObIArray &pair_list); virtual Type get_type() const { return PG_META_RESTORE_READER_V2; }; - int get_partition_readers(const ObPartitionArray& partitions, - common::ObIArray& partition_reader_array); - int get_restore_tenant_id(uint64_t& tenant_id); - int get_restore_schema_version(int64_t& schema_version); + int get_partition_readers(const ObPartitionArray &partitions, + common::ObIArray &partition_reader_array); + int get_restore_tenant_id(uint64_t &tenant_id); + int get_restore_schema_version(int64_t &schema_version); private: - int prepare(const ObPhysicalRestoreArg& restore_info, const ObPhyRestoreMacroIndexStoreV2& macro_indexs); - int prepare_pg_meta(const ObPhysicalRestoreArg& restore_info); - int create_pg_partition_if_need(const ObPhysicalRestoreArg& restore_info, const ObPartitionGroupMeta& backup_pg_meta); - int read_partition_meta(const ObPartitionKey& pkey, const ObPhysicalRestoreArg& restore_info, - ObPGPartitionStoreMeta& partition_store_meta); - int trans_backup_pgmeta(const ObPhysicalRestoreArg& restore_info, ObPartitionGroupMeta& backup_pg_meta); - int check_backup_partitions_in_pg(const ObPhysicalRestoreArg& restore_info, ObPartitionGroupMeta& backup_pg_meta); - int get_backup_partition_meta_info(const ObPartitionKey& pkey, const ObPhysicalRestoreArg& restore_info, - const ObBackupPartitionStoreMetaInfo*& backup_partition_meta_info); - int trans_from_backup_partitions(const ObPhysicalRestoreArg& restore_info, - const common::ObPartitionArray& backup_partitions, common::ObPartitionArray& current_partitions); - int trans_to_backup_partitions(const ObPhysicalRestoreArg& restore_info, - const common::ObPartitionArray& current_partitions, common::ObPartitionArray& backup_partitions); - int do_filter_pg_partitions(const ObPGKey& pg_key, ObPartitionArray& partitions); + int prepare(const ObPhysicalRestoreArg &restore_info, const ObPhyRestoreMacroIndexStoreV2 ¯o_indexs); + int prepare_pg_meta(const ObPhysicalRestoreArg &restore_info); + int create_pg_partition_if_need(const ObPhysicalRestoreArg &restore_info, const ObPartitionGroupMeta &backup_pg_meta); + int read_partition_meta(const ObPartitionKey &pkey, const ObPhysicalRestoreArg &restore_info, + ObPGPartitionStoreMeta &partition_store_meta); + int trans_backup_pgmeta(const ObPhysicalRestoreArg &restore_info, ObPartitionGroupMeta &backup_pg_meta); + int check_backup_partitions_in_pg(const ObPhysicalRestoreArg &restore_info, ObPartitionGroupMeta &backup_pg_meta); + int get_backup_partition_meta_info(const ObPartitionKey &pkey, const ObPhysicalRestoreArg &restore_info, + const ObBackupPartitionStoreMetaInfo *&backup_partition_meta_info); + int trans_from_backup_partitions(const ObPhysicalRestoreArg &restore_info, + const common::ObPartitionArray &backup_partitions, common::ObPartitionArray ¤t_partitions); + int trans_to_backup_partitions(const ObPhysicalRestoreArg &restore_info, + const common::ObPartitionArray ¤t_partitions, common::ObPartitionArray &backup_partitions); + int do_filter_pg_partitions(const ObPGKey &pg_key, ObPartitionArray &partitions); private: - typedef hash::ObHashMap MetaReaderMap; + typedef hash::ObHashMap MetaReaderMap; bool is_inited_; - const ObPhysicalRestoreArg* restore_info_; - const ObPhyRestoreMetaIndexStore* meta_indexs_; + const ObPhysicalRestoreArg *restore_info_; + const ObPhyRestoreMetaIndexStore *meta_indexs_; ObPGMetaPhysicalReader reader_; ObPartitionGroupMeta pg_meta_; - common::ObInOutBandwidthThrottle* bandwidth_throttle_; + common::ObInOutBandwidthThrottle *bandwidth_throttle_; int64_t last_read_size_; MetaReaderMap partition_reader_map_; common::ObArenaAllocator allocator_; @@ -244,22 +247,22 @@ public: ObPGPartitionBaseDataMetaRestoreReaderV2(); virtual ~ObPGPartitionBaseDataMetaRestoreReaderV2(); void reset(); - int init(const ObPartitionArray& partitions, ObPartitionGroupMetaRestoreReaderV2* reader); - int fetch_pg_partition_meta_info(obrpc::ObPGPartitionMetaInfo& partition_meta_info); + int init(const ObPartitionArray &partitions, ObPartitionGroupMetaRestoreReaderV2 *reader); + int fetch_pg_partition_meta_info(obrpc::ObPGPartitionMetaInfo &partition_meta_info); virtual Type get_type() const { return BASE_DATA_META_OB_RESTORE_READER_V2; } private: - int check_sstable_table_ids_in_table(const ObPartitionKey& pkey, const common::ObIArray& table_ids); - int check_sstable_ids_contain_schema_table_id(const hash::ObHashSet& table_id_set, - const uint64_t schema_table_id, schema::ObSchemaGetterGuard& schema_guard); + int check_sstable_table_ids_in_table(const ObPartitionKey &pkey, const common::ObIArray &table_ids); + int check_sstable_ids_contain_schema_table_id(const hash::ObHashSet &table_id_set, + const uint64_t schema_table_id, schema::ObSchemaGetterGuard &schema_guard); private: bool is_inited_; int64_t reader_index_; - common::ObArray partition_reader_array_; + common::ObArray partition_reader_array_; int64_t schema_version_; DISALLOW_COPY_AND_ASSIGN(ObPGPartitionBaseDataMetaRestoreReaderV2); }; diff --git a/src/storage/ob_partition_backup.cpp b/src/storage/ob_partition_backup.cpp index fb3c862e3..e9525a943 100644 --- a/src/storage/ob_partition_backup.cpp +++ b/src/storage/ob_partition_backup.cpp @@ -813,8 +813,12 @@ int ObPartGroupBackupTask::check_before_backup() ObExternBackupInfoMgr extern_backup_info_mgr; ObClusterBackupDest cluster_backup_dest; ObBackupDest backup_dest; - ObFakeBackupLeaseService fake_backup_lease_service; - ObExternBackupInfo last_backup_info; + ObBackupPath path; + ObStorageUtil util(false /*need retry*/); + bool is_exist = false; + + // For nfs 4.2 may has bug, which makes open wrong file handle + // There just check file exist if (!is_inited_) { ret = OB_NOT_INIT; STORAGE_LOG(WARN, "not inited", K(ret)); @@ -828,17 +832,13 @@ int ObPartGroupBackupTask::check_before_backup() STORAGE_LOG(WARN, "failed to set backup dest", K(ret), K(backup_arg)); } else if (OB_FAIL(cluster_backup_dest.set(backup_dest, backup_arg.incarnation_))) { STORAGE_LOG(WARN, "failed to set cluster backup dest", K(ret), K(backup_dest)); - } else if (OB_FAIL(extern_backup_info_mgr.init(tenant_id, cluster_backup_dest, fake_backup_lease_service))) { - STORAGE_LOG(WARN, "failed to init extern backup info", K(ret), K(cluster_backup_dest)); - } else if (OB_FAIL(extern_backup_info_mgr.get_last_info(last_backup_info))) { - STORAGE_LOG(WARN, "failed to get last info", K(ret), K(cluster_backup_dest)); - } else if (!last_backup_info.is_valid() || ObExternBackupInfo::DOING != last_backup_info.status_ || - last_backup_info.backup_data_version_ != backup_arg.backup_data_version_ || - last_backup_info.backup_schema_version_ != backup_arg.backup_schema_version_ || - last_backup_info.backup_type_ != backup_arg.backup_type_ || - last_backup_info.inc_backup_set_id_ != backup_arg.backup_set_id_) { + } else if (OB_FAIL(ObBackupPathUtil::get_tenant_data_backup_info_path(cluster_backup_dest, tenant_id, path))) { + LOG_WARN("failed to get tenant data backup info path", K(ret), K(backup_dest)); + } else if (OB_FAIL(util.is_exist(path.get_ptr(), backup_arg.storage_info_, is_exist))) { + LOG_WARN("failed to check extern backup file info exist", K(ret), K(path), K(backup_dest)); + } else if (!is_exist) { ret = OB_ERR_UNEXPECTED; - LOG_WARN("last backup info is unexpected", K(ret), K(last_backup_info), K(backup_arg)); + LOG_WARN("extern backup info is not exist", K(ret), K(backup_arg), K(path)); } } return ret; diff --git a/src/storage/ob_partition_base_data_backup.cpp b/src/storage/ob_partition_base_data_backup.cpp index c28a7b756..4c4bea92a 100644 --- a/src/storage/ob_partition_base_data_backup.cpp +++ b/src/storage/ob_partition_base_data_backup.cpp @@ -3110,16 +3110,8 @@ int ObBackupPhysicalPGCtx::check_table_exist( if (OB_UNLIKELY(!macro_index_store.is_inited() || !table_key.is_valid())) { ret = OB_INVALID_ARGUMENT; STORAGE_LOG(WARN, "invalid argument", K(ret), K(macro_index_store), K(table_key)); - } else if (OB_FAIL(macro_index_store.get_macro_index_array(table_key, macro_index_array))) { - if (OB_HASH_NOT_EXIST == ret) { - is_exist = false; - ret = OB_SUCCESS; - } - } else if (OB_ISNULL(macro_index_array)) { - ret = OB_ERR_UNEXPECTED; - LOG_WARN("macro index array should not be NULL", K(ret), K(table_key)); - } else { - is_exist = true; + } else if (OB_FAIL(macro_index_store.check_table_exist(table_key, is_exist))) { + STORAGE_LOG(WARN, "failed to check table exist", K(ret), K(table_key)); } return ret; } @@ -3340,6 +3332,7 @@ int ObBackupCopyPhysicalTask::process() } } } + STORAGE_LOG(INFO, "reuse backup macro count", K(block_info), K(copy_count), K(reuse_count)); } } if (OB_FAIL(ret)) { diff --git a/src/storage/ob_partition_migrator.cpp b/src/storage/ob_partition_migrator.cpp index 550b29b9f..324783638 100644 --- a/src/storage/ob_partition_migrator.cpp +++ b/src/storage/ob_partition_migrator.cpp @@ -3260,8 +3260,12 @@ int ObPartGroupMigrationTask::check_before_backup() ObExternBackupInfoMgr extern_backup_info_mgr; ObClusterBackupDest cluster_backup_dest; ObBackupDest backup_dest; - ObFakeBackupLeaseService fake_backup_lease_service; - ObExternBackupInfo last_backup_info; + ObBackupPath path; + ObStorageUtil util(false /*need retry*/); + bool is_exist = false; + + // For nfs 4.2 may has bug, which makes open wrong file handle + // There just check file exist if (!is_inited_) { ret = OB_NOT_INIT; STORAGE_LOG(WARN, "not inited", K(ret)); @@ -3275,17 +3279,13 @@ int ObPartGroupMigrationTask::check_before_backup() STORAGE_LOG(WARN, "failed to set backup dest", K(ret), K(backup_arg)); } else if (OB_FAIL(cluster_backup_dest.set(backup_dest, backup_arg.incarnation_))) { STORAGE_LOG(WARN, "failed to set cluster backup dest", K(ret), K(backup_dest)); - } else if (OB_FAIL(extern_backup_info_mgr.init(tenant_id, cluster_backup_dest, fake_backup_lease_service))) { - STORAGE_LOG(WARN, "failed to init extern backup info", K(ret), K(cluster_backup_dest)); - } else if (OB_FAIL(extern_backup_info_mgr.get_last_info(last_backup_info))) { - STORAGE_LOG(WARN, "failed to get last info", K(ret), K(cluster_backup_dest)); - } else if (!last_backup_info.is_valid() || ObExternBackupInfo::DOING != last_backup_info.status_ || - last_backup_info.backup_data_version_ != backup_arg.backup_data_version_ || - last_backup_info.backup_schema_version_ != backup_arg.backup_schema_version_ || - last_backup_info.backup_type_ != backup_arg.backup_type_ || - last_backup_info.inc_backup_set_id_ != backup_arg.backup_set_id_) { + } else if (OB_FAIL(ObBackupPathUtil::get_tenant_data_backup_info_path(cluster_backup_dest, tenant_id, path))) { + LOG_WARN("failed to get tenant data backup info path", K(ret), K(backup_dest)); + } else if (OB_FAIL(util.is_exist(path.get_ptr(), backup_arg.storage_info_, is_exist))) { + LOG_WARN("failed to check extern backup file info exist", K(ret), K(path), K(backup_dest)); + } else if (!is_exist) { ret = OB_ERR_UNEXPECTED; - LOG_WARN("last backup info is unexpected", K(ret), K(last_backup_info), K(backup_arg)); + LOG_WARN("extern backup info is not exist", K(ret), K(backup_arg), K(path)); } } return ret; @@ -5785,7 +5785,8 @@ int ObBackupDag::init(const ObBackupDataType &backup_data_type, ObMigrateCtx &ct ctx.replica_op_arg_.backup_arg_, ctx.replica_op_arg_.key_))) { LOG_WARN("failed to init physical backup ctx", K(ret), K(ctx.replica_op_arg_.backup_arg_)); - } else if (ctx.replica_op_arg_.backup_arg_.is_incremental_backup() && OB_ISNULL(ctx.macro_indexs_)) { + } else if (ctx.replica_op_arg_.backup_arg_.is_incremental_backup() && OB_ISNULL(ctx.macro_indexs_) && + backup_data_type.is_major_backup()) { ObPhyRestoreMacroIndexStoreV2 *phy_restore_macro_index_v2 = NULL; if (OB_ISNULL(phy_restore_macro_index_v2 = MIGRATOR.get_cp_fty()->get_phy_restore_macro_index_v2())) { ret = OB_ERR_UNEXPECTED;