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

v1.4.0

上级 fa4c735e
......@@ -910,7 +910,7 @@ class TestMajorCommand(MajorCommand):
self.register_command(MySQLTestCommand())
self.register_command(SysBenchCommand())
self.register_command(TPCHCommand())
# self.register_command(TPCCCommand())
self.register_command(TPCCCommand())
class BenchMajorCommand(MajorCommand):
......
......@@ -42,6 +42,18 @@ def build(plugin_context, cursor, odp_cursor, *args, **kwargs):
def local_execute_command(command, env=None, timeout=None):
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):
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,
......@@ -130,22 +142,30 @@ def build(plugin_context, cursor, odp_cursor, *args, **kwargs):
stdio.exception('')
return
stdio.stop_loading('succeed')
# drop old tables
bmsql_sql_path = kwargs.get('bmsql_sql_path', '')
run_sql(sql_file=os.path.join(bmsql_sql_path, 'tableDrops.sql'), force=True)
retries = 300
pending_free_count = -1
while pending_free_count != 0 and retries > 0:
retries -= 1
sql = 'select pending_free_count from oceanbase.__all_virtual_macro_block_marker_status'
stdio.verbose('execute sql: %s' % sql)
cursor.execute(sql)
ret = cursor.fetchone()
stdio.verbose('sql result: %s' % ret)
pending_free_count = ret.get('pending_free_count', 0) if ret else 0
merge_version = execute(cursor, "select value from oceanbase.__all_zone where name='frozen_version'")['value']
stdio.start_loading('Merge')
execute(cursor, 'alter system major freeze')
sql = "select value from oceanbase.__all_zone where name='frozen_version' and value != %s" % merge_version
while True:
if execute(cursor, sql):
break
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
if not run_sql(sql_file=os.path.join(bmsql_sql_path, 'tableCreates.sql')):
stdio.error('create tables failed')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册