From 723d5dd86ea0c2760db61e1e1a26d2edc5c0c3b1 Mon Sep 17 00:00:00 2001 From: obdev Date: Mon, 23 May 2022 15:26:53 +0800 Subject: [PATCH] [CP] [BUGFIX] Use backuped frozen status to restore system tables --- src/rootserver/ob_ddl_service.cpp | 9 ++++++++- src/rootserver/restore/ob_restore_scheduler.cpp | 2 ++ src/share/ob_rpc_struct.cpp | 6 ++++-- src/share/ob_rpc_struct.h | 4 +++- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/rootserver/ob_ddl_service.cpp b/src/rootserver/ob_ddl_service.cpp index 89f082448e..25e39da7c1 100755 --- a/src/rootserver/ob_ddl_service.cpp +++ b/src/rootserver/ob_ddl_service.cpp @@ -13967,6 +13967,7 @@ int ObDDLService::do_create_tenant_partitions(const ObCreateTenantArg &arg, int64_t non_paxos_replica_num = 0; int64_t restore = REPLICA_NOT_RESTORE; int64_t table_id = copy.get_table_id(); + share::ObSimpleFrozenStatus new_frozen_status = frozen_status; if (OB_FAIL(ret)) { } else if (is_restore) { // physical restore create_mode = OB_CREATE_TABLE_MODE_PHYSICAL_RESTORE; @@ -13977,6 +13978,12 @@ int ObDDLService::do_create_tenant_partitions(const ObCreateTenantArg &arg, int hash_ret = restore_partition_map.get_refactored(extract_pure_id(table_id), status); if (OB_SUCCESS == hash_ret) { restore = status; + // For system tables in physical restore: + // 1. REPLICA_RESTORE_DATA: frozen_status will be overwrite by storage, so it's unuseful. + // 2. REPLICA_RESTORE_ARCHIVE_DATA: frozen_version will be overwrite so it's unuseful, but + // frozen_timestamp should come from backup info to filter clog. + // 3. REPLICA_NOT_RESTORE: frozen_status should come from restore cluster. + new_frozen_status = arg.restore_frozen_status_; } else if (OB_HASH_NOT_EXIST == hash_ret) { // create sys table in tenant space which were not backuped in lower version. restore = REPLICA_NOT_RESTORE; @@ -14008,7 +14015,7 @@ int ObDDLService::do_create_tenant_partitions(const ObCreateTenantArg &arg, is_standby, create_mode, restore, - frozen_status))) { + new_frozen_status))) { LOG_WARN("fail to create partitions", K(ret)); } else { } // no more to do diff --git a/src/rootserver/restore/ob_restore_scheduler.cpp b/src/rootserver/restore/ob_restore_scheduler.cpp index 06d14521b6..31f3a6e2a5 100644 --- a/src/rootserver/restore/ob_restore_scheduler.cpp +++ b/src/rootserver/restore/ob_restore_scheduler.cpp @@ -380,6 +380,8 @@ int ObRestoreScheduler::fill_create_tenant_arg(const ObPhysicalRestoreJob &job, arg.tenant_schema_.set_compatibility_mode(mode); arg.if_not_exist_ = false; arg.is_restore_ = true; + arg.restore_frozen_status_.frozen_version_ = job.restore_data_version_; + arg.restore_frozen_status_.frozen_timestamp_ = job.frozen_snapshot_version_; if (OB_FAIL(assign_pool_list(job.pool_list_, arg.pool_list_))) { LOG_WARN("fail to get pool list", K(ret), K(job)); } diff --git a/src/share/ob_rpc_struct.cpp b/src/share/ob_rpc_struct.cpp index f2657e7dc2..590f44e4d2 100755 --- a/src/share/ob_rpc_struct.cpp +++ b/src/share/ob_rpc_struct.cpp @@ -481,6 +481,7 @@ int ObCreateTenantArg::assign(const ObCreateTenantArg& other) if_not_exist_ = other.if_not_exist_; name_case_mode_ = other.name_case_mode_; is_restore_ = other.is_restore_; + restore_frozen_status_ = other.restore_frozen_status_; } return ret; } @@ -495,12 +496,13 @@ DEF_TO_STRING(ObCreateTenantArg) K_(name_case_mode), K_(is_restore), K_(restore_pkeys), - K_(restore_log_pkeys)); + K_(restore_log_pkeys), + K_(restore_frozen_status)); return pos; } OB_SERIALIZE_MEMBER((ObCreateTenantArg, ObDDLArg), tenant_schema_, pool_list_, if_not_exist_, sys_var_list_, - name_case_mode_, is_restore_, restore_pkeys_, restore_log_pkeys_); + name_case_mode_, is_restore_, restore_pkeys_, restore_log_pkeys_, restore_frozen_status_); bool ObCreateTenantEndArg::is_valid() const { diff --git a/src/share/ob_rpc_struct.h b/src/share/ob_rpc_struct.h index 2ebcdf42e8..eda618ffa9 100755 --- a/src/share/ob_rpc_struct.h +++ b/src/share/ob_rpc_struct.h @@ -526,7 +526,8 @@ public: if_not_exist_(false), sys_var_list_(), name_case_mode_(common::OB_NAME_CASE_INVALID), - is_restore_(false) + is_restore_(false), + restore_frozen_status_() {} virtual ~ObCreateTenantArg(){}; bool is_valid() const; @@ -544,6 +545,7 @@ public: // is_restore = REPLICA_RESTORE_DATA common::ObSArray restore_log_pkeys_; // For physical restore, partitions that should be created with // is_restore = REPLICA_RESTORE_ARCHIVE_DATA + share::ObSimpleFrozenStatus restore_frozen_status_; }; struct ObCreateTenantEndArg : public ObDDLArg { -- GitLab