[CP] 升级脚本python3改造

This commit is contained in:
zhaoyiping0622
2024-07-02 11:41:44 +00:00
committed by ob-robot
parent 7efcb54714
commit 99432b79bd
12 changed files with 434 additions and 399 deletions

View File

@ -121,10 +121,10 @@
# results = cur.fetchall()
# if len(results) != 1:
# logging.exception('min_observer_version is not sync')
# raise e
# raise MyError('min_observer_version is not sync')
# elif len(results[0]) != 1:
# logging.exception('column cnt not match')
# raise e
# raise MyError('column cnt not match')
# else:
# min_cluster_version = get_version(results[0][0])
# return min_cluster_version
@ -197,17 +197,17 @@
# ori_value = 'True'
# elif len(result) != 1 or len(result[0]) != 1:
# logging.exception('result cnt not match')
# raise e
# raise MyError('result cnt not match')
# elif result[0][0].lower() in ["1", "true", "on", "yes", 't']:
# ori_value = 'True'
# elif result[0][0].lower() in ["0", "false", "off", "no", 'f']:
# ori_value = 'False'
# else:
# logging.exception("""result value is invalid, result:{0}""".format(result[0][0]))
# raise e
# raise MyError("""result value is invalid, result:{0}""".format(result[0][0]))
# return ori_value
#
## print version like "x.x.x.x"
## print(version like "x.x.x.x")
#def print_version(version):
# version = int(version)
# major = (version >> 32) & 0xffffffff
@ -222,7 +222,7 @@
#
# if len(versions) != 4:
# logging.exception("""version:{0} is invalid""".format(version_str))
# raise e
# raise MyError("""version:{0} is invalid""".format(version_str))
#
# major = int(versions[0])
# minor = int(versions[1])
@ -231,7 +231,7 @@
#
# if major > 0xffffffff or minor > 0xffff or major_patch > 0xff or minor_patch > 0xff:
# logging.exception("""version:{0} is invalid""".format(version_str))
# raise e
# raise MyError("""version:{0} is invalid""".format(version_str))
#
# version = (major << 32) | (minor << 16) | (major_patch << 8) | (minor_patch)
# return version
@ -285,7 +285,7 @@
# result = cur.fetchall()
# if len(result) != 1 or len(result[0]) != 1:
# logging.exception('result cnt not match')
# raise e
# raise MyError('result cnt not match')
# elif result[0][0] == 0:
# logging.info("""{0} is sync, value is {1}""".format(key, value))
# break
@ -295,7 +295,7 @@
# times -= 1
# if times == -1:
# logging.exception("""check {0}:{1} sync timeout""".format(key, value))
# raise e
# raise MyError("""check {0}:{1} sync timeout""".format(key, value))
# time.sleep(5)
#
# set_session_timeout(cur, 10)
@ -414,12 +414,12 @@
# if True == print_when_succ:
# logging.info('succeed to execute sql: %s, rowcount = %d', sql, rowcount)
# return rowcount
# except mysql.connector.Error, e:
# except mysql.connector.Error as e:
# logging.exception('mysql connector error, fail to execute sql: %s', sql)
# raise e
# except Exception, e:
# raise
# except Exception as e:
# logging.exception('normal error, fail to execute sql: %s', sql)
# raise e
# raise
# def exec_query(self, sql, print_when_succ = True):
# try:
# self.__cursor.execute(sql)
@ -428,12 +428,12 @@
# if True == print_when_succ:
# logging.info('succeed to execute query: %s, rowcount = %d', sql, rowcount)
# return (self.__cursor.description, results)
# except mysql.connector.Error, e:
# except mysql.connector.Error as e:
# logging.exception('mysql connector error, fail to execute sql: %s', sql)
# raise e
# except Exception, e:
# raise
# except Exception as e:
# logging.exception('normal error, fail to execute sql: %s', sql)
# raise e
# raise
#
#class DDLCursor:
# _cursor = None
@ -444,9 +444,9 @@
# # 这里检查是不是ddl,不是ddl就抛错
# check_is_ddl_sql(sql)
# return self._cursor.exec_sql(sql, print_when_succ)
# except Exception, e:
# except Exception as e:
# logging.exception('fail to execute ddl: %s', sql)
# raise e
# raise
#
#class QueryCursor:
# _cursor = None
@ -457,9 +457,9 @@
# # 这里检查是不是query,不是query就抛错
# check_is_query_sql(sql)
# return self._cursor.exec_query(sql, print_when_succ)
# except Exception, e:
# except Exception as e:
# logging.exception('fail to execute dml query: %s', sql)
# raise e
# raise
#
#class DMLCursor(QueryCursor):
# def exec_update(self, sql, print_when_succ = True):
@ -467,9 +467,9 @@
# # 这里检查是不是update,不是update就抛错
# check_is_update_sql(sql)
# return self._cursor.exec_sql(sql, print_when_succ)
# except Exception, e:
# except Exception as e:
# logging.exception('fail to execute dml update: %s', sql)
# raise e
# raise
#
#class BaseDDLAction():
# __ddl_cursor = None
@ -579,9 +579,9 @@
# for r in results:
# tenant_id_list.append(r[0])
# return tenant_id_list
# except Exception, e:
# except Exception as e:
# logging.exception('fail to fetch distinct tenant ids')
# raise e
# raise
#
####====XXXX======######==== I am a splitter ====######======XXXX====####
#filename:config.py
@ -706,9 +706,9 @@
# actions.refresh_commit_sql_list()
# logging.info('================succeed to run post check action ===============')
#
# except Exception, e:
# except Exception as e:
# logging.exception('run error')
# raise e
# raise
# finally:
# # 打印统计信息
# print_stats()
@ -716,12 +716,12 @@
# # actions.dump_rollback_sql_to_file(upgrade_params.rollback_sql_filename)
# cur.close()
# conn.close()
# except mysql.connector.Error, e:
# except mysql.connector.Error as e:
# logging.exception('connection error')
# raise e
# except Exception, e:
# raise
# except Exception as e:
# logging.exception('normal error')
# raise e
# raise
#
#def do_upgrade_by_argv(argv):
# upgrade_params = UpgradeParams()
@ -755,14 +755,14 @@
# logging.info('parameters from cmd: host=\"%s\", port=%s, user=\"%s\", password=\"%s\", timeout=\"%s\", module=\"%s\", log-file=\"%s\"',\
# host, port, user, password.replace('"', '\\"'), timeout, module_set, log_filename)
# do_upgrade(host, port, user, password, timeout, module_set, upgrade_params)
# except mysql.connector.Error, e:
# except mysql.connector.Error as e:
# logging.exception('mysql connctor error')
# logging.exception('run error, maybe you can reference ' + upgrade_params.rollback_sql_filename + ' to rollback it')
# raise e
# except Exception, e:
# raise
# except Exception as e:
# logging.exception('normal error')
# logging.exception('run error, maybe you can reference ' + upgrade_params.rollback_sql_filename + ' to rollback it')
# raise e
# raise
#
#
#
@ -866,9 +866,9 @@
# upgrade_health_checker.do_check(my_host, my_port, my_user, my_passwd, upgrade_params, timeout, True) # need_check_major_status = True
# logging.info('================succeed to run health check action ===============')
#
# except Exception, e:
# except Exception as e:
# logging.exception('run error')
# raise e
# raise
# finally:
# # 打印统计信息
# print_stats()
@ -876,12 +876,12 @@
# # actions.dump_rollback_sql_to_file(upgrade_params.rollback_sql_filename)
# cur.close()
# conn.close()
# except mysql.connector.Error, e:
# except mysql.connector.Error as e:
# logging.exception('connection error')
# raise e
# except Exception, e:
# raise
# except Exception as e:
# logging.exception('normal error')
# raise e
# raise
#
#def do_upgrade_by_argv(argv):
# upgrade_params = UpgradeParams()
@ -915,14 +915,14 @@
# logging.info('parameters from cmd: host=\"%s\", port=%s, user=\"%s\", password=\"%s\", timeout=\"%s\", module=\"%s\", log-file=\"%s\"',\
# host, port, user, password.replace('"', '\\"'), timeout, module_set, log_filename)
# do_upgrade(host, port, user, password, timeout, module_set, upgrade_params)
# except mysql.connector.Error, e:
# except mysql.connector.Error as e:
# logging.exception('mysql connctor error')
# logging.exception('run error, maybe you can reference ' + upgrade_params.rollback_sql_filename + ' to rollback it')
# raise e
# except Exception, e:
# raise
# except Exception as e:
# logging.exception('normal error')
# logging.exception('run error, maybe you can reference ' + upgrade_params.rollback_sql_filename + ' to rollback it')
# raise e
# raise
#
#
#
@ -1162,15 +1162,15 @@
# if 'help' == opt.get_long_name():
# if 'upgrade_pre' == filename:
# global pre_help_str
# print pre_help_str
# print(pre_help_str)
# elif 'upgrade_post' == filename:
# global post_help_str
# print post_help_str
# print(post_help_str)
# else:
# raise MyError('not supported filename:{0} for help option'.format(filename))
# elif 'version' == opt.get_long_name():
# global version_str
# print version_str
# print(version_str)
#
#def deal_with_local_opts(filename):
# global g_opts
@ -1395,6 +1395,7 @@
##!/usr/bin/env python
## -*- coding: utf-8 -*-
#
#from my_error import MyError
#import logging
#import time
#from actions import Cursor
@ -1431,9 +1432,9 @@
# info_cnt = result[0][0]
# if info_cnt > 0:
# actions.set_parameter(cur, "syslog_level", "WDIAG")
# except Exception, e:
# except Exception as e:
# logging.warn("upgrade syslog level failed!")
# raise e
# raise
#####========******####========= actions end =========####******========####
#
#def query(cur, sql):
@ -1469,7 +1470,7 @@
# results = query(cur, sql)
# if len(results) < 1 or len(results[0]) < 1:
# logging.warn("row/column cnt not match")
# raise e
# raise MyError("row/column cnt not match")
# elif results[0][0] <= 0:
# # __all_virtual_core_table doesn't exist, this cluster is upgraded from 4.0.0.0
# across_version = True
@ -1478,14 +1479,14 @@
# tenant_ids = get_tenant_ids(cur)
# if len(tenant_ids) <= 0:
# logging.warn("tenant_ids count is unexpected")
# raise e
# raise MyError("tenant_ids count is unexpected")
# tenant_count = len(tenant_ids)
#
# sql = "select count(*) from __all_virtual_core_table where column_name in ('target_data_version', 'current_data_version') and column_value = {0}".format(int_current_data_version)
# results = query(cur, sql)
# if len(results) != 1 or len(results[0]) != 1:
# logging.warn('result cnt not match')
# raise e
# raise MyError('result cnt not match')
# elif 2 * tenant_count != results[0][0]:
# logging.info('target_data_version/current_data_version not match with {0}, tenant_cnt:{1}, result_cnt:{2}'.format(current_data_version, tenant_count, results[0][0]))
# across_version = True
@ -1499,7 +1500,7 @@
# results = query(cur, sql)
# if len(results) < 1 or len(results[0]) < 1:
# logging.warn("row/column cnt not match")
# raise e
# raise MyError("row/column cnt not match")
# elif results[0][0] == 0:
# logging.info("compatible are all matched")
# else:
@ -1518,16 +1519,16 @@
# max_job_id = 0
# elif (len(results) != 1 or len(results[0]) != 1):
# logging.warn("row cnt not match")
# raise e
# raise MyError("row cnt not match")
# else:
# max_job_id = results[0][0]
#
# logging.info("get max_used_job_id:{0}".format(max_job_id))
#
# return max_job_id
# except Exception, e:
# except Exception as e:
# logging.warn("failed to get max_used_job_id")
# raise e
# raise
#
#def check_can_run_upgrade_job(cur, job_name):
# try:
@ -1541,10 +1542,10 @@
# logging.info("upgrade job not created yet, should run upgrade job")
# elif (len(results) != 1 or len(results[0]) != 1):
# logging.warn("row cnt not match")
# raise e
# raise MyError("row cnt not match")
# elif ("INPROGRESS" == results[0][0]):
# logging.warn("upgrade job still running, should wait")
# raise e
# raise MyError("upgrade job still running, should wait")
# elif ("SUCCESS" == results[0][0]):
# bret = True
# logging.info("maybe upgrade job remained, can run again")
@ -1553,12 +1554,12 @@
# logging.info("execute upgrade job failed, should run again")
# else:
# logging.warn("invalid job status: {0}".format(results[0][0]))
# raise e
# raise MyError("invalid job status: {0}".format(results[0][0]))
#
# return bret
# except Exception, e:
# except Exception as e:
# logging.warn("failed to check if upgrade job can run")
# raise e
# raise
#
#def check_upgrade_job_result(cur, job_name, timeout, max_used_job_id):
# try:
@ -1575,7 +1576,7 @@
# logging.info("upgrade job not created yet")
# elif (len(results) != 1 or len(results[0]) != 4):
# logging.warn("row cnt not match")
# raise e
# raise MyError("row cnt not match")
# elif ("INPROGRESS" == results[0][0]):
# logging.info("upgrade job is still running")
# # check if rs change
@ -1587,39 +1588,39 @@
# results = query(cur, sql)
# if (len(results) != 1 or len(results[0]) != 1):
# logging.warn("row/column cnt not match")
# raise e
# raise MyError("row/column cnt not match")
# elif results[0][0] == 1:
# sql = """select count(*) from oceanbase.__all_rootservice_event_history where gmt_create > '{0}' and event = 'full_rootservice'""".format(gmt_create)
# results = query(cur, sql)
# if (len(results) != 1 or len(results[0]) != 1):
# logging.warn("row/column cnt not match")
# raise e
# raise MyError("row/column cnt not match")
# elif results[0][0] > 0:
# logging.warn("rs changed, should check if upgrade job is still running")
# raise e
# raise MyError("rs changed, should check if upgrade job is still running")
# else:
# logging.info("rs[{0}:{1}] still exist, keep waiting".format(ip, port))
# else:
# logging.warn("rs changed or not exist, should check if upgrade job is still running")
# raise e
# raise MyError("rs changed or not exist, should check if upgrade job is still running")
# elif ("SUCCESS" == results[0][0]):
# logging.info("execute upgrade job successfully")
# break;
# elif ("FAILED" == results[0][0]):
# logging.warn("execute upgrade job failed")
# raise e
# raise MyError("execute upgrade job failed")
# else:
# logging.warn("invalid job status: {0}".format(results[0][0]))
# raise e
# raise MyError("invalid job status: {0}".format(results[0][0]))
#
# times = times - 1
# if times == -1:
# logging.warn("""check {0} job timeout""".format(job_name))
# raise e
# raise MyError("""check {0} job timeout""".format(job_name))
# time.sleep(10)
# except Exception, e:
# except Exception as e:
# logging.warn("failed to check upgrade job result")
# raise e
# raise
#
#def run_upgrade_job(conn, cur, job_name, timeout):
# try:
@ -1646,15 +1647,16 @@
# # reset enable_ddl
# if ori_enable_ddl == 0:
# actions.set_parameter(cur, 'enable_ddl', 'False', timeout)
# except Exception, e:
# except Exception as e:
# logging.warn("run upgrade job failed, :{0}".format(job_name))
# raise e
# raise
# logging.info("run upgrade job success, job_name:{0}".format(job_name))
####====XXXX======######==== I am a splitter ====######======XXXX====####
#filename:upgrade_checker.py
##!/usr/bin/env python
## -*- coding: utf-8 -*-
#
#from __future__ import print_function
#import sys
#import os
#import mysql.connector
@ -1664,6 +1666,10 @@
#import time
#import re
#
#if sys.version_info.major == 3:
# def cmp(a, b):
# return (a > b) - (a < b)
#
#class UpgradeParams:
# log_filename = 'upgrade_checker.log'
# old_version = '4.0.0.0'
@ -1691,12 +1697,12 @@
# if True == print_when_succ:
# logging.info('succeed to execute sql: %s, rowcount = %d', sql, rowcount)
# return rowcount
# except mysql.connector.Error, e:
# except mysql.connector.Error as e:
# logging.exception('mysql connector error, fail to execute sql: %s', sql)
# raise e
# except Exception, e:
# raise
# except Exception as e:
# logging.exception('normal error, fail to execute sql: %s', sql)
# raise e
# raise
# def exec_query(self, sql, print_when_succ = True):
# try:
# self.__cursor.execute(sql)
@ -1705,12 +1711,12 @@
# if True == print_when_succ:
# logging.info('succeed to execute query: %s, rowcount = %d', sql, rowcount)
# return (self.__cursor.description, results)
# except mysql.connector.Error, e:
# except mysql.connector.Error as e:
# logging.exception('mysql connector error, fail to execute sql: %s', sql)
# raise e
# except Exception, e:
# raise
# except Exception as e:
# logging.exception('normal error, fail to execute sql: %s', sql)
# raise e
# raise
#
#def set_parameter(cur, parameter, value):
# sql = """alter system set {0} = '{1}'""".format(parameter, value)
@ -1728,7 +1734,7 @@
# result = cur.fetchall()
# if len(result) != 1 or len(result[0]) != 1:
# logging.exception('result cnt not match')
# raise e
# raise MyError('result cnt not match')
# elif result[0][0] == 0:
# logging.info("""{0} is sync, value is {1}""".format(key, value))
# break
@ -1738,7 +1744,7 @@
# times -= 1
# if times == 0:
# logging.exception("""check {0}:{1} sync timeout""".format(key, value))
# raise e
# raise MyError("""check {0}:{1} sync timeout""".format(key, value))
# time.sleep(5)
#
##### --------------start : opt.py --------------
@ -1875,10 +1881,10 @@
#def deal_with_local_opt(opt):
# if 'help' == opt.get_long_name():
# global help_str
# print help_str
# print(help_str)
# elif 'version' == opt.get_long_name():
# global version_str
# print version_str
# print(version_str)
#
#def deal_with_local_opts():
# global g_opts
@ -1961,7 +1967,7 @@
#
# if len(versions) != 4:
# logging.exception("""version:{0} is invalid""".format(version_str))
# raise e
# raise MyError("""version:{0} is invalid""".format(version_str))
#
# major = int(versions[0])
# minor = int(versions[1])
@ -1970,7 +1976,7 @@
#
# if major > 0xffffffff or minor > 0xffff or major_patch > 0xff or minor_patch > 0xff:
# logging.exception("""version:{0} is invalid""".format(version_str))
# raise e
# raise MyError("""version:{0} is invalid""".format(version_str))
#
# version = (major << 32) | (minor << 16) | (major_patch << 8) | (minor_patch)
# return version
@ -1982,7 +1988,7 @@
# if len(results) != 1:
# fail_list.append('min_observer_version is not sync')
# elif cmp(results[0][0], upgrade_params.old_version) < 0 :
# fail_list.append('old observer version is expected equal or higher then: {0}, actual version:{1}'.format(upgrade_params.old_version, results[0][0]))
# fail_list.append('old observer version is expected equal or higher than: {0}, actual version:{1}'.format(upgrade_params.old_version, results[0][0]))
# logging.info('check observer version success, version = {0}'.format(results[0][0]))
#
#def check_data_version(query_cur):
@ -2423,18 +2429,18 @@
# # all check func should execute before check_fail_list
# check_fail_list()
# modify_server_permanent_offline_time(cur)
# except Exception, e:
# except Exception as e:
# logging.exception('run error')
# raise e
# raise
# finally:
# cur.close()
# conn.close()
# except mysql.connector.Error, e:
# except mysql.connector.Error as e:
# logging.exception('connection error')
# raise e
# except Exception, e:
# raise
# except Exception as e:
# logging.exception('normal error')
# raise e
# raise
#
#if __name__ == '__main__':
# upgrade_params = UpgradeParams()
@ -2457,17 +2463,18 @@
# logging.info('parameters from cmd: host=\"%s\", port=%s, user=\"%s\", password=\"%s\", timeout=\"%s\", log-file=\"%s\"',\
# host, port, user, password.replace('"', '\\"'), timeout, log_filename)
# do_check(host, port, user, password, timeout, upgrade_params)
# except mysql.connector.Error, e:
# except mysql.connector.Error as e:
# logging.exception('mysql connctor error')
# raise e
# except Exception, e:
# raise
# except Exception as e:
# logging.exception('normal error')
# raise e
# raise
####====XXXX======######==== I am a splitter ====######======XXXX====####
#filename:upgrade_health_checker.py
##!/usr/bin/env python
## -*- coding: utf-8 -*-
#
#from __future__ import print_function
#import sys
#import os
#import time
@ -2504,12 +2511,12 @@
# if True == print_when_succ:
# logging.info('succeed to execute sql: %s, rowcount = %d', sql, rowcount)
# return rowcount
# except mysql.connector.Error, e:
# except mysql.connector.Error as e:
# logging.exception('mysql connector error, fail to execute sql: %s', sql)
# raise e
# except Exception, e:
# raise
# except Exception as e:
# logging.exception('normal error, fail to execute sql: %s', sql)
# raise e
# raise
# def exec_query(self, sql, print_when_succ = True):
# try:
# self.__cursor.execute(sql)
@ -2518,12 +2525,12 @@
# if True == print_when_succ:
# logging.info('succeed to execute query: %s, rowcount = %d', sql, rowcount)
# return (self.__cursor.description, results)
# except mysql.connector.Error, e:
# except mysql.connector.Error as e:
# logging.exception('mysql connector error, fail to execute sql: %s', sql)
# raise e
# except Exception, e:
# raise
# except Exception as e:
# logging.exception('normal error, fail to execute sql: %s', sql)
# raise e
# raise
##### ---------------end----------------------
#
##### --------------start : opt.py --------------
@ -2663,10 +2670,10 @@
#def deal_with_local_opt(opt):
# if 'help' == opt.get_long_name():
# global help_str
# print help_str
# print(help_str)
# elif 'version' == opt.get_long_name():
# global version_str
# print version_str
# print(version_str)
#
#def deal_with_local_opts():
# global g_opts
@ -2767,9 +2774,9 @@
# for r in results:
# tenant_id_list.append(r[0])
# return tenant_id_list
# except Exception, e:
# except Exception as e:
# logging.exception('fail to fetch distinct tenant ids')
# raise e
# raise
#
#def set_default_timeout_by_tenant(query_cur, timeout, timeout_per_tenant, min_timeout):
# if timeout > 0:
@ -2853,7 +2860,7 @@
# times -= 1
# if times == -1:
# logging.warn("""check {0} job timeout""".format(job_name))
# raise e
# raise MyError("""check {0} job timeout""".format(job_name))
# time.sleep(10)
#
## 开始健康检查
@ -2876,18 +2883,18 @@
# check_server_version_by_zone(query_cur, zone)
# if True == need_check_major_status:
# check_major_merge(query_cur, timeout)
# except Exception, e:
# except Exception as e:
# logging.exception('run error')
# raise e
# raise
# finally:
# cur.close()
# conn.close()
# except mysql.connector.Error, e:
# except mysql.connector.Error as e:
# logging.exception('connection error')
# raise e
# except Exception, e:
# raise
# except Exception as e:
# logging.exception('normal error')
# raise e
# raise
#
#if __name__ == '__main__':
# upgrade_params = UpgradeParams()
@ -2911,18 +2918,19 @@
# logging.info('parameters from cmd: host=\"%s\", port=%s, user=\"%s\", password=\"%s\", log-file=\"%s\", timeout=%s, zone=\"%s\"', \
# host, port, user, password.replace('"', '\\"'), log_filename, timeout, zone)
# do_check(host, port, user, password, upgrade_params, timeout, False, zone) # need_check_major_status = False
# except mysql.connector.Error, e:
# except mysql.connector.Error as e:
# logging.exception('mysql connctor error')
# raise e
# except Exception, e:
# raise
# except Exception as e:
# logging.exception('normal error')
# raise e
# raise
#
####====XXXX======######==== I am a splitter ====######======XXXX====####
#filename:upgrade_post_checker.py
##!/usr/bin/env python
## -*- coding: utf-8 -*-
#
#from my_error import MyError
#import sys
#import os
#import time
@ -2946,7 +2954,7 @@
# (desc, results) = query_cur.exec_query(sql)
# if len(results) == 0:
# logging.warn('result cnt not match')
# raise e
# raise MyError('result cnt not match')
# tenant_count = len(results)
# tenant_ids_str = ''
# for index, row in enumerate(results):
@ -2957,7 +2965,7 @@
# (desc, results) = query_cur.exec_query(sql)
# if len(results) != 1 or len(results[0]) != 1:
# logging.warn('result cnt not match')
# raise e
# raise MyError('result cnt not match')
# server_count = results[0][0]
#
# # check compatible sync
@ -2977,7 +2985,7 @@
# result = cur.fetchall()
# if len(result) != 1 or len(result[0]) != 1:
# logging.exception('result cnt not match')
# raise e
# raise MyError('result cnt not match')
# elif result[0][0] == parameter_count:
# logging.info("""'compatible' is sync, value is {0}""".format(current_data_version))
# break
@ -2987,7 +2995,7 @@
# times -= 1
# if times == -1:
# logging.exception("""check compatible:{0} sync timeout""".format(current_data_version))
# raise e
# raise MyError("""check compatible:{0} sync timeout""".format(current_data_version))
# time.sleep(5)
#
# actions.set_session_timeout(cur, 10)
@ -2998,10 +3006,10 @@
# (desc, results) = query_cur.exec_query(sql)
# if len(results) != 1 or len(results[0]) != 1:
# logging.warn('result cnt not match')
# raise e
# raise MyError('result cnt not match')
# elif 2 * tenant_count != results[0][0]:
# logging.warn('target_data_version/current_data_version not match with {0}, tenant_cnt:{1}, result_cnt:{2}'.format(current_data_version, tenant_count, results[0][0]))
# raise e
# raise MyError('target_data_version/current_data_version not match with {0}, tenant_cnt:{1}, result_cnt:{2}'.format(current_data_version, tenant_count, results[0][0]))
# else:
# logging.info("all tenant's target_data_version/current_data_version are match with {0}".format(current_data_version))
#
@ -3021,7 +3029,7 @@
#
# if times == -1:
# logging.warn('check root inspection failed!')
# raise e
# raise MyError('check root inspection failed!')
# logging.info('check root inspection success')
#
## 4 开ddl
@ -3053,13 +3061,14 @@
# enable_rebalance(cur, timeout)
# enable_rereplication(cur, timeout)
# enable_major_freeze(cur, timeout)
# except Exception, e:
# except Exception as e:
# logging.exception('run error')
# raise e
# raise
####====XXXX======######==== I am a splitter ====######======XXXX====####
#sub file module end
from __future__ import print_function, absolute_import
import os
import sys
import datetime
@ -3115,7 +3124,7 @@ def split_py_files(sub_files_dir):
if i >= cur_file_lines_count:
raise SplitError('invalid line index:' + str(i) + ', lines_count:' + str(cur_file_lines_count))
elif (sub_file_module_end_line + char_enter) == cur_file_lines[i]:
print 'succeed to split all sub py files'
print('succeed to split all sub py files')
break
else:
mark_idx = cur_file_lines[i].find(sub_filename_line_prefix)
@ -3137,5 +3146,7 @@ if __name__ == '__main__':
sub_files_dir = cur_file_short_name + sub_files_dir_suffix
sub_files_short_dir = cur_file_real_name + sub_files_dir_suffix
split_py_files(sub_files_dir)
exec('from ' + sub_files_short_dir + '.do_upgrade_post import do_upgrade_by_argv')
sub_files_absolute_dir = os.path.abspath(sub_files_dir)
sys.path.append(sub_files_absolute_dir)
from do_upgrade_post import do_upgrade_by_argv
do_upgrade_by_argv(sys.argv[1:])