Skip to content
This repository has been archived by the owner on May 9, 2023. It is now read-only.

Commit

Permalink
Bugfix issue196 (#200)
Browse files Browse the repository at this point in the history
* Preliminary fix for issue #196

* Fixing failed sql syntax

* Added sleep() statement

* Increasing sleep()

* Increased sleep to 30 again.

* Changed check uptime

* Added sleep again

* Raised --server-id random range

* changing random server id choice

* Changed values a bit

* Added --no-check-slave-tables for pt-table-checksum

* Finalizing the bug fix
  • Loading branch information
Shahriyar Rzayev authored Nov 22, 2017
1 parent d448c63 commit 9810823
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 18 deletions.
20 changes: 14 additions & 6 deletions general_conf/check_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,23 @@ def check_mysql_uptime(self, options=None):
statusargs = "{} {} status".format(self.mysqladmin, options)

logger.debug("Running mysqladmin command -> {}".format(statusargs))
statusargs = shlex.split(statusargs)
myadmin = subprocess.Popen(statusargs, stdout=subprocess.PIPE)
#statusargs = shlex.split(statusargs)
status, output = subprocess.getstatusoutput(statusargs)
#myadmin = subprocess.Popen(statusargs, stdout=subprocess.PIPE)

if not ('Uptime' in str(myadmin.stdout.read())):
logger.error('FAILED: Server is NOT Up')
raise RuntimeError('FAILED: Server is NOT Up')
else:
if status == 0:
logger.debug('OK: Server is Up and running')
return True
else:
logger.error('FAILED: Server is NOT Up')
raise RuntimeError('FAILED: Server is NOT Up')

# if not ('Uptime' in str(myadmin.stdout.read())):
# logger.error('FAILED: Server is NOT Up')
# raise RuntimeError('FAILED: Server is NOT Up')
# else:
# logger.debug('OK: Server is Up and running')
# return True

def check_mysql_conf(self):
'''
Expand Down
9 changes: 4 additions & 5 deletions prepare_env_test_mode/run_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@ def run_sysbench_prepare(self, basedir):
"--mysql-socket={} prepare"

logger.debug("Running command -> {}".format(sysbench_cmd.format(1000,
100,
30,
db_name,
100,
sock_name)))

status, output = subprocess.getstatusoutput(sysbench_cmd.format(1000,
100,
30,
db_name,
100,
sock_name))
Expand All @@ -110,7 +110,6 @@ def run_sysbench_prepare(self, basedir):
logger.error(output)
raise RuntimeError("Failed to run sysbench")


def run_sysbench_run(self, basedir):
# Running sysbench run here
db_name = "sysbench_test_db"
Expand All @@ -127,13 +126,13 @@ def run_sysbench_run(self, basedir):
"--mysql-socket={} run"

logger.debug("Running command -> {}".format(sysbench_cmd.format(1000,
100,
30,
db_name,
100,
sock_name)))

status, output = subprocess.getstatusoutput(sysbench_cmd.format(1000,
100,
30,
db_name,
100,
sock_name))
Expand Down
13 changes: 9 additions & 4 deletions prepare_env_test_mode/runner_test_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def prepare_start_slave_options(basedir, slave_number, options):
socket_file = "--socket={}/sock{}.sock".format(basedir, slave_number)
port = "--port={}".format(RunnerTestMode.get_free_tcp_port())
log_error = "--log-error={}/log/node{}".format(basedir, slave_number)
server_id = "--server_id={}".format(randint(10, 99))
server_id = "--server_id={}".format(randint(1111, 9999))
return " ".join([tmpdir, datadir, socket_file, port, log_error, options, server_id])

@staticmethod
Expand All @@ -62,13 +62,15 @@ def run_pt_table_checksum(basedir, conn_options=None):
rb_obj = RunBenchmark()
sock_file = rb_obj.get_sock(basedir=basedir)
if conn_options is None:
# TODO: Temporarily disable check due to https://jira.percona.com/browse/PT-225
# --no-check-slave-tables
command = "pt-table-checksum --user={} --socket={} " \
"--recursion-method dsn=h=localhost,D=test,t=dsns " \
"--no-check-binlog-format".format("root", sock_file)
"--no-check-binlog-format --no-check-slave-tables".format("root", sock_file)
else:
command = "pt-table-checksum {} " \
"--recursion-method dsn=h=localhost,D=test,t=dsns " \
"--no-check-binlog-format".format(conn_options)
"--no-check-binlog-format --no-check-slave-tables".format(conn_options)
status, output = subprocess.getstatusoutput(command)
if status == 0:
logger.debug("pt-table-checksum succeeded on master")
Expand Down Expand Up @@ -399,6 +401,8 @@ def wipe_backup_prepare_copyback(self, basedir):
self.create_slave_shutdown_file(basedir=basedir, num=1)

# Checking if node is up
logger.debug("Pausing a bit here...")
sleep(10)
chk_obj = CheckEnv(config=self.conf)
check_options = "--user={} --socket={}/sock{}.sock".format('root', basedir, 1)
chk_obj.check_mysql_uptime(options=check_options)
Expand Down Expand Up @@ -470,7 +474,8 @@ def wipe_backup_prepare_copyback(self, basedir):
self.create_slave_connection_file(basedir=basedir, num=2)
# Creating shutdown file for new node
self.create_slave_shutdown_file(basedir=basedir, num=2)

logger.debug("Pausing a bit here...")
sleep(10)
check_options_2 = "--user={} --socket={}/sock{}.sock".format('root', basedir, 2)
chk_obj.check_mysql_uptime(options=check_options_2)

Expand Down
16 changes: 13 additions & 3 deletions prepare_env_test_mode/take_backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,27 @@ def run_all_backup(self):
# Method for taking backups using master_backup_script.backuper.py::all_backup()
RunBenchmark().run_sysbench_prepare(basedir=self.basedir)
if '5.7' in self.basedir:
for i in range(1, 10):
for i in range(1, 5):
sql_encrypt = "alter table sysbench_test_db.sbtest{} encryption='Y'".format(i)
RunBenchmark.run_sql_statement(basedir=self.basedir, sql_statement=sql_encrypt)
# Compression related issue -> https://bugs.launchpad.net/percona-xtrabackup/+bug/1641745
# Disabling for now
# TODO: Enable this after #1641745 is fixed.
# TODO: Enable this after #1641745 is fixed. Or disable 64K page size for MySQL;disabled.
sql_compress = "alter table sysbench_test_db.sbtest{} compression='lz4'".format(i)
RunBenchmark.run_sql_statement(basedir=self.basedir, sql_statement=sql_compress)
sql_optimize = "optimize table sysbench_test_db.sbtest{}".format(i)
RunBenchmark.run_sql_statement(basedir=self.basedir, sql_statement=sql_optimize)
for i in range(10, 15):
# Fix for https://github.com/ShahriyarR/MySQL-AutoXtraBackup/issues/196
# Adding JSON + virtual + stored columns here
sql_virtual_column = "alter table sysbench_test_db.sbtest{} add column json_test_v json generated always as (json_array(k,c,pad)) virtual".format(i)
RunBenchmark.run_sql_statement(basedir=self.basedir, sql_statement=sql_virtual_column)
sql_stored_column = "alter table sysbench_test_db.sbtest{} add column json_test_s json generated always as (json_array(k,c,pad)) stored".format(i)
RunBenchmark.run_sql_statement(basedir=self.basedir, sql_statement=sql_stored_column)
sql_create_json_column = "alter table sysbench_test_db.sbtest{} add column json_test_index varchar(255) generated always as (json_array(k,c,pad)) stored".format(i)
RunBenchmark.run_sql_statement(basedir=self.basedir, sql_statement=sql_create_json_column)
sql_alter_add_index = "alter table sysbench_test_db.sbtest{} add index(json_test_index)".format(i)
RunBenchmark.run_sql_statement(basedir=self.basedir, sql_statement=sql_alter_add_index)
for i in range(5, 10):
sql_compress = "alter table sysbench_test_db.sbtest{} compression='zlib'".format(i)
RunBenchmark.run_sql_statement(basedir=self.basedir, sql_statement=sql_compress)
# NOTE: PXB will ignore rocksdb tables, which is going to break pt-table-checksum
Expand Down

0 comments on commit 9810823

Please sign in to comment.