From 1c6016f1083166c7ae65e315e348eabce11688f5 Mon Sep 17 00:00:00 2001 From: tino247 Date: Mon, 1 Apr 2024 15:15:20 +0000 Subject: [PATCH] [UPGRADE] Forbid restoring tenant with unsupported data version --- src/rootserver/restore/ob_restore_util.cpp | 5 +++++ src/share/ob_upgrade_utils.cpp | 7 +++++++ src/share/ob_upgrade_utils.h | 1 + 3 files changed, 13 insertions(+) diff --git a/src/rootserver/restore/ob_restore_util.cpp b/src/rootserver/restore/ob_restore_util.cpp index e99ea9376e..e5958c8347 100644 --- a/src/rootserver/restore/ob_restore_util.cpp +++ b/src/rootserver/restore/ob_restore_util.cpp @@ -809,6 +809,11 @@ int ObRestoreUtil::check_backup_set_version_match_(share::ObBackupSetFileDesc &b ret = OB_OP_NOT_ALLOW; LOG_WARN("restore from version 4.0 is not allowd", K(ret), K(backup_file_desc.tenant_compatible_), K(data_version)); LOG_USER_ERROR(OB_OP_NOT_ALLOW, "restore from version 4.0 is"); + } else if (!ObUpgradeChecker::check_data_version_valid_for_backup(backup_file_desc.tenant_compatible_)) { + ret = OB_OP_NOT_ALLOW; + LOG_WARN("restore from backup with unsupported data version", + KR(ret), K(backup_file_desc.tenant_compatible_), K(data_version)); + LOG_USER_ERROR(OB_OP_NOT_ALLOW, "restore from backup with unsupported data version is"); } return ret; } diff --git a/src/share/ob_upgrade_utils.cpp b/src/share/ob_upgrade_utils.cpp index c8ffa3a172..4217c1c646 100755 --- a/src/share/ob_upgrade_utils.cpp +++ b/src/share/ob_upgrade_utils.cpp @@ -99,6 +99,13 @@ bool ObUpgradeChecker::check_data_version_exist( return bret; } +// TODO: should correspond to upgrade YML file. +// For now, just consider the valid upgrade path for 4.x . +bool ObUpgradeChecker::check_data_version_valid_for_backup(const uint64_t data_version) +{ + return DATA_VERSION_4_3_0_0 <= data_version; +} + //FIXME:(yanmu.ztl) cluster version should be discrete. bool ObUpgradeChecker::check_cluster_version_exist( const uint64_t version) diff --git a/src/share/ob_upgrade_utils.h b/src/share/ob_upgrade_utils.h index dab6a82df9..98c682da47 100755 --- a/src/share/ob_upgrade_utils.h +++ b/src/share/ob_upgrade_utils.h @@ -168,6 +168,7 @@ class ObUpgradeChecker { public: static bool check_data_version_exist(const uint64_t version); + static bool check_data_version_valid_for_backup(const uint64_t data_version); static bool check_cluster_version_exist(const uint64_t version); static int get_data_version_by_cluster_version( const uint64_t cluster_version,