From 525c146453079c6d1bf6fa68dc2f84a3a7ea4c39 Mon Sep 17 00:00:00 2001 From: SidewinderAK47 <1159409893@qq.com> Date: Thu, 6 Feb 2025 07:15:17 +0000 Subject: [PATCH] =?UTF-8?q?[FEAT=20MERGE]=E5=BF=AB=E9=80=9F=E6=81=A2?= =?UTF-8?q?=E5=A4=8D=E4=BC=98=E5=8C=96=E8=A1=A8=E7=BA=A7=E6=81=A2=E5=A4=8D?= =?UTF-8?q?=E6=80=A7=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../restore/ob_recover_table_initiator.cpp | 25 +++++++++++++++++++ .../restore/ob_recover_table_initiator.h | 1 + .../ob_recover_table_job_scheduler.cpp | 3 ++- src/share/restore/ob_restore_persist_helper.h | 3 +++ .../ob_sstable_copy_finish_task.cpp | 6 +++-- 5 files changed, 35 insertions(+), 3 deletions(-) diff --git a/src/rootserver/restore/ob_recover_table_initiator.cpp b/src/rootserver/restore/ob_recover_table_initiator.cpp index 200a8d65b3..095f002b0d 100644 --- a/src/rootserver/restore/ob_recover_table_initiator.cpp +++ b/src/rootserver/restore/ob_recover_table_initiator.cpp @@ -17,6 +17,7 @@ #include "ob_restore_util.h" #include "share/restore/ob_recover_table_persist_helper.h" #include "share/restore/ob_import_table_persist_helper.h" +#include "storage/high_availability/ob_storage_ha_utils.h" using namespace oceanbase; using namespace share::schema; @@ -170,6 +171,7 @@ int ObRecoverTableInitiator::insert_sys_job_( } else if (OB_FALSE_IT(physical_restore_job.set_initiator_job_id(job.get_job_id()))) { } else if (OB_FALSE_IT(physical_restore_job.set_initiator_tenant_id(OB_SYS_TENANT_ID))) { } else if (OB_FALSE_IT(physical_restore_job.set_recover_table(true))) { + } else if (OB_FAIL(fill_recover_table_restore_type_(physical_restore_job))) { } else if (OB_FAIL(ObRestoreUtil::record_physical_restore_job(trans, physical_restore_job))) { LOG_WARN("failed to record physical restore job", K(ret)); } @@ -513,4 +515,27 @@ int ObRecoverTableInitiator::fill_recover_table_arg_( LOG_WARN("failed to remap tablegroup", K(ret), K(arg.import_arg_)); } return ret; +} + +int ObRecoverTableInitiator::fill_recover_table_restore_type_(share::ObPhysicalRestoreJob &job) +{ + int ret = OB_SUCCESS; + /* 4.3.3 share noting mode support quick restore; 4.3.5 support mds table standby tenant read. + * In share noting mode, backup set data_version >= 4.3.5, recover table use quick physical restore. + * In other condition, recover table use full physical restore. */ + /* tenant_compatible_ & backup_compatible has been check in fill physical restore job */ + const uint64_t source_data_version = job.get_source_data_version(); + const ObBackupSetFileDesc::Compatible backup_compatible = + static_cast(job.get_backup_compatible()); + const bool is_allow_quick_restore = ObBackupSetFileDesc::is_allow_quick_restore(backup_compatible); + const bool is_allow_mds_standby_read = ObTransferUtils::enable_transfer_dml_ctrl(source_data_version); + // use quick restore should set table cnt display mode. + if (is_allow_quick_restore && is_allow_mds_standby_read) { + job.set_restore_type(QUICK_RESTORE_TYPE); + job.set_progress_display_mode(TABLET_CNT_DISPLAY_MODE); + } + + LOG_INFO("[RECOVER_TABLE] set recover table restore type", "restore_type", QUICK_RESTORE_TYPE, + "progress_display_mode", TABLET_CNT_DISPLAY_MODE); + return ret; } \ No newline at end of file diff --git a/src/rootserver/restore/ob_recover_table_initiator.h b/src/rootserver/restore/ob_recover_table_initiator.h index 74ee8e0e98..5e96336e78 100644 --- a/src/rootserver/restore/ob_recover_table_initiator.h +++ b/src/rootserver/restore/ob_recover_table_initiator.h @@ -83,6 +83,7 @@ private: share::ObImportRemapArg &import_remap_arg); int fill_remap_tablegroup(const share::ObImportArg &import_arg, share::ObImportRemapArg &import_remap_arg); + int fill_recover_table_restore_type_(share::ObPhysicalRestoreJob &job); private: bool is_inited_; diff --git a/src/rootserver/restore/ob_recover_table_job_scheduler.cpp b/src/rootserver/restore/ob_recover_table_job_scheduler.cpp index 460f9946f7..35e959a5ed 100644 --- a/src/rootserver/restore/ob_recover_table_job_scheduler.cpp +++ b/src/rootserver/restore/ob_recover_table_job_scheduler.cpp @@ -626,7 +626,8 @@ int ObRecoverTableJobScheduler::active_aux_tenant_(share::ObRecoverTableJob &job "initiator_job_id", job.get_job_id(), "initiator_tenant_id", job.get_tenant_id()); } else if (OB_FAIL(ban_multi_version_recycling_(job, restore_history_info.restore_tenant_id_))) { LOG_WARN("failed to ban multi version cecycling", K(ret)); - } else if (OB_FAIL(failover_to_primary_(job, restore_history_info.restore_tenant_id_))) { + } else if (restore_history_info.get_restore_type().is_full_restore() + && OB_FAIL(failover_to_primary_(job, restore_history_info.restore_tenant_id_))) { LOG_WARN("failed to failover to primary", K(ret), K(restore_history_info)); } if (OB_FAIL(ret)) { diff --git a/src/share/restore/ob_restore_persist_helper.h b/src/share/restore/ob_restore_persist_helper.h index cdff339a59..343ed36da2 100644 --- a/src/share/restore/ob_restore_persist_helper.h +++ b/src/share/restore/ob_restore_persist_helper.h @@ -362,6 +362,9 @@ struct ObHisRestoreJobPersistInfo final : public ObIInnerTableRow { return status_ == SUCCESS; } + const ObRestoreType &get_restore_type() const { + return restore_type_; + } const char *get_status_str() const; int get_status(const ObString &str_str) const; diff --git a/src/storage/high_availability/ob_sstable_copy_finish_task.cpp b/src/storage/high_availability/ob_sstable_copy_finish_task.cpp index 244c47b212..85055a17ce 100644 --- a/src/storage/high_availability/ob_sstable_copy_finish_task.cpp +++ b/src/storage/high_availability/ob_sstable_copy_finish_task.cpp @@ -1149,9 +1149,11 @@ int ObSSTableCopyFinishTask::get_space_optimization_mode_( LOG_WARN("sstable_param is null", K(ret)); } else if (sstable_param->table_key_.is_ddl_sstable()) { mode = ObSSTableIndexBuilder::DISABLE; - } else if (sstable_param->is_small_sstable_) { + } else if (ObTabletRestoreAction::is_restore_remote_sstable(copy_ctx_.restore_action_)) { + mode = ObSSTableIndexBuilder::DISABLE; + } else if (ObTabletRestoreAction::is_restore_replace_remote_sstable(copy_ctx_.restore_action_)) { mode = ObSSTableIndexBuilder::ENABLE; - } else if (sstable_param->basic_meta_.table_backup_flag_.has_backup()) { + } else if (sstable_param->is_small_sstable_) { mode = ObSSTableIndexBuilder::ENABLE; } else { mode = ObSSTableIndexBuilder::DISABLE;