From 007d00552bdcf0b20f04581261c6aa29f68fcbde Mon Sep 17 00:00:00 2001 From: gyt0221 <846772234@qq.com> Date: Wed, 3 Mar 2021 14:16:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=A1=E9=AA=8Cenable=5Fstream=5Freplication?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E4=B8=BAoff=E7=9A=84=E6=97=B6=E5=80=99=20?= =?UTF-8?q?=E5=8D=87=E7=BA=A7=E6=8A=9B=E5=87=BA=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/impl/upgrade/UpgradeConst.py | 6 +++++- script/impl/upgrade/UpgradeImpl.py | 18 ++++++++++++++++++ script/local/UpgradeUtility.py | 13 ++++++------- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/script/impl/upgrade/UpgradeConst.py b/script/impl/upgrade/UpgradeConst.py index 680063e..0280a19 100644 --- a/script/impl/upgrade/UpgradeConst.py +++ b/script/impl/upgrade/UpgradeConst.py @@ -124,7 +124,9 @@ BACKUP_DIR_LIST = ['global', 'pg_clog', 'pg_xlog', 'pg_multixact', BACKUP_DIR_LIST_BASE = ['global', 'pg_clog', 'pg_csnlog'] BACKUP_DIR_LIST_64BIT_XID = ['pg_multixact', 'pg_replslot', 'pg_notify', 'pg_subtrans', 'pg_twophase'] - +VALUE_OFF = ["off", "false", "0", "no"] +VALUE_ON = ["on", "true", "1", "yes"] +DN_GUC = ["upgrade_mode", "enable_stream_replication"] FIRST_GREY_UPGRADE_NUM = 92 UPGRADE_PRECOMMIT_NUM = 0.001 @@ -156,3 +158,5 @@ COMBIN_NUM = 30 ON_INPLACE_UPGRADE = "IsInplaceUpgrade" MAX_APP_SIZE = 2000 UPGRADE_VERSION_64bit_xid = 91.208 +ENABLE_STREAM_REPLICATION_VERSION = "92.149" +ENABLE_STREAM_REPLICATION_NAME = "enable_stream_replication" diff --git a/script/impl/upgrade/UpgradeImpl.py b/script/impl/upgrade/UpgradeImpl.py index 6be68e6..2533219 100644 --- a/script/impl/upgrade/UpgradeImpl.py +++ b/script/impl/upgrade/UpgradeImpl.py @@ -4484,6 +4484,11 @@ class UpgradeImpl: self.context.logger.log("Failed to check upgrade environment.", "constant") raise Exception(str(e)) + if not self.context.forceRollback: + if self.context.oldClusterNumber >= \ + Const.ENABLE_STREAM_REPLICATION_VERSION: + self.check_gucval_is_inval_given( + Const.ENABLE_STREAM_REPLICATION_NAME, Const.VALUE_ON) try: if self.context.action == Const.ACTION_INPLACE_UPGRADE: self.context.logger.log( @@ -4500,6 +4505,19 @@ class UpgradeImpl: self.context.logger.log( "Successfully checked upgrade environment.", "constant") + def check_gucval_is_inval_given(self, guc_name, val_list): + """ + Checks whether a given parameter is a given value list in a + given instance list. + """ + self.context.logger.debug("checks whether the parameter:{0} is " + "the value:{1}.".format(guc_name, val_list)) + guc_str = "{0}:{1}".format(guc_name, ",".join(val_list)) + self.checkParam(guc_str) + self.context.logger.debug("Success to check the parameter:{0} value " + "is in the value:{1}.".format(guc_name, + val_list)) + def checkDifferentVersion(self): """ if the cluster has only one version. no need to check diff --git a/script/local/UpgradeUtility.py b/script/local/UpgradeUtility.py index f8f242c..5d61025 100644 --- a/script/local/UpgradeUtility.py +++ b/script/local/UpgradeUtility.py @@ -1813,12 +1813,11 @@ def checkGucValue(): """ key = g_opts.gucStr.split(':')[0].strip() value = g_opts.gucStr.split(':')[1].strip() - if key == "upgrade_from": - instances = g_dbNode.cmagents - fileName = "cm_agent.conf" - elif key == "upgrade_mode": - #instances = g_dbNode.coordinators - #instances.extend(g_dbNode.datanodes) + if value in const.VALUE_OFF: + value = const.VALUE_OFF + if value in const.VALUE_ON: + value = const.VALUE_ON + if key in const.DN_GUC: instances = g_dbNode.datanodes fileName = "postgresql.conf" else: @@ -1849,7 +1848,7 @@ def checkGucValue(): realValue = realValue.split('#')[0].strip() g_logger.debug("[key:%s]: Realvalue %s, ExpectValue %s" % ( key, str(realValue), str(value))) - if str(value) != str(realValue): + if str(realValue) not in str(value): raise Exception( ErrorCode.GAUSS_521["GAUSS_52102"] % key + " Real value %s, expect value %s"