提交 9398d0d6 编写于 作者: F frf12

v1.4.0

上级 fa4c735e
...@@ -910,7 +910,7 @@ class TestMajorCommand(MajorCommand): ...@@ -910,7 +910,7 @@ class TestMajorCommand(MajorCommand):
self.register_command(MySQLTestCommand()) self.register_command(MySQLTestCommand())
self.register_command(SysBenchCommand()) self.register_command(SysBenchCommand())
self.register_command(TPCHCommand()) self.register_command(TPCHCommand())
# self.register_command(TPCCCommand()) self.register_command(TPCCCommand())
class BenchMajorCommand(MajorCommand): class BenchMajorCommand(MajorCommand):
......
...@@ -42,6 +42,18 @@ def build(plugin_context, cursor, odp_cursor, *args, **kwargs): ...@@ -42,6 +42,18 @@ def build(plugin_context, cursor, odp_cursor, *args, **kwargs):
def local_execute_command(command, env=None, timeout=None): def local_execute_command(command, env=None, timeout=None):
return LocalClient.execute_command(command, env, timeout, stdio) return LocalClient.execute_command(command, env, timeout, stdio)
def execute(cursor, query, args=None):
msg = query % tuple(args) if args is not None else query
stdio.verbose('execute sql: %s' % msg)
stdio.verbose("query: %s. args: %s" % (query, args))
try:
cursor.execute(query, args)
return cursor.fetchone()
except:
msg = 'execute sql exception: %s' % msg
stdio.exception(msg)
raise Exception(msg)
def run_sql(sql_file, force=False): def run_sql(sql_file, force=False):
sql_cmd = "{obclient} -h{host} -P{port} -u{user}@{tenant} {password_arg} -A {db} {force_flag} < {sql_file}".format( sql_cmd = "{obclient} -h{host} -P{port} -u{user}@{tenant} {password_arg} -A {db} {force_flag} < {sql_file}".format(
obclient=obclient_bin, host=host, port=port, user=user, tenant=tenant_name, obclient=obclient_bin, host=host, port=port, user=user, tenant=tenant_name,
...@@ -130,22 +142,30 @@ def build(plugin_context, cursor, odp_cursor, *args, **kwargs): ...@@ -130,22 +142,30 @@ def build(plugin_context, cursor, odp_cursor, *args, **kwargs):
stdio.exception('') stdio.exception('')
return return
stdio.stop_loading('succeed') stdio.stop_loading('succeed')
# drop old tables # drop old tables
bmsql_sql_path = kwargs.get('bmsql_sql_path', '') bmsql_sql_path = kwargs.get('bmsql_sql_path', '')
run_sql(sql_file=os.path.join(bmsql_sql_path, 'tableDrops.sql'), force=True) run_sql(sql_file=os.path.join(bmsql_sql_path, 'tableDrops.sql'), force=True)
retries = 300 merge_version = execute(cursor, "select value from oceanbase.__all_zone where name='frozen_version'")['value']
pending_free_count = -1 stdio.start_loading('Merge')
while pending_free_count != 0 and retries > 0: execute(cursor, 'alter system major freeze')
retries -= 1 sql = "select value from oceanbase.__all_zone where name='frozen_version' and value != %s" % merge_version
sql = 'select pending_free_count from oceanbase.__all_virtual_macro_block_marker_status' while True:
stdio.verbose('execute sql: %s' % sql) if execute(cursor, sql):
cursor.execute(sql) break
ret = cursor.fetchone()
stdio.verbose('sql result: %s' % ret)
pending_free_count = ret.get('pending_free_count', 0) if ret else 0
time.sleep(1) time.sleep(1)
while True:
if not execute(cursor, """select * from oceanbase.__all_zone
where name='last_merged_version'
and value != (select value from oceanbase.__all_zone where name='frozen_version' limit 1)
and zone in (select zone from oceanbase.__all_zone where name='status' and info = 'ACTIVE')
"""):
break
time.sleep(5)
stdio.stop_loading('succeed')
# create new tables # create new tables
if not run_sql(sql_file=os.path.join(bmsql_sql_path, 'tableCreates.sql')): if not run_sql(sql_file=os.path.join(bmsql_sql_path, 'tableCreates.sql')):
stdio.error('create tables failed') stdio.error('create tables failed')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册