[CP] 升级脚本python3改造
This commit is contained in:
@ -113,10 +113,10 @@ def get_min_cluster_version(cur):
|
|||||||
results = cur.fetchall()
|
results = cur.fetchall()
|
||||||
if len(results) != 1:
|
if len(results) != 1:
|
||||||
logging.exception('min_observer_version is not sync')
|
logging.exception('min_observer_version is not sync')
|
||||||
raise e
|
raise MyError('min_observer_version is not sync')
|
||||||
elif len(results[0]) != 1:
|
elif len(results[0]) != 1:
|
||||||
logging.exception('column cnt not match')
|
logging.exception('column cnt not match')
|
||||||
raise e
|
raise MyError('column cnt not match')
|
||||||
else:
|
else:
|
||||||
min_cluster_version = get_version(results[0][0])
|
min_cluster_version = get_version(results[0][0])
|
||||||
return min_cluster_version
|
return min_cluster_version
|
||||||
@ -189,17 +189,17 @@ def fetch_ori_enable_ddl(cur):
|
|||||||
ori_value = 'True'
|
ori_value = 'True'
|
||||||
elif len(result) != 1 or len(result[0]) != 1:
|
elif len(result) != 1 or len(result[0]) != 1:
|
||||||
logging.exception('result cnt not match')
|
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']:
|
elif result[0][0].lower() in ["1", "true", "on", "yes", 't']:
|
||||||
ori_value = 'True'
|
ori_value = 'True'
|
||||||
elif result[0][0].lower() in ["0", "false", "off", "no", 'f']:
|
elif result[0][0].lower() in ["0", "false", "off", "no", 'f']:
|
||||||
ori_value = 'False'
|
ori_value = 'False'
|
||||||
else:
|
else:
|
||||||
logging.exception("""result value is invalid, result:{0}""".format(result[0][0]))
|
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
|
return ori_value
|
||||||
|
|
||||||
# print version like "x.x.x.x"
|
# print(version like "x.x.x.x")
|
||||||
def print_version(version):
|
def print_version(version):
|
||||||
version = int(version)
|
version = int(version)
|
||||||
major = (version >> 32) & 0xffffffff
|
major = (version >> 32) & 0xffffffff
|
||||||
@ -214,7 +214,7 @@ def get_version(version_str):
|
|||||||
|
|
||||||
if len(versions) != 4:
|
if len(versions) != 4:
|
||||||
logging.exception("""version:{0} is invalid""".format(version_str))
|
logging.exception("""version:{0} is invalid""".format(version_str))
|
||||||
raise e
|
raise MyError("""version:{0} is invalid""".format(version_str))
|
||||||
|
|
||||||
major = int(versions[0])
|
major = int(versions[0])
|
||||||
minor = int(versions[1])
|
minor = int(versions[1])
|
||||||
@ -223,7 +223,7 @@ def get_version(version_str):
|
|||||||
|
|
||||||
if major > 0xffffffff or minor > 0xffff or major_patch > 0xff or minor_patch > 0xff:
|
if major > 0xffffffff or minor > 0xffff or major_patch > 0xff or minor_patch > 0xff:
|
||||||
logging.exception("""version:{0} is invalid""".format(version_str))
|
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)
|
version = (major << 32) | (minor << 16) | (major_patch << 8) | (minor_patch)
|
||||||
return version
|
return version
|
||||||
@ -277,7 +277,7 @@ def wait_parameter_sync(cur, is_tenant_config, key, value, timeout, only_sys_ten
|
|||||||
result = cur.fetchall()
|
result = cur.fetchall()
|
||||||
if len(result) != 1 or len(result[0]) != 1:
|
if len(result) != 1 or len(result[0]) != 1:
|
||||||
logging.exception('result cnt not match')
|
logging.exception('result cnt not match')
|
||||||
raise e
|
raise MyError('result cnt not match')
|
||||||
elif result[0][0] == 0:
|
elif result[0][0] == 0:
|
||||||
logging.info("""{0} is sync, value is {1}""".format(key, value))
|
logging.info("""{0} is sync, value is {1}""".format(key, value))
|
||||||
break
|
break
|
||||||
@ -287,7 +287,7 @@ def wait_parameter_sync(cur, is_tenant_config, key, value, timeout, only_sys_ten
|
|||||||
times -= 1
|
times -= 1
|
||||||
if times == -1:
|
if times == -1:
|
||||||
logging.exception("""check {0}:{1} sync timeout""".format(key, value))
|
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)
|
time.sleep(5)
|
||||||
|
|
||||||
set_session_timeout(cur, 10)
|
set_session_timeout(cur, 10)
|
||||||
@ -406,12 +406,12 @@ class Cursor:
|
|||||||
if True == print_when_succ:
|
if True == print_when_succ:
|
||||||
logging.info('succeed to execute sql: %s, rowcount = %d', sql, rowcount)
|
logging.info('succeed to execute sql: %s, rowcount = %d', sql, rowcount)
|
||||||
return 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)
|
logging.exception('mysql connector error, fail to execute sql: %s', sql)
|
||||||
raise e
|
raise
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.exception('normal error, fail to execute sql: %s', sql)
|
logging.exception('normal error, fail to execute sql: %s', sql)
|
||||||
raise e
|
raise
|
||||||
def exec_query(self, sql, print_when_succ = True):
|
def exec_query(self, sql, print_when_succ = True):
|
||||||
try:
|
try:
|
||||||
self.__cursor.execute(sql)
|
self.__cursor.execute(sql)
|
||||||
@ -420,12 +420,12 @@ class Cursor:
|
|||||||
if True == print_when_succ:
|
if True == print_when_succ:
|
||||||
logging.info('succeed to execute query: %s, rowcount = %d', sql, rowcount)
|
logging.info('succeed to execute query: %s, rowcount = %d', sql, rowcount)
|
||||||
return (self.__cursor.description, results)
|
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)
|
logging.exception('mysql connector error, fail to execute sql: %s', sql)
|
||||||
raise e
|
raise
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.exception('normal error, fail to execute sql: %s', sql)
|
logging.exception('normal error, fail to execute sql: %s', sql)
|
||||||
raise e
|
raise
|
||||||
|
|
||||||
class DDLCursor:
|
class DDLCursor:
|
||||||
_cursor = None
|
_cursor = None
|
||||||
@ -436,9 +436,9 @@ class DDLCursor:
|
|||||||
# 这里检查是不是ddl,不是ddl就抛错
|
# 这里检查是不是ddl,不是ddl就抛错
|
||||||
check_is_ddl_sql(sql)
|
check_is_ddl_sql(sql)
|
||||||
return self._cursor.exec_sql(sql, print_when_succ)
|
return self._cursor.exec_sql(sql, print_when_succ)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.exception('fail to execute ddl: %s', sql)
|
logging.exception('fail to execute ddl: %s', sql)
|
||||||
raise e
|
raise
|
||||||
|
|
||||||
class QueryCursor:
|
class QueryCursor:
|
||||||
_cursor = None
|
_cursor = None
|
||||||
@ -449,9 +449,9 @@ class QueryCursor:
|
|||||||
# 这里检查是不是query,不是query就抛错
|
# 这里检查是不是query,不是query就抛错
|
||||||
check_is_query_sql(sql)
|
check_is_query_sql(sql)
|
||||||
return self._cursor.exec_query(sql, print_when_succ)
|
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)
|
logging.exception('fail to execute dml query: %s', sql)
|
||||||
raise e
|
raise
|
||||||
|
|
||||||
class DMLCursor(QueryCursor):
|
class DMLCursor(QueryCursor):
|
||||||
def exec_update(self, sql, print_when_succ = True):
|
def exec_update(self, sql, print_when_succ = True):
|
||||||
@ -459,9 +459,9 @@ class DMLCursor(QueryCursor):
|
|||||||
# 这里检查是不是update,不是update就抛错
|
# 这里检查是不是update,不是update就抛错
|
||||||
check_is_update_sql(sql)
|
check_is_update_sql(sql)
|
||||||
return self._cursor.exec_sql(sql, print_when_succ)
|
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)
|
logging.exception('fail to execute dml update: %s', sql)
|
||||||
raise e
|
raise
|
||||||
|
|
||||||
class BaseDDLAction():
|
class BaseDDLAction():
|
||||||
__ddl_cursor = None
|
__ddl_cursor = None
|
||||||
@ -571,7 +571,7 @@ def fetch_tenant_ids(query_cur):
|
|||||||
for r in results:
|
for r in results:
|
||||||
tenant_id_list.append(r[0])
|
tenant_id_list.append(r[0])
|
||||||
return tenant_id_list
|
return tenant_id_list
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.exception('fail to fetch distinct tenant ids')
|
logging.exception('fail to fetch distinct tenant ids')
|
||||||
raise e
|
raise
|
||||||
|
|
||||||
|
@ -106,9 +106,9 @@ def do_upgrade(my_host, my_port, my_user, my_passwd, timeout, my_module_set, upg
|
|||||||
actions.refresh_commit_sql_list()
|
actions.refresh_commit_sql_list()
|
||||||
logging.info('================succeed to run post check action ===============')
|
logging.info('================succeed to run post check action ===============')
|
||||||
|
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.exception('run error')
|
logging.exception('run error')
|
||||||
raise e
|
raise
|
||||||
finally:
|
finally:
|
||||||
# 打印统计信息
|
# 打印统计信息
|
||||||
print_stats()
|
print_stats()
|
||||||
@ -116,12 +116,12 @@ def do_upgrade(my_host, my_port, my_user, my_passwd, timeout, my_module_set, upg
|
|||||||
# actions.dump_rollback_sql_to_file(upgrade_params.rollback_sql_filename)
|
# actions.dump_rollback_sql_to_file(upgrade_params.rollback_sql_filename)
|
||||||
cur.close()
|
cur.close()
|
||||||
conn.close()
|
conn.close()
|
||||||
except mysql.connector.Error, e:
|
except mysql.connector.Error as e:
|
||||||
logging.exception('connection error')
|
logging.exception('connection error')
|
||||||
raise e
|
raise
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.exception('normal error')
|
logging.exception('normal error')
|
||||||
raise e
|
raise
|
||||||
|
|
||||||
def do_upgrade_by_argv(argv):
|
def do_upgrade_by_argv(argv):
|
||||||
upgrade_params = UpgradeParams()
|
upgrade_params = UpgradeParams()
|
||||||
@ -155,14 +155,14 @@ def do_upgrade_by_argv(argv):
|
|||||||
logging.info('parameters from cmd: host=\"%s\", port=%s, user=\"%s\", password=\"%s\", timeout=\"%s\", module=\"%s\", log-file=\"%s\"',\
|
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)
|
host, port, user, password.replace('"', '\\"'), timeout, module_set, log_filename)
|
||||||
do_upgrade(host, port, user, password, timeout, module_set, upgrade_params)
|
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('mysql connctor error')
|
||||||
logging.exception('run error, maybe you can reference ' + upgrade_params.rollback_sql_filename + ' to rollback it')
|
logging.exception('run error, maybe you can reference ' + upgrade_params.rollback_sql_filename + ' to rollback it')
|
||||||
raise e
|
raise
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.exception('normal error')
|
logging.exception('normal error')
|
||||||
logging.exception('run error, maybe you can reference ' + upgrade_params.rollback_sql_filename + ' to rollback it')
|
logging.exception('run error, maybe you can reference ' + upgrade_params.rollback_sql_filename + ' to rollback it')
|
||||||
raise e
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -96,9 +96,9 @@ def do_upgrade(my_host, my_port, my_user, my_passwd, timeout, my_module_set, upg
|
|||||||
upgrade_health_checker.do_check(my_host, my_port, my_user, my_passwd, upgrade_params, timeout, True) # need_check_major_status = True
|
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 ===============')
|
logging.info('================succeed to run health check action ===============')
|
||||||
|
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.exception('run error')
|
logging.exception('run error')
|
||||||
raise e
|
raise
|
||||||
finally:
|
finally:
|
||||||
# 打印统计信息
|
# 打印统计信息
|
||||||
print_stats()
|
print_stats()
|
||||||
@ -106,12 +106,12 @@ def do_upgrade(my_host, my_port, my_user, my_passwd, timeout, my_module_set, upg
|
|||||||
# actions.dump_rollback_sql_to_file(upgrade_params.rollback_sql_filename)
|
# actions.dump_rollback_sql_to_file(upgrade_params.rollback_sql_filename)
|
||||||
cur.close()
|
cur.close()
|
||||||
conn.close()
|
conn.close()
|
||||||
except mysql.connector.Error, e:
|
except mysql.connector.Error as e:
|
||||||
logging.exception('connection error')
|
logging.exception('connection error')
|
||||||
raise e
|
raise
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.exception('normal error')
|
logging.exception('normal error')
|
||||||
raise e
|
raise
|
||||||
|
|
||||||
def do_upgrade_by_argv(argv):
|
def do_upgrade_by_argv(argv):
|
||||||
upgrade_params = UpgradeParams()
|
upgrade_params = UpgradeParams()
|
||||||
@ -145,14 +145,14 @@ def do_upgrade_by_argv(argv):
|
|||||||
logging.info('parameters from cmd: host=\"%s\", port=%s, user=\"%s\", password=\"%s\", timeout=\"%s\", module=\"%s\", log-file=\"%s\"',\
|
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)
|
host, port, user, password.replace('"', '\\"'), timeout, module_set, log_filename)
|
||||||
do_upgrade(host, port, user, password, timeout, module_set, upgrade_params)
|
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('mysql connctor error')
|
||||||
logging.exception('run error, maybe you can reference ' + upgrade_params.rollback_sql_filename + ' to rollback it')
|
logging.exception('run error, maybe you can reference ' + upgrade_params.rollback_sql_filename + ' to rollback it')
|
||||||
raise e
|
raise
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.exception('normal error')
|
logging.exception('normal error')
|
||||||
logging.exception('run error, maybe you can reference ' + upgrade_params.rollback_sql_filename + ' to rollback it')
|
logging.exception('run error, maybe you can reference ' + upgrade_params.rollback_sql_filename + ' to rollback it')
|
||||||
raise e
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -63,7 +63,9 @@ if __name__ == '__main__':
|
|||||||
sub_files_dir = cur_file_short_name + sub_files_dir_suffix
|
sub_files_dir = cur_file_short_name + sub_files_dir_suffix
|
||||||
sub_files_short_dir = cur_file_real_name + sub_files_dir_suffix
|
sub_files_short_dir = cur_file_real_name + sub_files_dir_suffix
|
||||||
split_py_files(sub_files_dir)
|
split_py_files(sub_files_dir)
|
||||||
exec('from ' + sub_files_short_dir + '.{run_module_name} import do_upgrade_by_argv')
|
sub_files_absolute_dir = os.path.abspath(sub_files_dir)
|
||||||
|
sys.path.append(sub_files_absolute_dir)
|
||||||
|
from {run_module_name} import do_upgrade_by_argv
|
||||||
do_upgrade_by_argv(sys.argv[1:])
|
do_upgrade_by_argv(sys.argv[1:])
|
||||||
""".format(run_module_name = run_filename[0:run_filename.rfind('.')])
|
""".format(run_module_name = run_filename[0:run_filename.rfind('.')])
|
||||||
|
|
||||||
@ -71,6 +73,7 @@ def get_pre_and_post_extra_lines_strs(upgrade_pre_filename, upgrade_post_filenam
|
|||||||
do_upgrade_pre_filename, do_upgrade_post_filename, \
|
do_upgrade_pre_filename, do_upgrade_post_filename, \
|
||||||
file_splitter_line, sub_filename_line_prefix, sub_file_module_end_line):
|
file_splitter_line, sub_filename_line_prefix, sub_file_module_end_line):
|
||||||
upgrade_common_lines = """
|
upgrade_common_lines = """
|
||||||
|
from __future__ import print_function, absolute_import
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import datetime
|
import datetime
|
||||||
@ -126,7 +129,7 @@ def split_py_files(sub_files_dir):
|
|||||||
if i >= cur_file_lines_count:
|
if i >= cur_file_lines_count:
|
||||||
raise SplitError('invalid line index:' + str(i) + ', lines_count:' + str(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]:
|
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
|
break
|
||||||
else:
|
else:
|
||||||
mark_idx = cur_file_lines[i].find(sub_filename_line_prefix)
|
mark_idx = cur_file_lines[i].find(sub_filename_line_prefix)
|
||||||
|
@ -173,15 +173,15 @@ def deal_with_local_opt(opt, filename):
|
|||||||
if 'help' == opt.get_long_name():
|
if 'help' == opt.get_long_name():
|
||||||
if 'upgrade_pre' == filename:
|
if 'upgrade_pre' == filename:
|
||||||
global pre_help_str
|
global pre_help_str
|
||||||
print pre_help_str
|
print(pre_help_str)
|
||||||
elif 'upgrade_post' == filename:
|
elif 'upgrade_post' == filename:
|
||||||
global post_help_str
|
global post_help_str
|
||||||
print post_help_str
|
print(post_help_str)
|
||||||
else:
|
else:
|
||||||
raise MyError('not supported filename:{0} for help option'.format(filename))
|
raise MyError('not supported filename:{0} for help option'.format(filename))
|
||||||
elif 'version' == opt.get_long_name():
|
elif 'version' == opt.get_long_name():
|
||||||
global version_str
|
global version_str
|
||||||
print version_str
|
print(version_str)
|
||||||
|
|
||||||
def deal_with_local_opts(filename):
|
def deal_with_local_opts(filename):
|
||||||
global g_opts
|
global g_opts
|
||||||
|
2
tools/upgrade/requirements.txt
Normal file
2
tools/upgrade/requirements.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
mysql-connector-python==8.0.6
|
||||||
|
protobuf==3.18.0
|
@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from my_error import MyError
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
from actions import Cursor
|
from actions import Cursor
|
||||||
@ -37,9 +38,9 @@ def upgrade_syslog_level(conn, cur):
|
|||||||
info_cnt = result[0][0]
|
info_cnt = result[0][0]
|
||||||
if info_cnt > 0:
|
if info_cnt > 0:
|
||||||
actions.set_parameter(cur, "syslog_level", "WDIAG")
|
actions.set_parameter(cur, "syslog_level", "WDIAG")
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.warn("upgrade syslog level failed!")
|
logging.warn("upgrade syslog level failed!")
|
||||||
raise e
|
raise
|
||||||
####========******####========= actions end =========####******========####
|
####========******####========= actions end =========####******========####
|
||||||
|
|
||||||
def query(cur, sql):
|
def query(cur, sql):
|
||||||
@ -75,7 +76,7 @@ def upgrade_across_version(cur):
|
|||||||
results = query(cur, sql)
|
results = query(cur, sql)
|
||||||
if len(results) < 1 or len(results[0]) < 1:
|
if len(results) < 1 or len(results[0]) < 1:
|
||||||
logging.warn("row/column cnt not match")
|
logging.warn("row/column cnt not match")
|
||||||
raise e
|
raise MyError("row/column cnt not match")
|
||||||
elif results[0][0] <= 0:
|
elif results[0][0] <= 0:
|
||||||
# __all_virtual_core_table doesn't exist, this cluster is upgraded from 4.0.0.0
|
# __all_virtual_core_table doesn't exist, this cluster is upgraded from 4.0.0.0
|
||||||
across_version = True
|
across_version = True
|
||||||
@ -84,14 +85,14 @@ def upgrade_across_version(cur):
|
|||||||
tenant_ids = get_tenant_ids(cur)
|
tenant_ids = get_tenant_ids(cur)
|
||||||
if len(tenant_ids) <= 0:
|
if len(tenant_ids) <= 0:
|
||||||
logging.warn("tenant_ids count is unexpected")
|
logging.warn("tenant_ids count is unexpected")
|
||||||
raise e
|
raise MyError("tenant_ids count is unexpected")
|
||||||
tenant_count = len(tenant_ids)
|
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)
|
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)
|
results = query(cur, sql)
|
||||||
if len(results) != 1 or len(results[0]) != 1:
|
if len(results) != 1 or len(results[0]) != 1:
|
||||||
logging.warn('result cnt not match')
|
logging.warn('result cnt not match')
|
||||||
raise e
|
raise MyError('result cnt not match')
|
||||||
elif 2 * tenant_count != results[0][0]:
|
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]))
|
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
|
across_version = True
|
||||||
@ -105,7 +106,7 @@ def upgrade_across_version(cur):
|
|||||||
results = query(cur, sql)
|
results = query(cur, sql)
|
||||||
if len(results) < 1 or len(results[0]) < 1:
|
if len(results) < 1 or len(results[0]) < 1:
|
||||||
logging.warn("row/column cnt not match")
|
logging.warn("row/column cnt not match")
|
||||||
raise e
|
raise MyError("row/column cnt not match")
|
||||||
elif results[0][0] == 0:
|
elif results[0][0] == 0:
|
||||||
logging.info("compatible are all matched")
|
logging.info("compatible are all matched")
|
||||||
else:
|
else:
|
||||||
@ -124,16 +125,16 @@ def get_max_used_job_id(cur):
|
|||||||
max_job_id = 0
|
max_job_id = 0
|
||||||
elif (len(results) != 1 or len(results[0]) != 1):
|
elif (len(results) != 1 or len(results[0]) != 1):
|
||||||
logging.warn("row cnt not match")
|
logging.warn("row cnt not match")
|
||||||
raise e
|
raise MyError("row cnt not match")
|
||||||
else:
|
else:
|
||||||
max_job_id = results[0][0]
|
max_job_id = results[0][0]
|
||||||
|
|
||||||
logging.info("get max_used_job_id:{0}".format(max_job_id))
|
logging.info("get max_used_job_id:{0}".format(max_job_id))
|
||||||
|
|
||||||
return max_job_id
|
return max_job_id
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.warn("failed to get max_used_job_id")
|
logging.warn("failed to get max_used_job_id")
|
||||||
raise e
|
raise
|
||||||
|
|
||||||
def check_can_run_upgrade_job(cur, job_name):
|
def check_can_run_upgrade_job(cur, job_name):
|
||||||
try:
|
try:
|
||||||
@ -147,10 +148,10 @@ def check_can_run_upgrade_job(cur, job_name):
|
|||||||
logging.info("upgrade job not created yet, should run upgrade job")
|
logging.info("upgrade job not created yet, should run upgrade job")
|
||||||
elif (len(results) != 1 or len(results[0]) != 1):
|
elif (len(results) != 1 or len(results[0]) != 1):
|
||||||
logging.warn("row cnt not match")
|
logging.warn("row cnt not match")
|
||||||
raise e
|
raise MyError("row cnt not match")
|
||||||
elif ("INPROGRESS" == results[0][0]):
|
elif ("INPROGRESS" == results[0][0]):
|
||||||
logging.warn("upgrade job still running, should wait")
|
logging.warn("upgrade job still running, should wait")
|
||||||
raise e
|
raise MyError("upgrade job still running, should wait")
|
||||||
elif ("SUCCESS" == results[0][0]):
|
elif ("SUCCESS" == results[0][0]):
|
||||||
bret = True
|
bret = True
|
||||||
logging.info("maybe upgrade job remained, can run again")
|
logging.info("maybe upgrade job remained, can run again")
|
||||||
@ -159,12 +160,12 @@ def check_can_run_upgrade_job(cur, job_name):
|
|||||||
logging.info("execute upgrade job failed, should run again")
|
logging.info("execute upgrade job failed, should run again")
|
||||||
else:
|
else:
|
||||||
logging.warn("invalid job status: {0}".format(results[0][0]))
|
logging.warn("invalid job status: {0}".format(results[0][0]))
|
||||||
raise e
|
raise MyError("invalid job status: {0}".format(results[0][0]))
|
||||||
|
|
||||||
return bret
|
return bret
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.warn("failed to check if upgrade job can run")
|
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):
|
def check_upgrade_job_result(cur, job_name, timeout, max_used_job_id):
|
||||||
try:
|
try:
|
||||||
@ -181,7 +182,7 @@ def check_upgrade_job_result(cur, job_name, timeout, max_used_job_id):
|
|||||||
logging.info("upgrade job not created yet")
|
logging.info("upgrade job not created yet")
|
||||||
elif (len(results) != 1 or len(results[0]) != 4):
|
elif (len(results) != 1 or len(results[0]) != 4):
|
||||||
logging.warn("row cnt not match")
|
logging.warn("row cnt not match")
|
||||||
raise e
|
raise MyError("row cnt not match")
|
||||||
elif ("INPROGRESS" == results[0][0]):
|
elif ("INPROGRESS" == results[0][0]):
|
||||||
logging.info("upgrade job is still running")
|
logging.info("upgrade job is still running")
|
||||||
# check if rs change
|
# check if rs change
|
||||||
@ -193,39 +194,39 @@ def check_upgrade_job_result(cur, job_name, timeout, max_used_job_id):
|
|||||||
results = query(cur, sql)
|
results = query(cur, sql)
|
||||||
if (len(results) != 1 or len(results[0]) != 1):
|
if (len(results) != 1 or len(results[0]) != 1):
|
||||||
logging.warn("row/column cnt not match")
|
logging.warn("row/column cnt not match")
|
||||||
raise e
|
raise MyError("row/column cnt not match")
|
||||||
elif results[0][0] == 1:
|
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)
|
sql = """select count(*) from oceanbase.__all_rootservice_event_history where gmt_create > '{0}' and event = 'full_rootservice'""".format(gmt_create)
|
||||||
results = query(cur, sql)
|
results = query(cur, sql)
|
||||||
if (len(results) != 1 or len(results[0]) != 1):
|
if (len(results) != 1 or len(results[0]) != 1):
|
||||||
logging.warn("row/column cnt not match")
|
logging.warn("row/column cnt not match")
|
||||||
raise e
|
raise MyError("row/column cnt not match")
|
||||||
elif results[0][0] > 0:
|
elif results[0][0] > 0:
|
||||||
logging.warn("rs changed, should check if upgrade job is still running")
|
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:
|
else:
|
||||||
logging.info("rs[{0}:{1}] still exist, keep waiting".format(ip, port))
|
logging.info("rs[{0}:{1}] still exist, keep waiting".format(ip, port))
|
||||||
else:
|
else:
|
||||||
logging.warn("rs changed or not exist, should check if upgrade job is still running")
|
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]):
|
elif ("SUCCESS" == results[0][0]):
|
||||||
logging.info("execute upgrade job successfully")
|
logging.info("execute upgrade job successfully")
|
||||||
break;
|
break;
|
||||||
elif ("FAILED" == results[0][0]):
|
elif ("FAILED" == results[0][0]):
|
||||||
logging.warn("execute upgrade job failed")
|
logging.warn("execute upgrade job failed")
|
||||||
raise e
|
raise MyError("execute upgrade job failed")
|
||||||
else:
|
else:
|
||||||
logging.warn("invalid job status: {0}".format(results[0][0]))
|
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
|
times = times - 1
|
||||||
if times == -1:
|
if times == -1:
|
||||||
logging.warn("""check {0} job timeout""".format(job_name))
|
logging.warn("""check {0} job timeout""".format(job_name))
|
||||||
raise e
|
raise MyError("""check {0} job timeout""".format(job_name))
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.warn("failed to check upgrade job result")
|
logging.warn("failed to check upgrade job result")
|
||||||
raise e
|
raise
|
||||||
|
|
||||||
def run_upgrade_job(conn, cur, job_name, timeout):
|
def run_upgrade_job(conn, cur, job_name, timeout):
|
||||||
try:
|
try:
|
||||||
@ -252,7 +253,7 @@ def run_upgrade_job(conn, cur, job_name, timeout):
|
|||||||
# reset enable_ddl
|
# reset enable_ddl
|
||||||
if ori_enable_ddl == 0:
|
if ori_enable_ddl == 0:
|
||||||
actions.set_parameter(cur, 'enable_ddl', 'False', timeout)
|
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))
|
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))
|
logging.info("run upgrade job success, job_name:{0}".format(job_name))
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import mysql.connector
|
import mysql.connector
|
||||||
@ -10,6 +11,10 @@ import getopt
|
|||||||
import time
|
import time
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
if sys.version_info.major == 3:
|
||||||
|
def cmp(a, b):
|
||||||
|
return (a > b) - (a < b)
|
||||||
|
|
||||||
class UpgradeParams:
|
class UpgradeParams:
|
||||||
log_filename = 'upgrade_checker.log'
|
log_filename = 'upgrade_checker.log'
|
||||||
old_version = '4.0.0.0'
|
old_version = '4.0.0.0'
|
||||||
@ -37,12 +42,12 @@ class Cursor:
|
|||||||
if True == print_when_succ:
|
if True == print_when_succ:
|
||||||
logging.info('succeed to execute sql: %s, rowcount = %d', sql, rowcount)
|
logging.info('succeed to execute sql: %s, rowcount = %d', sql, rowcount)
|
||||||
return 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)
|
logging.exception('mysql connector error, fail to execute sql: %s', sql)
|
||||||
raise e
|
raise
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.exception('normal error, fail to execute sql: %s', sql)
|
logging.exception('normal error, fail to execute sql: %s', sql)
|
||||||
raise e
|
raise
|
||||||
def exec_query(self, sql, print_when_succ = True):
|
def exec_query(self, sql, print_when_succ = True):
|
||||||
try:
|
try:
|
||||||
self.__cursor.execute(sql)
|
self.__cursor.execute(sql)
|
||||||
@ -51,12 +56,12 @@ class Cursor:
|
|||||||
if True == print_when_succ:
|
if True == print_when_succ:
|
||||||
logging.info('succeed to execute query: %s, rowcount = %d', sql, rowcount)
|
logging.info('succeed to execute query: %s, rowcount = %d', sql, rowcount)
|
||||||
return (self.__cursor.description, results)
|
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)
|
logging.exception('mysql connector error, fail to execute sql: %s', sql)
|
||||||
raise e
|
raise
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.exception('normal error, fail to execute sql: %s', sql)
|
logging.exception('normal error, fail to execute sql: %s', sql)
|
||||||
raise e
|
raise
|
||||||
|
|
||||||
def set_parameter(cur, parameter, value):
|
def set_parameter(cur, parameter, value):
|
||||||
sql = """alter system set {0} = '{1}'""".format(parameter, value)
|
sql = """alter system set {0} = '{1}'""".format(parameter, value)
|
||||||
@ -74,7 +79,7 @@ def wait_parameter_sync(cur, key, value):
|
|||||||
result = cur.fetchall()
|
result = cur.fetchall()
|
||||||
if len(result) != 1 or len(result[0]) != 1:
|
if len(result) != 1 or len(result[0]) != 1:
|
||||||
logging.exception('result cnt not match')
|
logging.exception('result cnt not match')
|
||||||
raise e
|
raise MyError('result cnt not match')
|
||||||
elif result[0][0] == 0:
|
elif result[0][0] == 0:
|
||||||
logging.info("""{0} is sync, value is {1}""".format(key, value))
|
logging.info("""{0} is sync, value is {1}""".format(key, value))
|
||||||
break
|
break
|
||||||
@ -84,7 +89,7 @@ def wait_parameter_sync(cur, key, value):
|
|||||||
times -= 1
|
times -= 1
|
||||||
if times == 0:
|
if times == 0:
|
||||||
logging.exception("""check {0}:{1} sync timeout""".format(key, value))
|
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)
|
time.sleep(5)
|
||||||
|
|
||||||
#### --------------start : opt.py --------------
|
#### --------------start : opt.py --------------
|
||||||
@ -221,10 +226,10 @@ def parse_options(argv):
|
|||||||
def deal_with_local_opt(opt):
|
def deal_with_local_opt(opt):
|
||||||
if 'help' == opt.get_long_name():
|
if 'help' == opt.get_long_name():
|
||||||
global help_str
|
global help_str
|
||||||
print help_str
|
print(help_str)
|
||||||
elif 'version' == opt.get_long_name():
|
elif 'version' == opt.get_long_name():
|
||||||
global version_str
|
global version_str
|
||||||
print version_str
|
print(version_str)
|
||||||
|
|
||||||
def deal_with_local_opts():
|
def deal_with_local_opts():
|
||||||
global g_opts
|
global g_opts
|
||||||
@ -307,7 +312,7 @@ def get_version(version_str):
|
|||||||
|
|
||||||
if len(versions) != 4:
|
if len(versions) != 4:
|
||||||
logging.exception("""version:{0} is invalid""".format(version_str))
|
logging.exception("""version:{0} is invalid""".format(version_str))
|
||||||
raise e
|
raise MyError("""version:{0} is invalid""".format(version_str))
|
||||||
|
|
||||||
major = int(versions[0])
|
major = int(versions[0])
|
||||||
minor = int(versions[1])
|
minor = int(versions[1])
|
||||||
@ -316,7 +321,7 @@ def get_version(version_str):
|
|||||||
|
|
||||||
if major > 0xffffffff or minor > 0xffff or major_patch > 0xff or minor_patch > 0xff:
|
if major > 0xffffffff or minor > 0xffff or major_patch > 0xff or minor_patch > 0xff:
|
||||||
logging.exception("""version:{0} is invalid""".format(version_str))
|
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)
|
version = (major << 32) | (minor << 16) | (major_patch << 8) | (minor_patch)
|
||||||
return version
|
return version
|
||||||
@ -328,7 +333,7 @@ def check_observer_version(query_cur, upgrade_params):
|
|||||||
if len(results) != 1:
|
if len(results) != 1:
|
||||||
fail_list.append('min_observer_version is not sync')
|
fail_list.append('min_observer_version is not sync')
|
||||||
elif cmp(results[0][0], upgrade_params.old_version) < 0 :
|
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]))
|
logging.info('check observer version success, version = {0}'.format(results[0][0]))
|
||||||
|
|
||||||
def check_data_version(query_cur):
|
def check_data_version(query_cur):
|
||||||
@ -769,18 +774,18 @@ def do_check(my_host, my_port, my_user, my_passwd, timeout, upgrade_params):
|
|||||||
# all check func should execute before check_fail_list
|
# all check func should execute before check_fail_list
|
||||||
check_fail_list()
|
check_fail_list()
|
||||||
modify_server_permanent_offline_time(cur)
|
modify_server_permanent_offline_time(cur)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.exception('run error')
|
logging.exception('run error')
|
||||||
raise e
|
raise
|
||||||
finally:
|
finally:
|
||||||
cur.close()
|
cur.close()
|
||||||
conn.close()
|
conn.close()
|
||||||
except mysql.connector.Error, e:
|
except mysql.connector.Error as e:
|
||||||
logging.exception('connection error')
|
logging.exception('connection error')
|
||||||
raise e
|
raise
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.exception('normal error')
|
logging.exception('normal error')
|
||||||
raise e
|
raise
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
upgrade_params = UpgradeParams()
|
upgrade_params = UpgradeParams()
|
||||||
@ -803,9 +808,9 @@ if __name__ == '__main__':
|
|||||||
logging.info('parameters from cmd: host=\"%s\", port=%s, user=\"%s\", password=\"%s\", timeout=\"%s\", log-file=\"%s\"',\
|
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)
|
host, port, user, password.replace('"', '\\"'), timeout, log_filename)
|
||||||
do_check(host, port, user, password, timeout, upgrade_params)
|
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')
|
logging.exception('mysql connctor error')
|
||||||
raise e
|
raise
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.exception('normal error')
|
logging.exception('normal error')
|
||||||
raise e
|
raise
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
@ -37,12 +38,12 @@ class QueryCursor:
|
|||||||
if True == print_when_succ:
|
if True == print_when_succ:
|
||||||
logging.info('succeed to execute sql: %s, rowcount = %d', sql, rowcount)
|
logging.info('succeed to execute sql: %s, rowcount = %d', sql, rowcount)
|
||||||
return 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)
|
logging.exception('mysql connector error, fail to execute sql: %s', sql)
|
||||||
raise e
|
raise
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.exception('normal error, fail to execute sql: %s', sql)
|
logging.exception('normal error, fail to execute sql: %s', sql)
|
||||||
raise e
|
raise
|
||||||
def exec_query(self, sql, print_when_succ = True):
|
def exec_query(self, sql, print_when_succ = True):
|
||||||
try:
|
try:
|
||||||
self.__cursor.execute(sql)
|
self.__cursor.execute(sql)
|
||||||
@ -51,12 +52,12 @@ class QueryCursor:
|
|||||||
if True == print_when_succ:
|
if True == print_when_succ:
|
||||||
logging.info('succeed to execute query: %s, rowcount = %d', sql, rowcount)
|
logging.info('succeed to execute query: %s, rowcount = %d', sql, rowcount)
|
||||||
return (self.__cursor.description, results)
|
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)
|
logging.exception('mysql connector error, fail to execute sql: %s', sql)
|
||||||
raise e
|
raise
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.exception('normal error, fail to execute sql: %s', sql)
|
logging.exception('normal error, fail to execute sql: %s', sql)
|
||||||
raise e
|
raise
|
||||||
#### ---------------end----------------------
|
#### ---------------end----------------------
|
||||||
|
|
||||||
#### --------------start : opt.py --------------
|
#### --------------start : opt.py --------------
|
||||||
@ -196,10 +197,10 @@ def parse_options(argv):
|
|||||||
def deal_with_local_opt(opt):
|
def deal_with_local_opt(opt):
|
||||||
if 'help' == opt.get_long_name():
|
if 'help' == opt.get_long_name():
|
||||||
global help_str
|
global help_str
|
||||||
print help_str
|
print(help_str)
|
||||||
elif 'version' == opt.get_long_name():
|
elif 'version' == opt.get_long_name():
|
||||||
global version_str
|
global version_str
|
||||||
print version_str
|
print(version_str)
|
||||||
|
|
||||||
def deal_with_local_opts():
|
def deal_with_local_opts():
|
||||||
global g_opts
|
global g_opts
|
||||||
@ -300,9 +301,9 @@ def fetch_tenant_ids(query_cur):
|
|||||||
for r in results:
|
for r in results:
|
||||||
tenant_id_list.append(r[0])
|
tenant_id_list.append(r[0])
|
||||||
return tenant_id_list
|
return tenant_id_list
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.exception('fail to fetch distinct tenant ids')
|
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):
|
def set_default_timeout_by_tenant(query_cur, timeout, timeout_per_tenant, min_timeout):
|
||||||
if timeout > 0:
|
if timeout > 0:
|
||||||
@ -386,7 +387,7 @@ def check_until_timeout(query_cur, sql, value, timeout):
|
|||||||
times -= 1
|
times -= 1
|
||||||
if times == -1:
|
if times == -1:
|
||||||
logging.warn("""check {0} job timeout""".format(job_name))
|
logging.warn("""check {0} job timeout""".format(job_name))
|
||||||
raise e
|
raise MyError("""check {0} job timeout""".format(job_name))
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
|
|
||||||
# 开始健康检查
|
# 开始健康检查
|
||||||
@ -409,18 +410,18 @@ def do_check(my_host, my_port, my_user, my_passwd, upgrade_params, timeout, need
|
|||||||
check_server_version_by_zone(query_cur, zone)
|
check_server_version_by_zone(query_cur, zone)
|
||||||
if True == need_check_major_status:
|
if True == need_check_major_status:
|
||||||
check_major_merge(query_cur, timeout)
|
check_major_merge(query_cur, timeout)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.exception('run error')
|
logging.exception('run error')
|
||||||
raise e
|
raise
|
||||||
finally:
|
finally:
|
||||||
cur.close()
|
cur.close()
|
||||||
conn.close()
|
conn.close()
|
||||||
except mysql.connector.Error, e:
|
except mysql.connector.Error as e:
|
||||||
logging.exception('connection error')
|
logging.exception('connection error')
|
||||||
raise e
|
raise
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.exception('normal error')
|
logging.exception('normal error')
|
||||||
raise e
|
raise
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
upgrade_params = UpgradeParams()
|
upgrade_params = UpgradeParams()
|
||||||
@ -444,10 +445,10 @@ if __name__ == '__main__':
|
|||||||
logging.info('parameters from cmd: host=\"%s\", port=%s, user=\"%s\", password=\"%s\", log-file=\"%s\", timeout=%s, zone=\"%s\"', \
|
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)
|
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
|
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')
|
logging.exception('mysql connctor error')
|
||||||
raise e
|
raise
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.exception('normal error')
|
logging.exception('normal error')
|
||||||
raise e
|
raise
|
||||||
|
|
||||||
|
@ -121,10 +121,10 @@
|
|||||||
# results = cur.fetchall()
|
# results = cur.fetchall()
|
||||||
# if len(results) != 1:
|
# if len(results) != 1:
|
||||||
# logging.exception('min_observer_version is not sync')
|
# logging.exception('min_observer_version is not sync')
|
||||||
# raise e
|
# raise MyError('min_observer_version is not sync')
|
||||||
# elif len(results[0]) != 1:
|
# elif len(results[0]) != 1:
|
||||||
# logging.exception('column cnt not match')
|
# logging.exception('column cnt not match')
|
||||||
# raise e
|
# raise MyError('column cnt not match')
|
||||||
# else:
|
# else:
|
||||||
# min_cluster_version = get_version(results[0][0])
|
# min_cluster_version = get_version(results[0][0])
|
||||||
# return min_cluster_version
|
# return min_cluster_version
|
||||||
@ -197,17 +197,17 @@
|
|||||||
# ori_value = 'True'
|
# ori_value = 'True'
|
||||||
# elif len(result) != 1 or len(result[0]) != 1:
|
# elif len(result) != 1 or len(result[0]) != 1:
|
||||||
# logging.exception('result cnt not match')
|
# 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']:
|
# elif result[0][0].lower() in ["1", "true", "on", "yes", 't']:
|
||||||
# ori_value = 'True'
|
# ori_value = 'True'
|
||||||
# elif result[0][0].lower() in ["0", "false", "off", "no", 'f']:
|
# elif result[0][0].lower() in ["0", "false", "off", "no", 'f']:
|
||||||
# ori_value = 'False'
|
# ori_value = 'False'
|
||||||
# else:
|
# else:
|
||||||
# logging.exception("""result value is invalid, result:{0}""".format(result[0][0]))
|
# 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
|
# return ori_value
|
||||||
#
|
#
|
||||||
## print version like "x.x.x.x"
|
## print(version like "x.x.x.x")
|
||||||
#def print_version(version):
|
#def print_version(version):
|
||||||
# version = int(version)
|
# version = int(version)
|
||||||
# major = (version >> 32) & 0xffffffff
|
# major = (version >> 32) & 0xffffffff
|
||||||
@ -222,7 +222,7 @@
|
|||||||
#
|
#
|
||||||
# if len(versions) != 4:
|
# if len(versions) != 4:
|
||||||
# logging.exception("""version:{0} is invalid""".format(version_str))
|
# logging.exception("""version:{0} is invalid""".format(version_str))
|
||||||
# raise e
|
# raise MyError("""version:{0} is invalid""".format(version_str))
|
||||||
#
|
#
|
||||||
# major = int(versions[0])
|
# major = int(versions[0])
|
||||||
# minor = int(versions[1])
|
# minor = int(versions[1])
|
||||||
@ -231,7 +231,7 @@
|
|||||||
#
|
#
|
||||||
# if major > 0xffffffff or minor > 0xffff or major_patch > 0xff or minor_patch > 0xff:
|
# if major > 0xffffffff or minor > 0xffff or major_patch > 0xff or minor_patch > 0xff:
|
||||||
# logging.exception("""version:{0} is invalid""".format(version_str))
|
# 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)
|
# version = (major << 32) | (minor << 16) | (major_patch << 8) | (minor_patch)
|
||||||
# return version
|
# return version
|
||||||
@ -285,7 +285,7 @@
|
|||||||
# result = cur.fetchall()
|
# result = cur.fetchall()
|
||||||
# if len(result) != 1 or len(result[0]) != 1:
|
# if len(result) != 1 or len(result[0]) != 1:
|
||||||
# logging.exception('result cnt not match')
|
# logging.exception('result cnt not match')
|
||||||
# raise e
|
# raise MyError('result cnt not match')
|
||||||
# elif result[0][0] == 0:
|
# elif result[0][0] == 0:
|
||||||
# logging.info("""{0} is sync, value is {1}""".format(key, value))
|
# logging.info("""{0} is sync, value is {1}""".format(key, value))
|
||||||
# break
|
# break
|
||||||
@ -295,7 +295,7 @@
|
|||||||
# times -= 1
|
# times -= 1
|
||||||
# if times == -1:
|
# if times == -1:
|
||||||
# logging.exception("""check {0}:{1} sync timeout""".format(key, value))
|
# 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)
|
# time.sleep(5)
|
||||||
#
|
#
|
||||||
# set_session_timeout(cur, 10)
|
# set_session_timeout(cur, 10)
|
||||||
@ -414,12 +414,12 @@
|
|||||||
# if True == print_when_succ:
|
# if True == print_when_succ:
|
||||||
# logging.info('succeed to execute sql: %s, rowcount = %d', sql, rowcount)
|
# logging.info('succeed to execute sql: %s, rowcount = %d', sql, rowcount)
|
||||||
# return 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)
|
# logging.exception('mysql connector error, fail to execute sql: %s', sql)
|
||||||
# raise e
|
# raise
|
||||||
# except Exception, e:
|
# except Exception as e:
|
||||||
# logging.exception('normal error, fail to execute sql: %s', sql)
|
# logging.exception('normal error, fail to execute sql: %s', sql)
|
||||||
# raise e
|
# raise
|
||||||
# def exec_query(self, sql, print_when_succ = True):
|
# def exec_query(self, sql, print_when_succ = True):
|
||||||
# try:
|
# try:
|
||||||
# self.__cursor.execute(sql)
|
# self.__cursor.execute(sql)
|
||||||
@ -428,12 +428,12 @@
|
|||||||
# if True == print_when_succ:
|
# if True == print_when_succ:
|
||||||
# logging.info('succeed to execute query: %s, rowcount = %d', sql, rowcount)
|
# logging.info('succeed to execute query: %s, rowcount = %d', sql, rowcount)
|
||||||
# return (self.__cursor.description, results)
|
# 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)
|
# logging.exception('mysql connector error, fail to execute sql: %s', sql)
|
||||||
# raise e
|
# raise
|
||||||
# except Exception, e:
|
# except Exception as e:
|
||||||
# logging.exception('normal error, fail to execute sql: %s', sql)
|
# logging.exception('normal error, fail to execute sql: %s', sql)
|
||||||
# raise e
|
# raise
|
||||||
#
|
#
|
||||||
#class DDLCursor:
|
#class DDLCursor:
|
||||||
# _cursor = None
|
# _cursor = None
|
||||||
@ -444,9 +444,9 @@
|
|||||||
# # 这里检查是不是ddl,不是ddl就抛错
|
# # 这里检查是不是ddl,不是ddl就抛错
|
||||||
# check_is_ddl_sql(sql)
|
# check_is_ddl_sql(sql)
|
||||||
# return self._cursor.exec_sql(sql, print_when_succ)
|
# return self._cursor.exec_sql(sql, print_when_succ)
|
||||||
# except Exception, e:
|
# except Exception as e:
|
||||||
# logging.exception('fail to execute ddl: %s', sql)
|
# logging.exception('fail to execute ddl: %s', sql)
|
||||||
# raise e
|
# raise
|
||||||
#
|
#
|
||||||
#class QueryCursor:
|
#class QueryCursor:
|
||||||
# _cursor = None
|
# _cursor = None
|
||||||
@ -457,9 +457,9 @@
|
|||||||
# # 这里检查是不是query,不是query就抛错
|
# # 这里检查是不是query,不是query就抛错
|
||||||
# check_is_query_sql(sql)
|
# check_is_query_sql(sql)
|
||||||
# return self._cursor.exec_query(sql, print_when_succ)
|
# 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)
|
# logging.exception('fail to execute dml query: %s', sql)
|
||||||
# raise e
|
# raise
|
||||||
#
|
#
|
||||||
#class DMLCursor(QueryCursor):
|
#class DMLCursor(QueryCursor):
|
||||||
# def exec_update(self, sql, print_when_succ = True):
|
# def exec_update(self, sql, print_when_succ = True):
|
||||||
@ -467,9 +467,9 @@
|
|||||||
# # 这里检查是不是update,不是update就抛错
|
# # 这里检查是不是update,不是update就抛错
|
||||||
# check_is_update_sql(sql)
|
# check_is_update_sql(sql)
|
||||||
# return self._cursor.exec_sql(sql, print_when_succ)
|
# 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)
|
# logging.exception('fail to execute dml update: %s', sql)
|
||||||
# raise e
|
# raise
|
||||||
#
|
#
|
||||||
#class BaseDDLAction():
|
#class BaseDDLAction():
|
||||||
# __ddl_cursor = None
|
# __ddl_cursor = None
|
||||||
@ -579,9 +579,9 @@
|
|||||||
# for r in results:
|
# for r in results:
|
||||||
# tenant_id_list.append(r[0])
|
# tenant_id_list.append(r[0])
|
||||||
# return tenant_id_list
|
# return tenant_id_list
|
||||||
# except Exception, e:
|
# except Exception as e:
|
||||||
# logging.exception('fail to fetch distinct tenant ids')
|
# logging.exception('fail to fetch distinct tenant ids')
|
||||||
# raise e
|
# raise
|
||||||
#
|
#
|
||||||
####====XXXX======######==== I am a splitter ====######======XXXX====####
|
####====XXXX======######==== I am a splitter ====######======XXXX====####
|
||||||
#filename:config.py
|
#filename:config.py
|
||||||
@ -706,9 +706,9 @@
|
|||||||
# actions.refresh_commit_sql_list()
|
# actions.refresh_commit_sql_list()
|
||||||
# logging.info('================succeed to run post check action ===============')
|
# logging.info('================succeed to run post check action ===============')
|
||||||
#
|
#
|
||||||
# except Exception, e:
|
# except Exception as e:
|
||||||
# logging.exception('run error')
|
# logging.exception('run error')
|
||||||
# raise e
|
# raise
|
||||||
# finally:
|
# finally:
|
||||||
# # 打印统计信息
|
# # 打印统计信息
|
||||||
# print_stats()
|
# print_stats()
|
||||||
@ -716,12 +716,12 @@
|
|||||||
# # actions.dump_rollback_sql_to_file(upgrade_params.rollback_sql_filename)
|
# # actions.dump_rollback_sql_to_file(upgrade_params.rollback_sql_filename)
|
||||||
# cur.close()
|
# cur.close()
|
||||||
# conn.close()
|
# conn.close()
|
||||||
# except mysql.connector.Error, e:
|
# except mysql.connector.Error as e:
|
||||||
# logging.exception('connection error')
|
# logging.exception('connection error')
|
||||||
# raise e
|
# raise
|
||||||
# except Exception, e:
|
# except Exception as e:
|
||||||
# logging.exception('normal error')
|
# logging.exception('normal error')
|
||||||
# raise e
|
# raise
|
||||||
#
|
#
|
||||||
#def do_upgrade_by_argv(argv):
|
#def do_upgrade_by_argv(argv):
|
||||||
# upgrade_params = UpgradeParams()
|
# 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\"',\
|
# 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)
|
# host, port, user, password.replace('"', '\\"'), timeout, module_set, log_filename)
|
||||||
# do_upgrade(host, port, user, password, timeout, module_set, upgrade_params)
|
# 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('mysql connctor error')
|
||||||
# logging.exception('run error, maybe you can reference ' + upgrade_params.rollback_sql_filename + ' to rollback it')
|
# logging.exception('run error, maybe you can reference ' + upgrade_params.rollback_sql_filename + ' to rollback it')
|
||||||
# raise e
|
# raise
|
||||||
# except Exception, e:
|
# except Exception as e:
|
||||||
# logging.exception('normal error')
|
# logging.exception('normal error')
|
||||||
# logging.exception('run error, maybe you can reference ' + upgrade_params.rollback_sql_filename + ' to rollback it')
|
# 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
|
# 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 ===============')
|
# logging.info('================succeed to run health check action ===============')
|
||||||
#
|
#
|
||||||
# except Exception, e:
|
# except Exception as e:
|
||||||
# logging.exception('run error')
|
# logging.exception('run error')
|
||||||
# raise e
|
# raise
|
||||||
# finally:
|
# finally:
|
||||||
# # 打印统计信息
|
# # 打印统计信息
|
||||||
# print_stats()
|
# print_stats()
|
||||||
@ -876,12 +876,12 @@
|
|||||||
# # actions.dump_rollback_sql_to_file(upgrade_params.rollback_sql_filename)
|
# # actions.dump_rollback_sql_to_file(upgrade_params.rollback_sql_filename)
|
||||||
# cur.close()
|
# cur.close()
|
||||||
# conn.close()
|
# conn.close()
|
||||||
# except mysql.connector.Error, e:
|
# except mysql.connector.Error as e:
|
||||||
# logging.exception('connection error')
|
# logging.exception('connection error')
|
||||||
# raise e
|
# raise
|
||||||
# except Exception, e:
|
# except Exception as e:
|
||||||
# logging.exception('normal error')
|
# logging.exception('normal error')
|
||||||
# raise e
|
# raise
|
||||||
#
|
#
|
||||||
#def do_upgrade_by_argv(argv):
|
#def do_upgrade_by_argv(argv):
|
||||||
# upgrade_params = UpgradeParams()
|
# 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\"',\
|
# 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)
|
# host, port, user, password.replace('"', '\\"'), timeout, module_set, log_filename)
|
||||||
# do_upgrade(host, port, user, password, timeout, module_set, upgrade_params)
|
# 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('mysql connctor error')
|
||||||
# logging.exception('run error, maybe you can reference ' + upgrade_params.rollback_sql_filename + ' to rollback it')
|
# logging.exception('run error, maybe you can reference ' + upgrade_params.rollback_sql_filename + ' to rollback it')
|
||||||
# raise e
|
# raise
|
||||||
# except Exception, e:
|
# except Exception as e:
|
||||||
# logging.exception('normal error')
|
# logging.exception('normal error')
|
||||||
# logging.exception('run error, maybe you can reference ' + upgrade_params.rollback_sql_filename + ' to rollback it')
|
# 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 'help' == opt.get_long_name():
|
||||||
# if 'upgrade_pre' == filename:
|
# if 'upgrade_pre' == filename:
|
||||||
# global pre_help_str
|
# global pre_help_str
|
||||||
# print pre_help_str
|
# print(pre_help_str)
|
||||||
# elif 'upgrade_post' == filename:
|
# elif 'upgrade_post' == filename:
|
||||||
# global post_help_str
|
# global post_help_str
|
||||||
# print post_help_str
|
# print(post_help_str)
|
||||||
# else:
|
# else:
|
||||||
# raise MyError('not supported filename:{0} for help option'.format(filename))
|
# raise MyError('not supported filename:{0} for help option'.format(filename))
|
||||||
# elif 'version' == opt.get_long_name():
|
# elif 'version' == opt.get_long_name():
|
||||||
# global version_str
|
# global version_str
|
||||||
# print version_str
|
# print(version_str)
|
||||||
#
|
#
|
||||||
#def deal_with_local_opts(filename):
|
#def deal_with_local_opts(filename):
|
||||||
# global g_opts
|
# global g_opts
|
||||||
@ -1395,6 +1395,7 @@
|
|||||||
##!/usr/bin/env python
|
##!/usr/bin/env python
|
||||||
## -*- coding: utf-8 -*-
|
## -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
|
#from my_error import MyError
|
||||||
#import logging
|
#import logging
|
||||||
#import time
|
#import time
|
||||||
#from actions import Cursor
|
#from actions import Cursor
|
||||||
@ -1431,9 +1432,9 @@
|
|||||||
# info_cnt = result[0][0]
|
# info_cnt = result[0][0]
|
||||||
# if info_cnt > 0:
|
# if info_cnt > 0:
|
||||||
# actions.set_parameter(cur, "syslog_level", "WDIAG")
|
# actions.set_parameter(cur, "syslog_level", "WDIAG")
|
||||||
# except Exception, e:
|
# except Exception as e:
|
||||||
# logging.warn("upgrade syslog level failed!")
|
# logging.warn("upgrade syslog level failed!")
|
||||||
# raise e
|
# raise
|
||||||
#####========******####========= actions end =========####******========####
|
#####========******####========= actions end =========####******========####
|
||||||
#
|
#
|
||||||
#def query(cur, sql):
|
#def query(cur, sql):
|
||||||
@ -1469,7 +1470,7 @@
|
|||||||
# results = query(cur, sql)
|
# results = query(cur, sql)
|
||||||
# if len(results) < 1 or len(results[0]) < 1:
|
# if len(results) < 1 or len(results[0]) < 1:
|
||||||
# logging.warn("row/column cnt not match")
|
# logging.warn("row/column cnt not match")
|
||||||
# raise e
|
# raise MyError("row/column cnt not match")
|
||||||
# elif results[0][0] <= 0:
|
# elif results[0][0] <= 0:
|
||||||
# # __all_virtual_core_table doesn't exist, this cluster is upgraded from 4.0.0.0
|
# # __all_virtual_core_table doesn't exist, this cluster is upgraded from 4.0.0.0
|
||||||
# across_version = True
|
# across_version = True
|
||||||
@ -1478,14 +1479,14 @@
|
|||||||
# tenant_ids = get_tenant_ids(cur)
|
# tenant_ids = get_tenant_ids(cur)
|
||||||
# if len(tenant_ids) <= 0:
|
# if len(tenant_ids) <= 0:
|
||||||
# logging.warn("tenant_ids count is unexpected")
|
# logging.warn("tenant_ids count is unexpected")
|
||||||
# raise e
|
# raise MyError("tenant_ids count is unexpected")
|
||||||
# tenant_count = len(tenant_ids)
|
# 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)
|
# 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)
|
# results = query(cur, sql)
|
||||||
# if len(results) != 1 or len(results[0]) != 1:
|
# if len(results) != 1 or len(results[0]) != 1:
|
||||||
# logging.warn('result cnt not match')
|
# logging.warn('result cnt not match')
|
||||||
# raise e
|
# raise MyError('result cnt not match')
|
||||||
# elif 2 * tenant_count != results[0][0]:
|
# 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]))
|
# 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
|
# across_version = True
|
||||||
@ -1499,7 +1500,7 @@
|
|||||||
# results = query(cur, sql)
|
# results = query(cur, sql)
|
||||||
# if len(results) < 1 or len(results[0]) < 1:
|
# if len(results) < 1 or len(results[0]) < 1:
|
||||||
# logging.warn("row/column cnt not match")
|
# logging.warn("row/column cnt not match")
|
||||||
# raise e
|
# raise MyError("row/column cnt not match")
|
||||||
# elif results[0][0] == 0:
|
# elif results[0][0] == 0:
|
||||||
# logging.info("compatible are all matched")
|
# logging.info("compatible are all matched")
|
||||||
# else:
|
# else:
|
||||||
@ -1518,16 +1519,16 @@
|
|||||||
# max_job_id = 0
|
# max_job_id = 0
|
||||||
# elif (len(results) != 1 or len(results[0]) != 1):
|
# elif (len(results) != 1 or len(results[0]) != 1):
|
||||||
# logging.warn("row cnt not match")
|
# logging.warn("row cnt not match")
|
||||||
# raise e
|
# raise MyError("row cnt not match")
|
||||||
# else:
|
# else:
|
||||||
# max_job_id = results[0][0]
|
# max_job_id = results[0][0]
|
||||||
#
|
#
|
||||||
# logging.info("get max_used_job_id:{0}".format(max_job_id))
|
# logging.info("get max_used_job_id:{0}".format(max_job_id))
|
||||||
#
|
#
|
||||||
# return max_job_id
|
# return max_job_id
|
||||||
# except Exception, e:
|
# except Exception as e:
|
||||||
# logging.warn("failed to get max_used_job_id")
|
# logging.warn("failed to get max_used_job_id")
|
||||||
# raise e
|
# raise
|
||||||
#
|
#
|
||||||
#def check_can_run_upgrade_job(cur, job_name):
|
#def check_can_run_upgrade_job(cur, job_name):
|
||||||
# try:
|
# try:
|
||||||
@ -1541,10 +1542,10 @@
|
|||||||
# logging.info("upgrade job not created yet, should run upgrade job")
|
# logging.info("upgrade job not created yet, should run upgrade job")
|
||||||
# elif (len(results) != 1 or len(results[0]) != 1):
|
# elif (len(results) != 1 or len(results[0]) != 1):
|
||||||
# logging.warn("row cnt not match")
|
# logging.warn("row cnt not match")
|
||||||
# raise e
|
# raise MyError("row cnt not match")
|
||||||
# elif ("INPROGRESS" == results[0][0]):
|
# elif ("INPROGRESS" == results[0][0]):
|
||||||
# logging.warn("upgrade job still running, should wait")
|
# logging.warn("upgrade job still running, should wait")
|
||||||
# raise e
|
# raise MyError("upgrade job still running, should wait")
|
||||||
# elif ("SUCCESS" == results[0][0]):
|
# elif ("SUCCESS" == results[0][0]):
|
||||||
# bret = True
|
# bret = True
|
||||||
# logging.info("maybe upgrade job remained, can run again")
|
# logging.info("maybe upgrade job remained, can run again")
|
||||||
@ -1553,12 +1554,12 @@
|
|||||||
# logging.info("execute upgrade job failed, should run again")
|
# logging.info("execute upgrade job failed, should run again")
|
||||||
# else:
|
# else:
|
||||||
# logging.warn("invalid job status: {0}".format(results[0][0]))
|
# logging.warn("invalid job status: {0}".format(results[0][0]))
|
||||||
# raise e
|
# raise MyError("invalid job status: {0}".format(results[0][0]))
|
||||||
#
|
#
|
||||||
# return bret
|
# return bret
|
||||||
# except Exception, e:
|
# except Exception as e:
|
||||||
# logging.warn("failed to check if upgrade job can run")
|
# 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):
|
#def check_upgrade_job_result(cur, job_name, timeout, max_used_job_id):
|
||||||
# try:
|
# try:
|
||||||
@ -1575,7 +1576,7 @@
|
|||||||
# logging.info("upgrade job not created yet")
|
# logging.info("upgrade job not created yet")
|
||||||
# elif (len(results) != 1 or len(results[0]) != 4):
|
# elif (len(results) != 1 or len(results[0]) != 4):
|
||||||
# logging.warn("row cnt not match")
|
# logging.warn("row cnt not match")
|
||||||
# raise e
|
# raise MyError("row cnt not match")
|
||||||
# elif ("INPROGRESS" == results[0][0]):
|
# elif ("INPROGRESS" == results[0][0]):
|
||||||
# logging.info("upgrade job is still running")
|
# logging.info("upgrade job is still running")
|
||||||
# # check if rs change
|
# # check if rs change
|
||||||
@ -1587,39 +1588,39 @@
|
|||||||
# results = query(cur, sql)
|
# results = query(cur, sql)
|
||||||
# if (len(results) != 1 or len(results[0]) != 1):
|
# if (len(results) != 1 or len(results[0]) != 1):
|
||||||
# logging.warn("row/column cnt not match")
|
# logging.warn("row/column cnt not match")
|
||||||
# raise e
|
# raise MyError("row/column cnt not match")
|
||||||
# elif results[0][0] == 1:
|
# 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)
|
# sql = """select count(*) from oceanbase.__all_rootservice_event_history where gmt_create > '{0}' and event = 'full_rootservice'""".format(gmt_create)
|
||||||
# results = query(cur, sql)
|
# results = query(cur, sql)
|
||||||
# if (len(results) != 1 or len(results[0]) != 1):
|
# if (len(results) != 1 or len(results[0]) != 1):
|
||||||
# logging.warn("row/column cnt not match")
|
# logging.warn("row/column cnt not match")
|
||||||
# raise e
|
# raise MyError("row/column cnt not match")
|
||||||
# elif results[0][0] > 0:
|
# elif results[0][0] > 0:
|
||||||
# logging.warn("rs changed, should check if upgrade job is still running")
|
# 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:
|
# else:
|
||||||
# logging.info("rs[{0}:{1}] still exist, keep waiting".format(ip, port))
|
# logging.info("rs[{0}:{1}] still exist, keep waiting".format(ip, port))
|
||||||
# else:
|
# else:
|
||||||
# logging.warn("rs changed or not exist, should check if upgrade job is still running")
|
# 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]):
|
# elif ("SUCCESS" == results[0][0]):
|
||||||
# logging.info("execute upgrade job successfully")
|
# logging.info("execute upgrade job successfully")
|
||||||
# break;
|
# break;
|
||||||
# elif ("FAILED" == results[0][0]):
|
# elif ("FAILED" == results[0][0]):
|
||||||
# logging.warn("execute upgrade job failed")
|
# logging.warn("execute upgrade job failed")
|
||||||
# raise e
|
# raise MyError("execute upgrade job failed")
|
||||||
# else:
|
# else:
|
||||||
# logging.warn("invalid job status: {0}".format(results[0][0]))
|
# 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
|
# times = times - 1
|
||||||
# if times == -1:
|
# if times == -1:
|
||||||
# logging.warn("""check {0} job timeout""".format(job_name))
|
# logging.warn("""check {0} job timeout""".format(job_name))
|
||||||
# raise e
|
# raise MyError("""check {0} job timeout""".format(job_name))
|
||||||
# time.sleep(10)
|
# time.sleep(10)
|
||||||
# except Exception, e:
|
# except Exception as e:
|
||||||
# logging.warn("failed to check upgrade job result")
|
# logging.warn("failed to check upgrade job result")
|
||||||
# raise e
|
# raise
|
||||||
#
|
#
|
||||||
#def run_upgrade_job(conn, cur, job_name, timeout):
|
#def run_upgrade_job(conn, cur, job_name, timeout):
|
||||||
# try:
|
# try:
|
||||||
@ -1646,15 +1647,16 @@
|
|||||||
# # reset enable_ddl
|
# # reset enable_ddl
|
||||||
# if ori_enable_ddl == 0:
|
# if ori_enable_ddl == 0:
|
||||||
# actions.set_parameter(cur, 'enable_ddl', 'False', timeout)
|
# 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))
|
# 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))
|
# logging.info("run upgrade job success, job_name:{0}".format(job_name))
|
||||||
####====XXXX======######==== I am a splitter ====######======XXXX====####
|
####====XXXX======######==== I am a splitter ====######======XXXX====####
|
||||||
#filename:upgrade_checker.py
|
#filename:upgrade_checker.py
|
||||||
##!/usr/bin/env python
|
##!/usr/bin/env python
|
||||||
## -*- coding: utf-8 -*-
|
## -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
|
#from __future__ import print_function
|
||||||
#import sys
|
#import sys
|
||||||
#import os
|
#import os
|
||||||
#import mysql.connector
|
#import mysql.connector
|
||||||
@ -1664,6 +1666,10 @@
|
|||||||
#import time
|
#import time
|
||||||
#import re
|
#import re
|
||||||
#
|
#
|
||||||
|
#if sys.version_info.major == 3:
|
||||||
|
# def cmp(a, b):
|
||||||
|
# return (a > b) - (a < b)
|
||||||
|
#
|
||||||
#class UpgradeParams:
|
#class UpgradeParams:
|
||||||
# log_filename = 'upgrade_checker.log'
|
# log_filename = 'upgrade_checker.log'
|
||||||
# old_version = '4.0.0.0'
|
# old_version = '4.0.0.0'
|
||||||
@ -1691,12 +1697,12 @@
|
|||||||
# if True == print_when_succ:
|
# if True == print_when_succ:
|
||||||
# logging.info('succeed to execute sql: %s, rowcount = %d', sql, rowcount)
|
# logging.info('succeed to execute sql: %s, rowcount = %d', sql, rowcount)
|
||||||
# return 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)
|
# logging.exception('mysql connector error, fail to execute sql: %s', sql)
|
||||||
# raise e
|
# raise
|
||||||
# except Exception, e:
|
# except Exception as e:
|
||||||
# logging.exception('normal error, fail to execute sql: %s', sql)
|
# logging.exception('normal error, fail to execute sql: %s', sql)
|
||||||
# raise e
|
# raise
|
||||||
# def exec_query(self, sql, print_when_succ = True):
|
# def exec_query(self, sql, print_when_succ = True):
|
||||||
# try:
|
# try:
|
||||||
# self.__cursor.execute(sql)
|
# self.__cursor.execute(sql)
|
||||||
@ -1705,12 +1711,12 @@
|
|||||||
# if True == print_when_succ:
|
# if True == print_when_succ:
|
||||||
# logging.info('succeed to execute query: %s, rowcount = %d', sql, rowcount)
|
# logging.info('succeed to execute query: %s, rowcount = %d', sql, rowcount)
|
||||||
# return (self.__cursor.description, results)
|
# 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)
|
# logging.exception('mysql connector error, fail to execute sql: %s', sql)
|
||||||
# raise e
|
# raise
|
||||||
# except Exception, e:
|
# except Exception as e:
|
||||||
# logging.exception('normal error, fail to execute sql: %s', sql)
|
# logging.exception('normal error, fail to execute sql: %s', sql)
|
||||||
# raise e
|
# raise
|
||||||
#
|
#
|
||||||
#def set_parameter(cur, parameter, value):
|
#def set_parameter(cur, parameter, value):
|
||||||
# sql = """alter system set {0} = '{1}'""".format(parameter, value)
|
# sql = """alter system set {0} = '{1}'""".format(parameter, value)
|
||||||
@ -1728,7 +1734,7 @@
|
|||||||
# result = cur.fetchall()
|
# result = cur.fetchall()
|
||||||
# if len(result) != 1 or len(result[0]) != 1:
|
# if len(result) != 1 or len(result[0]) != 1:
|
||||||
# logging.exception('result cnt not match')
|
# logging.exception('result cnt not match')
|
||||||
# raise e
|
# raise MyError('result cnt not match')
|
||||||
# elif result[0][0] == 0:
|
# elif result[0][0] == 0:
|
||||||
# logging.info("""{0} is sync, value is {1}""".format(key, value))
|
# logging.info("""{0} is sync, value is {1}""".format(key, value))
|
||||||
# break
|
# break
|
||||||
@ -1738,7 +1744,7 @@
|
|||||||
# times -= 1
|
# times -= 1
|
||||||
# if times == 0:
|
# if times == 0:
|
||||||
# logging.exception("""check {0}:{1} sync timeout""".format(key, value))
|
# 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)
|
# time.sleep(5)
|
||||||
#
|
#
|
||||||
##### --------------start : opt.py --------------
|
##### --------------start : opt.py --------------
|
||||||
@ -1875,10 +1881,10 @@
|
|||||||
#def deal_with_local_opt(opt):
|
#def deal_with_local_opt(opt):
|
||||||
# if 'help' == opt.get_long_name():
|
# if 'help' == opt.get_long_name():
|
||||||
# global help_str
|
# global help_str
|
||||||
# print help_str
|
# print(help_str)
|
||||||
# elif 'version' == opt.get_long_name():
|
# elif 'version' == opt.get_long_name():
|
||||||
# global version_str
|
# global version_str
|
||||||
# print version_str
|
# print(version_str)
|
||||||
#
|
#
|
||||||
#def deal_with_local_opts():
|
#def deal_with_local_opts():
|
||||||
# global g_opts
|
# global g_opts
|
||||||
@ -1961,7 +1967,7 @@
|
|||||||
#
|
#
|
||||||
# if len(versions) != 4:
|
# if len(versions) != 4:
|
||||||
# logging.exception("""version:{0} is invalid""".format(version_str))
|
# logging.exception("""version:{0} is invalid""".format(version_str))
|
||||||
# raise e
|
# raise MyError("""version:{0} is invalid""".format(version_str))
|
||||||
#
|
#
|
||||||
# major = int(versions[0])
|
# major = int(versions[0])
|
||||||
# minor = int(versions[1])
|
# minor = int(versions[1])
|
||||||
@ -1970,7 +1976,7 @@
|
|||||||
#
|
#
|
||||||
# if major > 0xffffffff or minor > 0xffff or major_patch > 0xff or minor_patch > 0xff:
|
# if major > 0xffffffff or minor > 0xffff or major_patch > 0xff or minor_patch > 0xff:
|
||||||
# logging.exception("""version:{0} is invalid""".format(version_str))
|
# 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)
|
# version = (major << 32) | (minor << 16) | (major_patch << 8) | (minor_patch)
|
||||||
# return version
|
# return version
|
||||||
@ -1982,7 +1988,7 @@
|
|||||||
# if len(results) != 1:
|
# if len(results) != 1:
|
||||||
# fail_list.append('min_observer_version is not sync')
|
# fail_list.append('min_observer_version is not sync')
|
||||||
# elif cmp(results[0][0], upgrade_params.old_version) < 0 :
|
# 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]))
|
# logging.info('check observer version success, version = {0}'.format(results[0][0]))
|
||||||
#
|
#
|
||||||
#def check_data_version(query_cur):
|
#def check_data_version(query_cur):
|
||||||
@ -2423,18 +2429,18 @@
|
|||||||
# # all check func should execute before check_fail_list
|
# # all check func should execute before check_fail_list
|
||||||
# check_fail_list()
|
# check_fail_list()
|
||||||
# modify_server_permanent_offline_time(cur)
|
# modify_server_permanent_offline_time(cur)
|
||||||
# except Exception, e:
|
# except Exception as e:
|
||||||
# logging.exception('run error')
|
# logging.exception('run error')
|
||||||
# raise e
|
# raise
|
||||||
# finally:
|
# finally:
|
||||||
# cur.close()
|
# cur.close()
|
||||||
# conn.close()
|
# conn.close()
|
||||||
# except mysql.connector.Error, e:
|
# except mysql.connector.Error as e:
|
||||||
# logging.exception('connection error')
|
# logging.exception('connection error')
|
||||||
# raise e
|
# raise
|
||||||
# except Exception, e:
|
# except Exception as e:
|
||||||
# logging.exception('normal error')
|
# logging.exception('normal error')
|
||||||
# raise e
|
# raise
|
||||||
#
|
#
|
||||||
#if __name__ == '__main__':
|
#if __name__ == '__main__':
|
||||||
# upgrade_params = UpgradeParams()
|
# 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\"',\
|
# 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)
|
# host, port, user, password.replace('"', '\\"'), timeout, log_filename)
|
||||||
# do_check(host, port, user, password, timeout, upgrade_params)
|
# 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')
|
# logging.exception('mysql connctor error')
|
||||||
# raise e
|
# raise
|
||||||
# except Exception, e:
|
# except Exception as e:
|
||||||
# logging.exception('normal error')
|
# logging.exception('normal error')
|
||||||
# raise e
|
# raise
|
||||||
####====XXXX======######==== I am a splitter ====######======XXXX====####
|
####====XXXX======######==== I am a splitter ====######======XXXX====####
|
||||||
#filename:upgrade_health_checker.py
|
#filename:upgrade_health_checker.py
|
||||||
##!/usr/bin/env python
|
##!/usr/bin/env python
|
||||||
## -*- coding: utf-8 -*-
|
## -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
|
#from __future__ import print_function
|
||||||
#import sys
|
#import sys
|
||||||
#import os
|
#import os
|
||||||
#import time
|
#import time
|
||||||
@ -2504,12 +2511,12 @@
|
|||||||
# if True == print_when_succ:
|
# if True == print_when_succ:
|
||||||
# logging.info('succeed to execute sql: %s, rowcount = %d', sql, rowcount)
|
# logging.info('succeed to execute sql: %s, rowcount = %d', sql, rowcount)
|
||||||
# return 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)
|
# logging.exception('mysql connector error, fail to execute sql: %s', sql)
|
||||||
# raise e
|
# raise
|
||||||
# except Exception, e:
|
# except Exception as e:
|
||||||
# logging.exception('normal error, fail to execute sql: %s', sql)
|
# logging.exception('normal error, fail to execute sql: %s', sql)
|
||||||
# raise e
|
# raise
|
||||||
# def exec_query(self, sql, print_when_succ = True):
|
# def exec_query(self, sql, print_when_succ = True):
|
||||||
# try:
|
# try:
|
||||||
# self.__cursor.execute(sql)
|
# self.__cursor.execute(sql)
|
||||||
@ -2518,12 +2525,12 @@
|
|||||||
# if True == print_when_succ:
|
# if True == print_when_succ:
|
||||||
# logging.info('succeed to execute query: %s, rowcount = %d', sql, rowcount)
|
# logging.info('succeed to execute query: %s, rowcount = %d', sql, rowcount)
|
||||||
# return (self.__cursor.description, results)
|
# 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)
|
# logging.exception('mysql connector error, fail to execute sql: %s', sql)
|
||||||
# raise e
|
# raise
|
||||||
# except Exception, e:
|
# except Exception as e:
|
||||||
# logging.exception('normal error, fail to execute sql: %s', sql)
|
# logging.exception('normal error, fail to execute sql: %s', sql)
|
||||||
# raise e
|
# raise
|
||||||
##### ---------------end----------------------
|
##### ---------------end----------------------
|
||||||
#
|
#
|
||||||
##### --------------start : opt.py --------------
|
##### --------------start : opt.py --------------
|
||||||
@ -2663,10 +2670,10 @@
|
|||||||
#def deal_with_local_opt(opt):
|
#def deal_with_local_opt(opt):
|
||||||
# if 'help' == opt.get_long_name():
|
# if 'help' == opt.get_long_name():
|
||||||
# global help_str
|
# global help_str
|
||||||
# print help_str
|
# print(help_str)
|
||||||
# elif 'version' == opt.get_long_name():
|
# elif 'version' == opt.get_long_name():
|
||||||
# global version_str
|
# global version_str
|
||||||
# print version_str
|
# print(version_str)
|
||||||
#
|
#
|
||||||
#def deal_with_local_opts():
|
#def deal_with_local_opts():
|
||||||
# global g_opts
|
# global g_opts
|
||||||
@ -2767,9 +2774,9 @@
|
|||||||
# for r in results:
|
# for r in results:
|
||||||
# tenant_id_list.append(r[0])
|
# tenant_id_list.append(r[0])
|
||||||
# return tenant_id_list
|
# return tenant_id_list
|
||||||
# except Exception, e:
|
# except Exception as e:
|
||||||
# logging.exception('fail to fetch distinct tenant ids')
|
# 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):
|
#def set_default_timeout_by_tenant(query_cur, timeout, timeout_per_tenant, min_timeout):
|
||||||
# if timeout > 0:
|
# if timeout > 0:
|
||||||
@ -2853,7 +2860,7 @@
|
|||||||
# times -= 1
|
# times -= 1
|
||||||
# if times == -1:
|
# if times == -1:
|
||||||
# logging.warn("""check {0} job timeout""".format(job_name))
|
# logging.warn("""check {0} job timeout""".format(job_name))
|
||||||
# raise e
|
# raise MyError("""check {0} job timeout""".format(job_name))
|
||||||
# time.sleep(10)
|
# time.sleep(10)
|
||||||
#
|
#
|
||||||
## 开始健康检查
|
## 开始健康检查
|
||||||
@ -2876,18 +2883,18 @@
|
|||||||
# check_server_version_by_zone(query_cur, zone)
|
# check_server_version_by_zone(query_cur, zone)
|
||||||
# if True == need_check_major_status:
|
# if True == need_check_major_status:
|
||||||
# check_major_merge(query_cur, timeout)
|
# check_major_merge(query_cur, timeout)
|
||||||
# except Exception, e:
|
# except Exception as e:
|
||||||
# logging.exception('run error')
|
# logging.exception('run error')
|
||||||
# raise e
|
# raise
|
||||||
# finally:
|
# finally:
|
||||||
# cur.close()
|
# cur.close()
|
||||||
# conn.close()
|
# conn.close()
|
||||||
# except mysql.connector.Error, e:
|
# except mysql.connector.Error as e:
|
||||||
# logging.exception('connection error')
|
# logging.exception('connection error')
|
||||||
# raise e
|
# raise
|
||||||
# except Exception, e:
|
# except Exception as e:
|
||||||
# logging.exception('normal error')
|
# logging.exception('normal error')
|
||||||
# raise e
|
# raise
|
||||||
#
|
#
|
||||||
#if __name__ == '__main__':
|
#if __name__ == '__main__':
|
||||||
# upgrade_params = UpgradeParams()
|
# 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\"', \
|
# 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)
|
# 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
|
# 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')
|
# logging.exception('mysql connctor error')
|
||||||
# raise e
|
# raise
|
||||||
# except Exception, e:
|
# except Exception as e:
|
||||||
# logging.exception('normal error')
|
# logging.exception('normal error')
|
||||||
# raise e
|
# raise
|
||||||
#
|
#
|
||||||
####====XXXX======######==== I am a splitter ====######======XXXX====####
|
####====XXXX======######==== I am a splitter ====######======XXXX====####
|
||||||
#filename:upgrade_post_checker.py
|
#filename:upgrade_post_checker.py
|
||||||
##!/usr/bin/env python
|
##!/usr/bin/env python
|
||||||
## -*- coding: utf-8 -*-
|
## -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
|
#from my_error import MyError
|
||||||
#import sys
|
#import sys
|
||||||
#import os
|
#import os
|
||||||
#import time
|
#import time
|
||||||
@ -2946,7 +2954,7 @@
|
|||||||
# (desc, results) = query_cur.exec_query(sql)
|
# (desc, results) = query_cur.exec_query(sql)
|
||||||
# if len(results) == 0:
|
# if len(results) == 0:
|
||||||
# logging.warn('result cnt not match')
|
# logging.warn('result cnt not match')
|
||||||
# raise e
|
# raise MyError('result cnt not match')
|
||||||
# tenant_count = len(results)
|
# tenant_count = len(results)
|
||||||
# tenant_ids_str = ''
|
# tenant_ids_str = ''
|
||||||
# for index, row in enumerate(results):
|
# for index, row in enumerate(results):
|
||||||
@ -2957,7 +2965,7 @@
|
|||||||
# (desc, results) = query_cur.exec_query(sql)
|
# (desc, results) = query_cur.exec_query(sql)
|
||||||
# if len(results) != 1 or len(results[0]) != 1:
|
# if len(results) != 1 or len(results[0]) != 1:
|
||||||
# logging.warn('result cnt not match')
|
# logging.warn('result cnt not match')
|
||||||
# raise e
|
# raise MyError('result cnt not match')
|
||||||
# server_count = results[0][0]
|
# server_count = results[0][0]
|
||||||
#
|
#
|
||||||
# # check compatible sync
|
# # check compatible sync
|
||||||
@ -2977,7 +2985,7 @@
|
|||||||
# result = cur.fetchall()
|
# result = cur.fetchall()
|
||||||
# if len(result) != 1 or len(result[0]) != 1:
|
# if len(result) != 1 or len(result[0]) != 1:
|
||||||
# logging.exception('result cnt not match')
|
# logging.exception('result cnt not match')
|
||||||
# raise e
|
# raise MyError('result cnt not match')
|
||||||
# elif result[0][0] == parameter_count:
|
# elif result[0][0] == parameter_count:
|
||||||
# logging.info("""'compatible' is sync, value is {0}""".format(current_data_version))
|
# logging.info("""'compatible' is sync, value is {0}""".format(current_data_version))
|
||||||
# break
|
# break
|
||||||
@ -2987,7 +2995,7 @@
|
|||||||
# times -= 1
|
# times -= 1
|
||||||
# if times == -1:
|
# if times == -1:
|
||||||
# logging.exception("""check compatible:{0} sync timeout""".format(current_data_version))
|
# 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)
|
# time.sleep(5)
|
||||||
#
|
#
|
||||||
# actions.set_session_timeout(cur, 10)
|
# actions.set_session_timeout(cur, 10)
|
||||||
@ -2998,10 +3006,10 @@
|
|||||||
# (desc, results) = query_cur.exec_query(sql)
|
# (desc, results) = query_cur.exec_query(sql)
|
||||||
# if len(results) != 1 or len(results[0]) != 1:
|
# if len(results) != 1 or len(results[0]) != 1:
|
||||||
# logging.warn('result cnt not match')
|
# logging.warn('result cnt not match')
|
||||||
# raise e
|
# raise MyError('result cnt not match')
|
||||||
# elif 2 * tenant_count != results[0][0]:
|
# 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]))
|
# 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:
|
# else:
|
||||||
# logging.info("all tenant's target_data_version/current_data_version are match with {0}".format(current_data_version))
|
# 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:
|
# if times == -1:
|
||||||
# logging.warn('check root inspection failed!')
|
# logging.warn('check root inspection failed!')
|
||||||
# raise e
|
# raise MyError('check root inspection failed!')
|
||||||
# logging.info('check root inspection success')
|
# logging.info('check root inspection success')
|
||||||
#
|
#
|
||||||
## 4 开ddl
|
## 4 开ddl
|
||||||
@ -3053,13 +3061,14 @@
|
|||||||
# enable_rebalance(cur, timeout)
|
# enable_rebalance(cur, timeout)
|
||||||
# enable_rereplication(cur, timeout)
|
# enable_rereplication(cur, timeout)
|
||||||
# enable_major_freeze(cur, timeout)
|
# enable_major_freeze(cur, timeout)
|
||||||
# except Exception, e:
|
# except Exception as e:
|
||||||
# logging.exception('run error')
|
# logging.exception('run error')
|
||||||
# raise e
|
# raise
|
||||||
####====XXXX======######==== I am a splitter ====######======XXXX====####
|
####====XXXX======######==== I am a splitter ====######======XXXX====####
|
||||||
#sub file module end
|
#sub file module end
|
||||||
|
|
||||||
|
|
||||||
|
from __future__ import print_function, absolute_import
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import datetime
|
import datetime
|
||||||
@ -3115,7 +3124,7 @@ def split_py_files(sub_files_dir):
|
|||||||
if i >= cur_file_lines_count:
|
if i >= cur_file_lines_count:
|
||||||
raise SplitError('invalid line index:' + str(i) + ', lines_count:' + str(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]:
|
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
|
break
|
||||||
else:
|
else:
|
||||||
mark_idx = cur_file_lines[i].find(sub_filename_line_prefix)
|
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_dir = cur_file_short_name + sub_files_dir_suffix
|
||||||
sub_files_short_dir = cur_file_real_name + sub_files_dir_suffix
|
sub_files_short_dir = cur_file_real_name + sub_files_dir_suffix
|
||||||
split_py_files(sub_files_dir)
|
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:])
|
do_upgrade_by_argv(sys.argv[1:])
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from my_error import MyError
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
@ -24,7 +25,7 @@ def check_data_version(cur, query_cur, timeout):
|
|||||||
(desc, results) = query_cur.exec_query(sql)
|
(desc, results) = query_cur.exec_query(sql)
|
||||||
if len(results) == 0:
|
if len(results) == 0:
|
||||||
logging.warn('result cnt not match')
|
logging.warn('result cnt not match')
|
||||||
raise e
|
raise MyError('result cnt not match')
|
||||||
tenant_count = len(results)
|
tenant_count = len(results)
|
||||||
tenant_ids_str = ''
|
tenant_ids_str = ''
|
||||||
for index, row in enumerate(results):
|
for index, row in enumerate(results):
|
||||||
@ -35,7 +36,7 @@ def check_data_version(cur, query_cur, timeout):
|
|||||||
(desc, results) = query_cur.exec_query(sql)
|
(desc, results) = query_cur.exec_query(sql)
|
||||||
if len(results) != 1 or len(results[0]) != 1:
|
if len(results) != 1 or len(results[0]) != 1:
|
||||||
logging.warn('result cnt not match')
|
logging.warn('result cnt not match')
|
||||||
raise e
|
raise MyError('result cnt not match')
|
||||||
server_count = results[0][0]
|
server_count = results[0][0]
|
||||||
|
|
||||||
# check compatible sync
|
# check compatible sync
|
||||||
@ -55,7 +56,7 @@ def check_data_version(cur, query_cur, timeout):
|
|||||||
result = cur.fetchall()
|
result = cur.fetchall()
|
||||||
if len(result) != 1 or len(result[0]) != 1:
|
if len(result) != 1 or len(result[0]) != 1:
|
||||||
logging.exception('result cnt not match')
|
logging.exception('result cnt not match')
|
||||||
raise e
|
raise MyError('result cnt not match')
|
||||||
elif result[0][0] == parameter_count:
|
elif result[0][0] == parameter_count:
|
||||||
logging.info("""'compatible' is sync, value is {0}""".format(current_data_version))
|
logging.info("""'compatible' is sync, value is {0}""".format(current_data_version))
|
||||||
break
|
break
|
||||||
@ -65,7 +66,7 @@ def check_data_version(cur, query_cur, timeout):
|
|||||||
times -= 1
|
times -= 1
|
||||||
if times == -1:
|
if times == -1:
|
||||||
logging.exception("""check compatible:{0} sync timeout""".format(current_data_version))
|
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)
|
time.sleep(5)
|
||||||
|
|
||||||
actions.set_session_timeout(cur, 10)
|
actions.set_session_timeout(cur, 10)
|
||||||
@ -76,10 +77,10 @@ def check_data_version(cur, query_cur, timeout):
|
|||||||
(desc, results) = query_cur.exec_query(sql)
|
(desc, results) = query_cur.exec_query(sql)
|
||||||
if len(results) != 1 or len(results[0]) != 1:
|
if len(results) != 1 or len(results[0]) != 1:
|
||||||
logging.warn('result cnt not match')
|
logging.warn('result cnt not match')
|
||||||
raise e
|
raise MyError('result cnt not match')
|
||||||
elif 2 * tenant_count != results[0][0]:
|
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]))
|
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:
|
else:
|
||||||
logging.info("all tenant's target_data_version/current_data_version are match with {0}".format(current_data_version))
|
logging.info("all tenant's target_data_version/current_data_version are match with {0}".format(current_data_version))
|
||||||
|
|
||||||
@ -99,7 +100,7 @@ def check_root_inspection(cur, query_cur, timeout):
|
|||||||
|
|
||||||
if times == -1:
|
if times == -1:
|
||||||
logging.warn('check root inspection failed!')
|
logging.warn('check root inspection failed!')
|
||||||
raise e
|
raise MyError('check root inspection failed!')
|
||||||
logging.info('check root inspection success')
|
logging.info('check root inspection success')
|
||||||
|
|
||||||
# 4 开ddl
|
# 4 开ddl
|
||||||
@ -131,6 +132,6 @@ def do_check(conn, cur, query_cur, timeout):
|
|||||||
enable_rebalance(cur, timeout)
|
enable_rebalance(cur, timeout)
|
||||||
enable_rereplication(cur, timeout)
|
enable_rereplication(cur, timeout)
|
||||||
enable_major_freeze(cur, timeout)
|
enable_major_freeze(cur, timeout)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.exception('run error')
|
logging.exception('run error')
|
||||||
raise e
|
raise
|
||||||
|
@ -121,10 +121,10 @@
|
|||||||
# results = cur.fetchall()
|
# results = cur.fetchall()
|
||||||
# if len(results) != 1:
|
# if len(results) != 1:
|
||||||
# logging.exception('min_observer_version is not sync')
|
# logging.exception('min_observer_version is not sync')
|
||||||
# raise e
|
# raise MyError('min_observer_version is not sync')
|
||||||
# elif len(results[0]) != 1:
|
# elif len(results[0]) != 1:
|
||||||
# logging.exception('column cnt not match')
|
# logging.exception('column cnt not match')
|
||||||
# raise e
|
# raise MyError('column cnt not match')
|
||||||
# else:
|
# else:
|
||||||
# min_cluster_version = get_version(results[0][0])
|
# min_cluster_version = get_version(results[0][0])
|
||||||
# return min_cluster_version
|
# return min_cluster_version
|
||||||
@ -197,17 +197,17 @@
|
|||||||
# ori_value = 'True'
|
# ori_value = 'True'
|
||||||
# elif len(result) != 1 or len(result[0]) != 1:
|
# elif len(result) != 1 or len(result[0]) != 1:
|
||||||
# logging.exception('result cnt not match')
|
# 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']:
|
# elif result[0][0].lower() in ["1", "true", "on", "yes", 't']:
|
||||||
# ori_value = 'True'
|
# ori_value = 'True'
|
||||||
# elif result[0][0].lower() in ["0", "false", "off", "no", 'f']:
|
# elif result[0][0].lower() in ["0", "false", "off", "no", 'f']:
|
||||||
# ori_value = 'False'
|
# ori_value = 'False'
|
||||||
# else:
|
# else:
|
||||||
# logging.exception("""result value is invalid, result:{0}""".format(result[0][0]))
|
# 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
|
# return ori_value
|
||||||
#
|
#
|
||||||
## print version like "x.x.x.x"
|
## print(version like "x.x.x.x")
|
||||||
#def print_version(version):
|
#def print_version(version):
|
||||||
# version = int(version)
|
# version = int(version)
|
||||||
# major = (version >> 32) & 0xffffffff
|
# major = (version >> 32) & 0xffffffff
|
||||||
@ -222,7 +222,7 @@
|
|||||||
#
|
#
|
||||||
# if len(versions) != 4:
|
# if len(versions) != 4:
|
||||||
# logging.exception("""version:{0} is invalid""".format(version_str))
|
# logging.exception("""version:{0} is invalid""".format(version_str))
|
||||||
# raise e
|
# raise MyError("""version:{0} is invalid""".format(version_str))
|
||||||
#
|
#
|
||||||
# major = int(versions[0])
|
# major = int(versions[0])
|
||||||
# minor = int(versions[1])
|
# minor = int(versions[1])
|
||||||
@ -231,7 +231,7 @@
|
|||||||
#
|
#
|
||||||
# if major > 0xffffffff or minor > 0xffff or major_patch > 0xff or minor_patch > 0xff:
|
# if major > 0xffffffff or minor > 0xffff or major_patch > 0xff or minor_patch > 0xff:
|
||||||
# logging.exception("""version:{0} is invalid""".format(version_str))
|
# 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)
|
# version = (major << 32) | (minor << 16) | (major_patch << 8) | (minor_patch)
|
||||||
# return version
|
# return version
|
||||||
@ -285,7 +285,7 @@
|
|||||||
# result = cur.fetchall()
|
# result = cur.fetchall()
|
||||||
# if len(result) != 1 or len(result[0]) != 1:
|
# if len(result) != 1 or len(result[0]) != 1:
|
||||||
# logging.exception('result cnt not match')
|
# logging.exception('result cnt not match')
|
||||||
# raise e
|
# raise MyError('result cnt not match')
|
||||||
# elif result[0][0] == 0:
|
# elif result[0][0] == 0:
|
||||||
# logging.info("""{0} is sync, value is {1}""".format(key, value))
|
# logging.info("""{0} is sync, value is {1}""".format(key, value))
|
||||||
# break
|
# break
|
||||||
@ -295,7 +295,7 @@
|
|||||||
# times -= 1
|
# times -= 1
|
||||||
# if times == -1:
|
# if times == -1:
|
||||||
# logging.exception("""check {0}:{1} sync timeout""".format(key, value))
|
# 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)
|
# time.sleep(5)
|
||||||
#
|
#
|
||||||
# set_session_timeout(cur, 10)
|
# set_session_timeout(cur, 10)
|
||||||
@ -414,12 +414,12 @@
|
|||||||
# if True == print_when_succ:
|
# if True == print_when_succ:
|
||||||
# logging.info('succeed to execute sql: %s, rowcount = %d', sql, rowcount)
|
# logging.info('succeed to execute sql: %s, rowcount = %d', sql, rowcount)
|
||||||
# return 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)
|
# logging.exception('mysql connector error, fail to execute sql: %s', sql)
|
||||||
# raise e
|
# raise
|
||||||
# except Exception, e:
|
# except Exception as e:
|
||||||
# logging.exception('normal error, fail to execute sql: %s', sql)
|
# logging.exception('normal error, fail to execute sql: %s', sql)
|
||||||
# raise e
|
# raise
|
||||||
# def exec_query(self, sql, print_when_succ = True):
|
# def exec_query(self, sql, print_when_succ = True):
|
||||||
# try:
|
# try:
|
||||||
# self.__cursor.execute(sql)
|
# self.__cursor.execute(sql)
|
||||||
@ -428,12 +428,12 @@
|
|||||||
# if True == print_when_succ:
|
# if True == print_when_succ:
|
||||||
# logging.info('succeed to execute query: %s, rowcount = %d', sql, rowcount)
|
# logging.info('succeed to execute query: %s, rowcount = %d', sql, rowcount)
|
||||||
# return (self.__cursor.description, results)
|
# 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)
|
# logging.exception('mysql connector error, fail to execute sql: %s', sql)
|
||||||
# raise e
|
# raise
|
||||||
# except Exception, e:
|
# except Exception as e:
|
||||||
# logging.exception('normal error, fail to execute sql: %s', sql)
|
# logging.exception('normal error, fail to execute sql: %s', sql)
|
||||||
# raise e
|
# raise
|
||||||
#
|
#
|
||||||
#class DDLCursor:
|
#class DDLCursor:
|
||||||
# _cursor = None
|
# _cursor = None
|
||||||
@ -444,9 +444,9 @@
|
|||||||
# # 这里检查是不是ddl,不是ddl就抛错
|
# # 这里检查是不是ddl,不是ddl就抛错
|
||||||
# check_is_ddl_sql(sql)
|
# check_is_ddl_sql(sql)
|
||||||
# return self._cursor.exec_sql(sql, print_when_succ)
|
# return self._cursor.exec_sql(sql, print_when_succ)
|
||||||
# except Exception, e:
|
# except Exception as e:
|
||||||
# logging.exception('fail to execute ddl: %s', sql)
|
# logging.exception('fail to execute ddl: %s', sql)
|
||||||
# raise e
|
# raise
|
||||||
#
|
#
|
||||||
#class QueryCursor:
|
#class QueryCursor:
|
||||||
# _cursor = None
|
# _cursor = None
|
||||||
@ -457,9 +457,9 @@
|
|||||||
# # 这里检查是不是query,不是query就抛错
|
# # 这里检查是不是query,不是query就抛错
|
||||||
# check_is_query_sql(sql)
|
# check_is_query_sql(sql)
|
||||||
# return self._cursor.exec_query(sql, print_when_succ)
|
# 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)
|
# logging.exception('fail to execute dml query: %s', sql)
|
||||||
# raise e
|
# raise
|
||||||
#
|
#
|
||||||
#class DMLCursor(QueryCursor):
|
#class DMLCursor(QueryCursor):
|
||||||
# def exec_update(self, sql, print_when_succ = True):
|
# def exec_update(self, sql, print_when_succ = True):
|
||||||
@ -467,9 +467,9 @@
|
|||||||
# # 这里检查是不是update,不是update就抛错
|
# # 这里检查是不是update,不是update就抛错
|
||||||
# check_is_update_sql(sql)
|
# check_is_update_sql(sql)
|
||||||
# return self._cursor.exec_sql(sql, print_when_succ)
|
# 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)
|
# logging.exception('fail to execute dml update: %s', sql)
|
||||||
# raise e
|
# raise
|
||||||
#
|
#
|
||||||
#class BaseDDLAction():
|
#class BaseDDLAction():
|
||||||
# __ddl_cursor = None
|
# __ddl_cursor = None
|
||||||
@ -579,9 +579,9 @@
|
|||||||
# for r in results:
|
# for r in results:
|
||||||
# tenant_id_list.append(r[0])
|
# tenant_id_list.append(r[0])
|
||||||
# return tenant_id_list
|
# return tenant_id_list
|
||||||
# except Exception, e:
|
# except Exception as e:
|
||||||
# logging.exception('fail to fetch distinct tenant ids')
|
# logging.exception('fail to fetch distinct tenant ids')
|
||||||
# raise e
|
# raise
|
||||||
#
|
#
|
||||||
####====XXXX======######==== I am a splitter ====######======XXXX====####
|
####====XXXX======######==== I am a splitter ====######======XXXX====####
|
||||||
#filename:config.py
|
#filename:config.py
|
||||||
@ -706,9 +706,9 @@
|
|||||||
# actions.refresh_commit_sql_list()
|
# actions.refresh_commit_sql_list()
|
||||||
# logging.info('================succeed to run post check action ===============')
|
# logging.info('================succeed to run post check action ===============')
|
||||||
#
|
#
|
||||||
# except Exception, e:
|
# except Exception as e:
|
||||||
# logging.exception('run error')
|
# logging.exception('run error')
|
||||||
# raise e
|
# raise
|
||||||
# finally:
|
# finally:
|
||||||
# # 打印统计信息
|
# # 打印统计信息
|
||||||
# print_stats()
|
# print_stats()
|
||||||
@ -716,12 +716,12 @@
|
|||||||
# # actions.dump_rollback_sql_to_file(upgrade_params.rollback_sql_filename)
|
# # actions.dump_rollback_sql_to_file(upgrade_params.rollback_sql_filename)
|
||||||
# cur.close()
|
# cur.close()
|
||||||
# conn.close()
|
# conn.close()
|
||||||
# except mysql.connector.Error, e:
|
# except mysql.connector.Error as e:
|
||||||
# logging.exception('connection error')
|
# logging.exception('connection error')
|
||||||
# raise e
|
# raise
|
||||||
# except Exception, e:
|
# except Exception as e:
|
||||||
# logging.exception('normal error')
|
# logging.exception('normal error')
|
||||||
# raise e
|
# raise
|
||||||
#
|
#
|
||||||
#def do_upgrade_by_argv(argv):
|
#def do_upgrade_by_argv(argv):
|
||||||
# upgrade_params = UpgradeParams()
|
# 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\"',\
|
# 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)
|
# host, port, user, password.replace('"', '\\"'), timeout, module_set, log_filename)
|
||||||
# do_upgrade(host, port, user, password, timeout, module_set, upgrade_params)
|
# 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('mysql connctor error')
|
||||||
# logging.exception('run error, maybe you can reference ' + upgrade_params.rollback_sql_filename + ' to rollback it')
|
# logging.exception('run error, maybe you can reference ' + upgrade_params.rollback_sql_filename + ' to rollback it')
|
||||||
# raise e
|
# raise
|
||||||
# except Exception, e:
|
# except Exception as e:
|
||||||
# logging.exception('normal error')
|
# logging.exception('normal error')
|
||||||
# logging.exception('run error, maybe you can reference ' + upgrade_params.rollback_sql_filename + ' to rollback it')
|
# 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
|
# 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 ===============')
|
# logging.info('================succeed to run health check action ===============')
|
||||||
#
|
#
|
||||||
# except Exception, e:
|
# except Exception as e:
|
||||||
# logging.exception('run error')
|
# logging.exception('run error')
|
||||||
# raise e
|
# raise
|
||||||
# finally:
|
# finally:
|
||||||
# # 打印统计信息
|
# # 打印统计信息
|
||||||
# print_stats()
|
# print_stats()
|
||||||
@ -876,12 +876,12 @@
|
|||||||
# # actions.dump_rollback_sql_to_file(upgrade_params.rollback_sql_filename)
|
# # actions.dump_rollback_sql_to_file(upgrade_params.rollback_sql_filename)
|
||||||
# cur.close()
|
# cur.close()
|
||||||
# conn.close()
|
# conn.close()
|
||||||
# except mysql.connector.Error, e:
|
# except mysql.connector.Error as e:
|
||||||
# logging.exception('connection error')
|
# logging.exception('connection error')
|
||||||
# raise e
|
# raise
|
||||||
# except Exception, e:
|
# except Exception as e:
|
||||||
# logging.exception('normal error')
|
# logging.exception('normal error')
|
||||||
# raise e
|
# raise
|
||||||
#
|
#
|
||||||
#def do_upgrade_by_argv(argv):
|
#def do_upgrade_by_argv(argv):
|
||||||
# upgrade_params = UpgradeParams()
|
# 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\"',\
|
# 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)
|
# host, port, user, password.replace('"', '\\"'), timeout, module_set, log_filename)
|
||||||
# do_upgrade(host, port, user, password, timeout, module_set, upgrade_params)
|
# 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('mysql connctor error')
|
||||||
# logging.exception('run error, maybe you can reference ' + upgrade_params.rollback_sql_filename + ' to rollback it')
|
# logging.exception('run error, maybe you can reference ' + upgrade_params.rollback_sql_filename + ' to rollback it')
|
||||||
# raise e
|
# raise
|
||||||
# except Exception, e:
|
# except Exception as e:
|
||||||
# logging.exception('normal error')
|
# logging.exception('normal error')
|
||||||
# logging.exception('run error, maybe you can reference ' + upgrade_params.rollback_sql_filename + ' to rollback it')
|
# 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 'help' == opt.get_long_name():
|
||||||
# if 'upgrade_pre' == filename:
|
# if 'upgrade_pre' == filename:
|
||||||
# global pre_help_str
|
# global pre_help_str
|
||||||
# print pre_help_str
|
# print(pre_help_str)
|
||||||
# elif 'upgrade_post' == filename:
|
# elif 'upgrade_post' == filename:
|
||||||
# global post_help_str
|
# global post_help_str
|
||||||
# print post_help_str
|
# print(post_help_str)
|
||||||
# else:
|
# else:
|
||||||
# raise MyError('not supported filename:{0} for help option'.format(filename))
|
# raise MyError('not supported filename:{0} for help option'.format(filename))
|
||||||
# elif 'version' == opt.get_long_name():
|
# elif 'version' == opt.get_long_name():
|
||||||
# global version_str
|
# global version_str
|
||||||
# print version_str
|
# print(version_str)
|
||||||
#
|
#
|
||||||
#def deal_with_local_opts(filename):
|
#def deal_with_local_opts(filename):
|
||||||
# global g_opts
|
# global g_opts
|
||||||
@ -1395,6 +1395,7 @@
|
|||||||
##!/usr/bin/env python
|
##!/usr/bin/env python
|
||||||
## -*- coding: utf-8 -*-
|
## -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
|
#from my_error import MyError
|
||||||
#import logging
|
#import logging
|
||||||
#import time
|
#import time
|
||||||
#from actions import Cursor
|
#from actions import Cursor
|
||||||
@ -1431,9 +1432,9 @@
|
|||||||
# info_cnt = result[0][0]
|
# info_cnt = result[0][0]
|
||||||
# if info_cnt > 0:
|
# if info_cnt > 0:
|
||||||
# actions.set_parameter(cur, "syslog_level", "WDIAG")
|
# actions.set_parameter(cur, "syslog_level", "WDIAG")
|
||||||
# except Exception, e:
|
# except Exception as e:
|
||||||
# logging.warn("upgrade syslog level failed!")
|
# logging.warn("upgrade syslog level failed!")
|
||||||
# raise e
|
# raise
|
||||||
#####========******####========= actions end =========####******========####
|
#####========******####========= actions end =========####******========####
|
||||||
#
|
#
|
||||||
#def query(cur, sql):
|
#def query(cur, sql):
|
||||||
@ -1469,7 +1470,7 @@
|
|||||||
# results = query(cur, sql)
|
# results = query(cur, sql)
|
||||||
# if len(results) < 1 or len(results[0]) < 1:
|
# if len(results) < 1 or len(results[0]) < 1:
|
||||||
# logging.warn("row/column cnt not match")
|
# logging.warn("row/column cnt not match")
|
||||||
# raise e
|
# raise MyError("row/column cnt not match")
|
||||||
# elif results[0][0] <= 0:
|
# elif results[0][0] <= 0:
|
||||||
# # __all_virtual_core_table doesn't exist, this cluster is upgraded from 4.0.0.0
|
# # __all_virtual_core_table doesn't exist, this cluster is upgraded from 4.0.0.0
|
||||||
# across_version = True
|
# across_version = True
|
||||||
@ -1478,14 +1479,14 @@
|
|||||||
# tenant_ids = get_tenant_ids(cur)
|
# tenant_ids = get_tenant_ids(cur)
|
||||||
# if len(tenant_ids) <= 0:
|
# if len(tenant_ids) <= 0:
|
||||||
# logging.warn("tenant_ids count is unexpected")
|
# logging.warn("tenant_ids count is unexpected")
|
||||||
# raise e
|
# raise MyError("tenant_ids count is unexpected")
|
||||||
# tenant_count = len(tenant_ids)
|
# 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)
|
# 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)
|
# results = query(cur, sql)
|
||||||
# if len(results) != 1 or len(results[0]) != 1:
|
# if len(results) != 1 or len(results[0]) != 1:
|
||||||
# logging.warn('result cnt not match')
|
# logging.warn('result cnt not match')
|
||||||
# raise e
|
# raise MyError('result cnt not match')
|
||||||
# elif 2 * tenant_count != results[0][0]:
|
# 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]))
|
# 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
|
# across_version = True
|
||||||
@ -1499,7 +1500,7 @@
|
|||||||
# results = query(cur, sql)
|
# results = query(cur, sql)
|
||||||
# if len(results) < 1 or len(results[0]) < 1:
|
# if len(results) < 1 or len(results[0]) < 1:
|
||||||
# logging.warn("row/column cnt not match")
|
# logging.warn("row/column cnt not match")
|
||||||
# raise e
|
# raise MyError("row/column cnt not match")
|
||||||
# elif results[0][0] == 0:
|
# elif results[0][0] == 0:
|
||||||
# logging.info("compatible are all matched")
|
# logging.info("compatible are all matched")
|
||||||
# else:
|
# else:
|
||||||
@ -1518,16 +1519,16 @@
|
|||||||
# max_job_id = 0
|
# max_job_id = 0
|
||||||
# elif (len(results) != 1 or len(results[0]) != 1):
|
# elif (len(results) != 1 or len(results[0]) != 1):
|
||||||
# logging.warn("row cnt not match")
|
# logging.warn("row cnt not match")
|
||||||
# raise e
|
# raise MyError("row cnt not match")
|
||||||
# else:
|
# else:
|
||||||
# max_job_id = results[0][0]
|
# max_job_id = results[0][0]
|
||||||
#
|
#
|
||||||
# logging.info("get max_used_job_id:{0}".format(max_job_id))
|
# logging.info("get max_used_job_id:{0}".format(max_job_id))
|
||||||
#
|
#
|
||||||
# return max_job_id
|
# return max_job_id
|
||||||
# except Exception, e:
|
# except Exception as e:
|
||||||
# logging.warn("failed to get max_used_job_id")
|
# logging.warn("failed to get max_used_job_id")
|
||||||
# raise e
|
# raise
|
||||||
#
|
#
|
||||||
#def check_can_run_upgrade_job(cur, job_name):
|
#def check_can_run_upgrade_job(cur, job_name):
|
||||||
# try:
|
# try:
|
||||||
@ -1541,10 +1542,10 @@
|
|||||||
# logging.info("upgrade job not created yet, should run upgrade job")
|
# logging.info("upgrade job not created yet, should run upgrade job")
|
||||||
# elif (len(results) != 1 or len(results[0]) != 1):
|
# elif (len(results) != 1 or len(results[0]) != 1):
|
||||||
# logging.warn("row cnt not match")
|
# logging.warn("row cnt not match")
|
||||||
# raise e
|
# raise MyError("row cnt not match")
|
||||||
# elif ("INPROGRESS" == results[0][0]):
|
# elif ("INPROGRESS" == results[0][0]):
|
||||||
# logging.warn("upgrade job still running, should wait")
|
# logging.warn("upgrade job still running, should wait")
|
||||||
# raise e
|
# raise MyError("upgrade job still running, should wait")
|
||||||
# elif ("SUCCESS" == results[0][0]):
|
# elif ("SUCCESS" == results[0][0]):
|
||||||
# bret = True
|
# bret = True
|
||||||
# logging.info("maybe upgrade job remained, can run again")
|
# logging.info("maybe upgrade job remained, can run again")
|
||||||
@ -1553,12 +1554,12 @@
|
|||||||
# logging.info("execute upgrade job failed, should run again")
|
# logging.info("execute upgrade job failed, should run again")
|
||||||
# else:
|
# else:
|
||||||
# logging.warn("invalid job status: {0}".format(results[0][0]))
|
# logging.warn("invalid job status: {0}".format(results[0][0]))
|
||||||
# raise e
|
# raise MyError("invalid job status: {0}".format(results[0][0]))
|
||||||
#
|
#
|
||||||
# return bret
|
# return bret
|
||||||
# except Exception, e:
|
# except Exception as e:
|
||||||
# logging.warn("failed to check if upgrade job can run")
|
# 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):
|
#def check_upgrade_job_result(cur, job_name, timeout, max_used_job_id):
|
||||||
# try:
|
# try:
|
||||||
@ -1575,7 +1576,7 @@
|
|||||||
# logging.info("upgrade job not created yet")
|
# logging.info("upgrade job not created yet")
|
||||||
# elif (len(results) != 1 or len(results[0]) != 4):
|
# elif (len(results) != 1 or len(results[0]) != 4):
|
||||||
# logging.warn("row cnt not match")
|
# logging.warn("row cnt not match")
|
||||||
# raise e
|
# raise MyError("row cnt not match")
|
||||||
# elif ("INPROGRESS" == results[0][0]):
|
# elif ("INPROGRESS" == results[0][0]):
|
||||||
# logging.info("upgrade job is still running")
|
# logging.info("upgrade job is still running")
|
||||||
# # check if rs change
|
# # check if rs change
|
||||||
@ -1587,39 +1588,39 @@
|
|||||||
# results = query(cur, sql)
|
# results = query(cur, sql)
|
||||||
# if (len(results) != 1 or len(results[0]) != 1):
|
# if (len(results) != 1 or len(results[0]) != 1):
|
||||||
# logging.warn("row/column cnt not match")
|
# logging.warn("row/column cnt not match")
|
||||||
# raise e
|
# raise MyError("row/column cnt not match")
|
||||||
# elif results[0][0] == 1:
|
# 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)
|
# sql = """select count(*) from oceanbase.__all_rootservice_event_history where gmt_create > '{0}' and event = 'full_rootservice'""".format(gmt_create)
|
||||||
# results = query(cur, sql)
|
# results = query(cur, sql)
|
||||||
# if (len(results) != 1 or len(results[0]) != 1):
|
# if (len(results) != 1 or len(results[0]) != 1):
|
||||||
# logging.warn("row/column cnt not match")
|
# logging.warn("row/column cnt not match")
|
||||||
# raise e
|
# raise MyError("row/column cnt not match")
|
||||||
# elif results[0][0] > 0:
|
# elif results[0][0] > 0:
|
||||||
# logging.warn("rs changed, should check if upgrade job is still running")
|
# 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:
|
# else:
|
||||||
# logging.info("rs[{0}:{1}] still exist, keep waiting".format(ip, port))
|
# logging.info("rs[{0}:{1}] still exist, keep waiting".format(ip, port))
|
||||||
# else:
|
# else:
|
||||||
# logging.warn("rs changed or not exist, should check if upgrade job is still running")
|
# 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]):
|
# elif ("SUCCESS" == results[0][0]):
|
||||||
# logging.info("execute upgrade job successfully")
|
# logging.info("execute upgrade job successfully")
|
||||||
# break;
|
# break;
|
||||||
# elif ("FAILED" == results[0][0]):
|
# elif ("FAILED" == results[0][0]):
|
||||||
# logging.warn("execute upgrade job failed")
|
# logging.warn("execute upgrade job failed")
|
||||||
# raise e
|
# raise MyError("execute upgrade job failed")
|
||||||
# else:
|
# else:
|
||||||
# logging.warn("invalid job status: {0}".format(results[0][0]))
|
# 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
|
# times = times - 1
|
||||||
# if times == -1:
|
# if times == -1:
|
||||||
# logging.warn("""check {0} job timeout""".format(job_name))
|
# logging.warn("""check {0} job timeout""".format(job_name))
|
||||||
# raise e
|
# raise MyError("""check {0} job timeout""".format(job_name))
|
||||||
# time.sleep(10)
|
# time.sleep(10)
|
||||||
# except Exception, e:
|
# except Exception as e:
|
||||||
# logging.warn("failed to check upgrade job result")
|
# logging.warn("failed to check upgrade job result")
|
||||||
# raise e
|
# raise
|
||||||
#
|
#
|
||||||
#def run_upgrade_job(conn, cur, job_name, timeout):
|
#def run_upgrade_job(conn, cur, job_name, timeout):
|
||||||
# try:
|
# try:
|
||||||
@ -1646,15 +1647,16 @@
|
|||||||
# # reset enable_ddl
|
# # reset enable_ddl
|
||||||
# if ori_enable_ddl == 0:
|
# if ori_enable_ddl == 0:
|
||||||
# actions.set_parameter(cur, 'enable_ddl', 'False', timeout)
|
# 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))
|
# 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))
|
# logging.info("run upgrade job success, job_name:{0}".format(job_name))
|
||||||
####====XXXX======######==== I am a splitter ====######======XXXX====####
|
####====XXXX======######==== I am a splitter ====######======XXXX====####
|
||||||
#filename:upgrade_checker.py
|
#filename:upgrade_checker.py
|
||||||
##!/usr/bin/env python
|
##!/usr/bin/env python
|
||||||
## -*- coding: utf-8 -*-
|
## -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
|
#from __future__ import print_function
|
||||||
#import sys
|
#import sys
|
||||||
#import os
|
#import os
|
||||||
#import mysql.connector
|
#import mysql.connector
|
||||||
@ -1664,6 +1666,10 @@
|
|||||||
#import time
|
#import time
|
||||||
#import re
|
#import re
|
||||||
#
|
#
|
||||||
|
#if sys.version_info.major == 3:
|
||||||
|
# def cmp(a, b):
|
||||||
|
# return (a > b) - (a < b)
|
||||||
|
#
|
||||||
#class UpgradeParams:
|
#class UpgradeParams:
|
||||||
# log_filename = 'upgrade_checker.log'
|
# log_filename = 'upgrade_checker.log'
|
||||||
# old_version = '4.0.0.0'
|
# old_version = '4.0.0.0'
|
||||||
@ -1691,12 +1697,12 @@
|
|||||||
# if True == print_when_succ:
|
# if True == print_when_succ:
|
||||||
# logging.info('succeed to execute sql: %s, rowcount = %d', sql, rowcount)
|
# logging.info('succeed to execute sql: %s, rowcount = %d', sql, rowcount)
|
||||||
# return 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)
|
# logging.exception('mysql connector error, fail to execute sql: %s', sql)
|
||||||
# raise e
|
# raise
|
||||||
# except Exception, e:
|
# except Exception as e:
|
||||||
# logging.exception('normal error, fail to execute sql: %s', sql)
|
# logging.exception('normal error, fail to execute sql: %s', sql)
|
||||||
# raise e
|
# raise
|
||||||
# def exec_query(self, sql, print_when_succ = True):
|
# def exec_query(self, sql, print_when_succ = True):
|
||||||
# try:
|
# try:
|
||||||
# self.__cursor.execute(sql)
|
# self.__cursor.execute(sql)
|
||||||
@ -1705,12 +1711,12 @@
|
|||||||
# if True == print_when_succ:
|
# if True == print_when_succ:
|
||||||
# logging.info('succeed to execute query: %s, rowcount = %d', sql, rowcount)
|
# logging.info('succeed to execute query: %s, rowcount = %d', sql, rowcount)
|
||||||
# return (self.__cursor.description, results)
|
# 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)
|
# logging.exception('mysql connector error, fail to execute sql: %s', sql)
|
||||||
# raise e
|
# raise
|
||||||
# except Exception, e:
|
# except Exception as e:
|
||||||
# logging.exception('normal error, fail to execute sql: %s', sql)
|
# logging.exception('normal error, fail to execute sql: %s', sql)
|
||||||
# raise e
|
# raise
|
||||||
#
|
#
|
||||||
#def set_parameter(cur, parameter, value):
|
#def set_parameter(cur, parameter, value):
|
||||||
# sql = """alter system set {0} = '{1}'""".format(parameter, value)
|
# sql = """alter system set {0} = '{1}'""".format(parameter, value)
|
||||||
@ -1728,7 +1734,7 @@
|
|||||||
# result = cur.fetchall()
|
# result = cur.fetchall()
|
||||||
# if len(result) != 1 or len(result[0]) != 1:
|
# if len(result) != 1 or len(result[0]) != 1:
|
||||||
# logging.exception('result cnt not match')
|
# logging.exception('result cnt not match')
|
||||||
# raise e
|
# raise MyError('result cnt not match')
|
||||||
# elif result[0][0] == 0:
|
# elif result[0][0] == 0:
|
||||||
# logging.info("""{0} is sync, value is {1}""".format(key, value))
|
# logging.info("""{0} is sync, value is {1}""".format(key, value))
|
||||||
# break
|
# break
|
||||||
@ -1738,7 +1744,7 @@
|
|||||||
# times -= 1
|
# times -= 1
|
||||||
# if times == 0:
|
# if times == 0:
|
||||||
# logging.exception("""check {0}:{1} sync timeout""".format(key, value))
|
# 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)
|
# time.sleep(5)
|
||||||
#
|
#
|
||||||
##### --------------start : opt.py --------------
|
##### --------------start : opt.py --------------
|
||||||
@ -1875,10 +1881,10 @@
|
|||||||
#def deal_with_local_opt(opt):
|
#def deal_with_local_opt(opt):
|
||||||
# if 'help' == opt.get_long_name():
|
# if 'help' == opt.get_long_name():
|
||||||
# global help_str
|
# global help_str
|
||||||
# print help_str
|
# print(help_str)
|
||||||
# elif 'version' == opt.get_long_name():
|
# elif 'version' == opt.get_long_name():
|
||||||
# global version_str
|
# global version_str
|
||||||
# print version_str
|
# print(version_str)
|
||||||
#
|
#
|
||||||
#def deal_with_local_opts():
|
#def deal_with_local_opts():
|
||||||
# global g_opts
|
# global g_opts
|
||||||
@ -1961,7 +1967,7 @@
|
|||||||
#
|
#
|
||||||
# if len(versions) != 4:
|
# if len(versions) != 4:
|
||||||
# logging.exception("""version:{0} is invalid""".format(version_str))
|
# logging.exception("""version:{0} is invalid""".format(version_str))
|
||||||
# raise e
|
# raise MyError("""version:{0} is invalid""".format(version_str))
|
||||||
#
|
#
|
||||||
# major = int(versions[0])
|
# major = int(versions[0])
|
||||||
# minor = int(versions[1])
|
# minor = int(versions[1])
|
||||||
@ -1970,7 +1976,7 @@
|
|||||||
#
|
#
|
||||||
# if major > 0xffffffff or minor > 0xffff or major_patch > 0xff or minor_patch > 0xff:
|
# if major > 0xffffffff or minor > 0xffff or major_patch > 0xff or minor_patch > 0xff:
|
||||||
# logging.exception("""version:{0} is invalid""".format(version_str))
|
# 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)
|
# version = (major << 32) | (minor << 16) | (major_patch << 8) | (minor_patch)
|
||||||
# return version
|
# return version
|
||||||
@ -1982,7 +1988,7 @@
|
|||||||
# if len(results) != 1:
|
# if len(results) != 1:
|
||||||
# fail_list.append('min_observer_version is not sync')
|
# fail_list.append('min_observer_version is not sync')
|
||||||
# elif cmp(results[0][0], upgrade_params.old_version) < 0 :
|
# 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]))
|
# logging.info('check observer version success, version = {0}'.format(results[0][0]))
|
||||||
#
|
#
|
||||||
#def check_data_version(query_cur):
|
#def check_data_version(query_cur):
|
||||||
@ -2423,18 +2429,18 @@
|
|||||||
# # all check func should execute before check_fail_list
|
# # all check func should execute before check_fail_list
|
||||||
# check_fail_list()
|
# check_fail_list()
|
||||||
# modify_server_permanent_offline_time(cur)
|
# modify_server_permanent_offline_time(cur)
|
||||||
# except Exception, e:
|
# except Exception as e:
|
||||||
# logging.exception('run error')
|
# logging.exception('run error')
|
||||||
# raise e
|
# raise
|
||||||
# finally:
|
# finally:
|
||||||
# cur.close()
|
# cur.close()
|
||||||
# conn.close()
|
# conn.close()
|
||||||
# except mysql.connector.Error, e:
|
# except mysql.connector.Error as e:
|
||||||
# logging.exception('connection error')
|
# logging.exception('connection error')
|
||||||
# raise e
|
# raise
|
||||||
# except Exception, e:
|
# except Exception as e:
|
||||||
# logging.exception('normal error')
|
# logging.exception('normal error')
|
||||||
# raise e
|
# raise
|
||||||
#
|
#
|
||||||
#if __name__ == '__main__':
|
#if __name__ == '__main__':
|
||||||
# upgrade_params = UpgradeParams()
|
# 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\"',\
|
# 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)
|
# host, port, user, password.replace('"', '\\"'), timeout, log_filename)
|
||||||
# do_check(host, port, user, password, timeout, upgrade_params)
|
# 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')
|
# logging.exception('mysql connctor error')
|
||||||
# raise e
|
# raise
|
||||||
# except Exception, e:
|
# except Exception as e:
|
||||||
# logging.exception('normal error')
|
# logging.exception('normal error')
|
||||||
# raise e
|
# raise
|
||||||
####====XXXX======######==== I am a splitter ====######======XXXX====####
|
####====XXXX======######==== I am a splitter ====######======XXXX====####
|
||||||
#filename:upgrade_health_checker.py
|
#filename:upgrade_health_checker.py
|
||||||
##!/usr/bin/env python
|
##!/usr/bin/env python
|
||||||
## -*- coding: utf-8 -*-
|
## -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
|
#from __future__ import print_function
|
||||||
#import sys
|
#import sys
|
||||||
#import os
|
#import os
|
||||||
#import time
|
#import time
|
||||||
@ -2504,12 +2511,12 @@
|
|||||||
# if True == print_when_succ:
|
# if True == print_when_succ:
|
||||||
# logging.info('succeed to execute sql: %s, rowcount = %d', sql, rowcount)
|
# logging.info('succeed to execute sql: %s, rowcount = %d', sql, rowcount)
|
||||||
# return 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)
|
# logging.exception('mysql connector error, fail to execute sql: %s', sql)
|
||||||
# raise e
|
# raise
|
||||||
# except Exception, e:
|
# except Exception as e:
|
||||||
# logging.exception('normal error, fail to execute sql: %s', sql)
|
# logging.exception('normal error, fail to execute sql: %s', sql)
|
||||||
# raise e
|
# raise
|
||||||
# def exec_query(self, sql, print_when_succ = True):
|
# def exec_query(self, sql, print_when_succ = True):
|
||||||
# try:
|
# try:
|
||||||
# self.__cursor.execute(sql)
|
# self.__cursor.execute(sql)
|
||||||
@ -2518,12 +2525,12 @@
|
|||||||
# if True == print_when_succ:
|
# if True == print_when_succ:
|
||||||
# logging.info('succeed to execute query: %s, rowcount = %d', sql, rowcount)
|
# logging.info('succeed to execute query: %s, rowcount = %d', sql, rowcount)
|
||||||
# return (self.__cursor.description, results)
|
# 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)
|
# logging.exception('mysql connector error, fail to execute sql: %s', sql)
|
||||||
# raise e
|
# raise
|
||||||
# except Exception, e:
|
# except Exception as e:
|
||||||
# logging.exception('normal error, fail to execute sql: %s', sql)
|
# logging.exception('normal error, fail to execute sql: %s', sql)
|
||||||
# raise e
|
# raise
|
||||||
##### ---------------end----------------------
|
##### ---------------end----------------------
|
||||||
#
|
#
|
||||||
##### --------------start : opt.py --------------
|
##### --------------start : opt.py --------------
|
||||||
@ -2663,10 +2670,10 @@
|
|||||||
#def deal_with_local_opt(opt):
|
#def deal_with_local_opt(opt):
|
||||||
# if 'help' == opt.get_long_name():
|
# if 'help' == opt.get_long_name():
|
||||||
# global help_str
|
# global help_str
|
||||||
# print help_str
|
# print(help_str)
|
||||||
# elif 'version' == opt.get_long_name():
|
# elif 'version' == opt.get_long_name():
|
||||||
# global version_str
|
# global version_str
|
||||||
# print version_str
|
# print(version_str)
|
||||||
#
|
#
|
||||||
#def deal_with_local_opts():
|
#def deal_with_local_opts():
|
||||||
# global g_opts
|
# global g_opts
|
||||||
@ -2767,9 +2774,9 @@
|
|||||||
# for r in results:
|
# for r in results:
|
||||||
# tenant_id_list.append(r[0])
|
# tenant_id_list.append(r[0])
|
||||||
# return tenant_id_list
|
# return tenant_id_list
|
||||||
# except Exception, e:
|
# except Exception as e:
|
||||||
# logging.exception('fail to fetch distinct tenant ids')
|
# 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):
|
#def set_default_timeout_by_tenant(query_cur, timeout, timeout_per_tenant, min_timeout):
|
||||||
# if timeout > 0:
|
# if timeout > 0:
|
||||||
@ -2853,7 +2860,7 @@
|
|||||||
# times -= 1
|
# times -= 1
|
||||||
# if times == -1:
|
# if times == -1:
|
||||||
# logging.warn("""check {0} job timeout""".format(job_name))
|
# logging.warn("""check {0} job timeout""".format(job_name))
|
||||||
# raise e
|
# raise MyError("""check {0} job timeout""".format(job_name))
|
||||||
# time.sleep(10)
|
# time.sleep(10)
|
||||||
#
|
#
|
||||||
## 开始健康检查
|
## 开始健康检查
|
||||||
@ -2876,18 +2883,18 @@
|
|||||||
# check_server_version_by_zone(query_cur, zone)
|
# check_server_version_by_zone(query_cur, zone)
|
||||||
# if True == need_check_major_status:
|
# if True == need_check_major_status:
|
||||||
# check_major_merge(query_cur, timeout)
|
# check_major_merge(query_cur, timeout)
|
||||||
# except Exception, e:
|
# except Exception as e:
|
||||||
# logging.exception('run error')
|
# logging.exception('run error')
|
||||||
# raise e
|
# raise
|
||||||
# finally:
|
# finally:
|
||||||
# cur.close()
|
# cur.close()
|
||||||
# conn.close()
|
# conn.close()
|
||||||
# except mysql.connector.Error, e:
|
# except mysql.connector.Error as e:
|
||||||
# logging.exception('connection error')
|
# logging.exception('connection error')
|
||||||
# raise e
|
# raise
|
||||||
# except Exception, e:
|
# except Exception as e:
|
||||||
# logging.exception('normal error')
|
# logging.exception('normal error')
|
||||||
# raise e
|
# raise
|
||||||
#
|
#
|
||||||
#if __name__ == '__main__':
|
#if __name__ == '__main__':
|
||||||
# upgrade_params = UpgradeParams()
|
# 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\"', \
|
# 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)
|
# 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
|
# 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')
|
# logging.exception('mysql connctor error')
|
||||||
# raise e
|
# raise
|
||||||
# except Exception, e:
|
# except Exception as e:
|
||||||
# logging.exception('normal error')
|
# logging.exception('normal error')
|
||||||
# raise e
|
# raise
|
||||||
#
|
#
|
||||||
####====XXXX======######==== I am a splitter ====######======XXXX====####
|
####====XXXX======######==== I am a splitter ====######======XXXX====####
|
||||||
#filename:upgrade_post_checker.py
|
#filename:upgrade_post_checker.py
|
||||||
##!/usr/bin/env python
|
##!/usr/bin/env python
|
||||||
## -*- coding: utf-8 -*-
|
## -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
|
#from my_error import MyError
|
||||||
#import sys
|
#import sys
|
||||||
#import os
|
#import os
|
||||||
#import time
|
#import time
|
||||||
@ -2946,7 +2954,7 @@
|
|||||||
# (desc, results) = query_cur.exec_query(sql)
|
# (desc, results) = query_cur.exec_query(sql)
|
||||||
# if len(results) == 0:
|
# if len(results) == 0:
|
||||||
# logging.warn('result cnt not match')
|
# logging.warn('result cnt not match')
|
||||||
# raise e
|
# raise MyError('result cnt not match')
|
||||||
# tenant_count = len(results)
|
# tenant_count = len(results)
|
||||||
# tenant_ids_str = ''
|
# tenant_ids_str = ''
|
||||||
# for index, row in enumerate(results):
|
# for index, row in enumerate(results):
|
||||||
@ -2957,7 +2965,7 @@
|
|||||||
# (desc, results) = query_cur.exec_query(sql)
|
# (desc, results) = query_cur.exec_query(sql)
|
||||||
# if len(results) != 1 or len(results[0]) != 1:
|
# if len(results) != 1 or len(results[0]) != 1:
|
||||||
# logging.warn('result cnt not match')
|
# logging.warn('result cnt not match')
|
||||||
# raise e
|
# raise MyError('result cnt not match')
|
||||||
# server_count = results[0][0]
|
# server_count = results[0][0]
|
||||||
#
|
#
|
||||||
# # check compatible sync
|
# # check compatible sync
|
||||||
@ -2977,7 +2985,7 @@
|
|||||||
# result = cur.fetchall()
|
# result = cur.fetchall()
|
||||||
# if len(result) != 1 or len(result[0]) != 1:
|
# if len(result) != 1 or len(result[0]) != 1:
|
||||||
# logging.exception('result cnt not match')
|
# logging.exception('result cnt not match')
|
||||||
# raise e
|
# raise MyError('result cnt not match')
|
||||||
# elif result[0][0] == parameter_count:
|
# elif result[0][0] == parameter_count:
|
||||||
# logging.info("""'compatible' is sync, value is {0}""".format(current_data_version))
|
# logging.info("""'compatible' is sync, value is {0}""".format(current_data_version))
|
||||||
# break
|
# break
|
||||||
@ -2987,7 +2995,7 @@
|
|||||||
# times -= 1
|
# times -= 1
|
||||||
# if times == -1:
|
# if times == -1:
|
||||||
# logging.exception("""check compatible:{0} sync timeout""".format(current_data_version))
|
# 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)
|
# time.sleep(5)
|
||||||
#
|
#
|
||||||
# actions.set_session_timeout(cur, 10)
|
# actions.set_session_timeout(cur, 10)
|
||||||
@ -2998,10 +3006,10 @@
|
|||||||
# (desc, results) = query_cur.exec_query(sql)
|
# (desc, results) = query_cur.exec_query(sql)
|
||||||
# if len(results) != 1 or len(results[0]) != 1:
|
# if len(results) != 1 or len(results[0]) != 1:
|
||||||
# logging.warn('result cnt not match')
|
# logging.warn('result cnt not match')
|
||||||
# raise e
|
# raise MyError('result cnt not match')
|
||||||
# elif 2 * tenant_count != results[0][0]:
|
# 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]))
|
# 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:
|
# else:
|
||||||
# logging.info("all tenant's target_data_version/current_data_version are match with {0}".format(current_data_version))
|
# 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:
|
# if times == -1:
|
||||||
# logging.warn('check root inspection failed!')
|
# logging.warn('check root inspection failed!')
|
||||||
# raise e
|
# raise MyError('check root inspection failed!')
|
||||||
# logging.info('check root inspection success')
|
# logging.info('check root inspection success')
|
||||||
#
|
#
|
||||||
## 4 开ddl
|
## 4 开ddl
|
||||||
@ -3053,13 +3061,14 @@
|
|||||||
# enable_rebalance(cur, timeout)
|
# enable_rebalance(cur, timeout)
|
||||||
# enable_rereplication(cur, timeout)
|
# enable_rereplication(cur, timeout)
|
||||||
# enable_major_freeze(cur, timeout)
|
# enable_major_freeze(cur, timeout)
|
||||||
# except Exception, e:
|
# except Exception as e:
|
||||||
# logging.exception('run error')
|
# logging.exception('run error')
|
||||||
# raise e
|
# raise
|
||||||
####====XXXX======######==== I am a splitter ====######======XXXX====####
|
####====XXXX======######==== I am a splitter ====######======XXXX====####
|
||||||
#sub file module end
|
#sub file module end
|
||||||
|
|
||||||
|
|
||||||
|
from __future__ import print_function, absolute_import
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import datetime
|
import datetime
|
||||||
@ -3115,7 +3124,7 @@ def split_py_files(sub_files_dir):
|
|||||||
if i >= cur_file_lines_count:
|
if i >= cur_file_lines_count:
|
||||||
raise SplitError('invalid line index:' + str(i) + ', lines_count:' + str(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]:
|
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
|
break
|
||||||
else:
|
else:
|
||||||
mark_idx = cur_file_lines[i].find(sub_filename_line_prefix)
|
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_dir = cur_file_short_name + sub_files_dir_suffix
|
||||||
sub_files_short_dir = cur_file_real_name + sub_files_dir_suffix
|
sub_files_short_dir = cur_file_real_name + sub_files_dir_suffix
|
||||||
split_py_files(sub_files_dir)
|
split_py_files(sub_files_dir)
|
||||||
exec('from ' + sub_files_short_dir + '.do_upgrade_pre 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_pre import do_upgrade_by_argv
|
||||||
do_upgrade_by_argv(sys.argv[1:])
|
do_upgrade_by_argv(sys.argv[1:])
|
||||||
|
Reference in New Issue
Block a user