mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-21 03:14:58 +00:00
PT-2340 - Support MySQL 8.4
- Updated modules and tests for pt-query-digest, pt-show-grants, pt-slave-delay, pt-slave-find, pt-slave-restart, pt-stalk, pt-summary, pt-table-checksum
This commit is contained in:
@@ -20,25 +20,25 @@ require "$trunk/bin/pt-table-checksum";
|
||||
|
||||
my $dp = new DSNParser(opts=>$dsn_opts);
|
||||
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
|
||||
my $master_dbh = $sb->get_dbh_for('master');
|
||||
my $slave1_dbh = $sb->get_dbh_for('slave1');
|
||||
my $source_dbh = $sb->get_dbh_for('source');
|
||||
my $replica1_dbh = $sb->get_dbh_for('replica1');
|
||||
|
||||
if ( !$master_dbh ) {
|
||||
plan skip_all => 'Cannot connect to sandbox master';
|
||||
if ( !$source_dbh ) {
|
||||
plan skip_all => 'Cannot connect to sandbox source';
|
||||
}
|
||||
elsif ( !$slave1_dbh ) {
|
||||
plan skip_all => 'Cannot connect to sandbox slave';
|
||||
elsif ( !$replica1_dbh ) {
|
||||
plan skip_all => 'Cannot connect to sandbox replica';
|
||||
}
|
||||
|
||||
# The sandbox servers run with lock_wait_timeout=3 and it's not dynamic
|
||||
# so we need to specify --set-vars innodb_lock_wait_timeout=3 else the tool will die.
|
||||
# And --max-load "" prevents waiting for status variables.
|
||||
my $master_dsn = 'h=127.1,P=12345,u=msandbox,p=msandbox';
|
||||
my @args = ($master_dsn, qw(--set-vars innodb_lock_wait_timeout=3), '--max-load', '');
|
||||
my $source_dsn = 'h=127.1,P=12345,u=msandbox,p=msandbox';
|
||||
my @args = ($source_dsn, qw(--set-vars innodb_lock_wait_timeout=3), '--max-load', '');
|
||||
my $output;
|
||||
my $exit_status;
|
||||
|
||||
$sb->create_dbs($master_dbh, [qw(test)]);
|
||||
$sb->create_dbs($source_dbh, [qw(test)]);
|
||||
|
||||
# #############################################################################
|
||||
# Issue 81: put some data that's too big into the boundaries table
|
||||
@@ -50,10 +50,10 @@ $sb->create_dbs($master_dbh, [qw(test)]);
|
||||
# Since the idea is probably to test warning handling, we'll turn off STRICT
|
||||
# for the next two tests.
|
||||
|
||||
my $modes = new SqlModes($master_dbh, global=>1);
|
||||
my $modes = new SqlModes($source_dbh, global=>1);
|
||||
$modes->del('STRICT_TRANS_TABLES','STRICT_ALL_TABLES');
|
||||
|
||||
$sb->load_file('master', 't/pt-table-checksum/samples/checksum_tbl_truncated.sql');
|
||||
$sb->load_file('source', 't/pt-table-checksum/samples/checksum_tbl_truncated.sql');
|
||||
|
||||
$output = output(
|
||||
sub { pt_table_checksum::main(@args,
|
||||
@@ -80,9 +80,9 @@ $modes->restore_original_modes();
|
||||
# ############################################################################
|
||||
# Lock wait timeout
|
||||
# ############################################################################
|
||||
$master_dbh->do('use sakila');
|
||||
$master_dbh->do('begin');
|
||||
$master_dbh->do('select * from city for update');
|
||||
$source_dbh->do('use sakila');
|
||||
$source_dbh->do('begin');
|
||||
$source_dbh->do('select * from city for update');
|
||||
|
||||
$output = output(
|
||||
sub { $exit_status = pt_table_checksum::main(@args, qw(-t sakila.city)) },
|
||||
@@ -112,7 +112,7 @@ is(
|
||||
|
||||
# Lock wait timeout for sandbox servers is 3s, so sleep 4 then commit
|
||||
# to release the lock. That should allow the checksum query to finish.
|
||||
my ($id) = $master_dbh->selectrow_array('select connection_id()');
|
||||
my ($id) = $source_dbh->selectrow_array('select connection_id()');
|
||||
system("sleep 4 ; /tmp/12345/use -e 'KILL $id' >/dev/null");
|
||||
|
||||
$output = output(
|
||||
@@ -133,20 +133,20 @@ like(
|
||||
"Checksum retried after lock wait timeout"
|
||||
);
|
||||
|
||||
# Reconnect to master since we just killed ourself.
|
||||
$master_dbh = $sb->get_dbh_for('master');
|
||||
# Reconnect to source since we just killed ourself.
|
||||
$source_dbh = $sb->get_dbh_for('source');
|
||||
|
||||
# #############################################################################
|
||||
# pt-table-checksum breaks replication if a slave table is missing or different
|
||||
# pt-table-checksum breaks replication if a replica table is missing or different
|
||||
# https://bugs.launchpad.net/percona-toolkit/+bug/1009510
|
||||
# #############################################################################
|
||||
|
||||
# Just re-using this simple table.
|
||||
$sb->load_file('master', "t/pt-table-checksum/samples/600cities.sql");
|
||||
$sb->load_file('source', "t/pt-table-checksum/samples/600cities.sql");
|
||||
|
||||
$master_dbh->do("SET SQL_LOG_BIN=0");
|
||||
$master_dbh->do("ALTER TABLE test.t ADD COLUMN col3 int");
|
||||
$master_dbh->do("SET SQL_LOG_BIN=1");
|
||||
$source_dbh->do("SET SQL_LOG_BIN=0");
|
||||
$source_dbh->do("ALTER TABLE test.t ADD COLUMN col3 int");
|
||||
$source_dbh->do("SET SQL_LOG_BIN=1");
|
||||
|
||||
$output = output(
|
||||
sub { $exit_status = pt_table_checksum::main(@args,
|
||||
@@ -157,19 +157,19 @@ $output = output(
|
||||
like(
|
||||
$output,
|
||||
qr/Skipping table test.t/,
|
||||
"Skip table missing column on slave (bug 1009510)"
|
||||
"Skip table missing column on replica (bug 1009510)"
|
||||
);
|
||||
|
||||
like(
|
||||
$output,
|
||||
qr/replica h=127.0.0.1,P=12346 is missing these columns: col3/,
|
||||
"Checked slave1 (bug 1009510)"
|
||||
"Checked replica1 (bug 1009510)"
|
||||
);
|
||||
|
||||
like(
|
||||
$output,
|
||||
qr/replica h=127.0.0.1,P=12347 is missing these columns: col3/,
|
||||
"Checked slave2 (bug 1009510)"
|
||||
"Checked replica2 (bug 1009510)"
|
||||
);
|
||||
|
||||
is(
|
||||
@@ -187,7 +187,7 @@ $output = output(
|
||||
unlike(
|
||||
$output,
|
||||
qr/Skipping table test.t/,
|
||||
"Doesn't skip table missing column on slave with --columns (bug 1009510)"
|
||||
"Doesn't skip table missing column on replica with --columns (bug 1009510)"
|
||||
);
|
||||
|
||||
is(
|
||||
@@ -202,22 +202,22 @@ is(
|
||||
diag(`/tmp/12345/use -uroot -pmsandbox < $trunk/t/lib/samples/ro-checksum-user.sql 2>&1`);
|
||||
diag(`/tmp/12345/use -uroot -pmsandbox -e "GRANT REPLICATION CLIENT, REPLICATION SLAVE ON *.* TO ro_checksum_user\@'%'" 2>&1`);
|
||||
|
||||
# Remove the --replicate table from slave1 and slave2,
|
||||
# so it's only on the master...
|
||||
$slave1_dbh->do("DROP DATABASE percona");
|
||||
$sb->wait_for_slaves;
|
||||
# Remove the --replicate table from replica1 and replica2,
|
||||
# so it's only on the source...
|
||||
$replica1_dbh->do("DROP DATABASE percona");
|
||||
$sb->wait_for_replicas;
|
||||
|
||||
$output = output(
|
||||
sub { $exit_status = pt_table_checksum::main(
|
||||
"h=127.1,u=ro_checksum_user,p=msandbox,P=12345",
|
||||
"h=127.1,u=ro_checksum_user,p=msandbox,P=12345,s=1",
|
||||
qw(--set-vars innodb_lock_wait_timeout=3 -t mysql.user)) },
|
||||
stderr => 1,
|
||||
);
|
||||
|
||||
like(
|
||||
$output,
|
||||
qr/database percona exists on the master/,
|
||||
"CREATE DATABASE error and db is missing on slaves (bug 1039569)"
|
||||
qr/database percona exists on the source/,
|
||||
"CREATE DATABASE error and db is missing on replicas (bug 1039569)"
|
||||
);
|
||||
|
||||
diag(`/tmp/12345/use -uroot -pmsandbox -e "DROP USER ro_checksum_user\@'%'" 2>&1`);
|
||||
@@ -225,6 +225,6 @@ diag(`/tmp/12345/use -uroot -pmsandbox -e "DROP USER ro_checksum_user\@'%'" 2>&1
|
||||
# #############################################################################
|
||||
# Done.
|
||||
# #############################################################################
|
||||
$sb->wipe_clean($master_dbh);
|
||||
$sb->wipe_clean($source_dbh);
|
||||
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
|
||||
done_testing;
|
||||
|
Reference in New Issue
Block a user