mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-14 15:33:49 +00:00
PT-1551 New wait for master method to pt-table-checksum
This is part of PT-1554. While I was testing pt-table-checksum ignore_columns.t was failing and it was because the original method in pt-table-checksum to wait for the slaves to catch up, wasn't enough. I added a new method who calls MySQL's SELECT MASTER_POS_WAIT from the MasterSlave package.
This commit is contained in:
@@ -6238,9 +6238,9 @@ sub find_replication_differences {
|
|||||||
}
|
}
|
||||||
my ($dbh, $repl_table) = @args{@required_args};
|
my ($dbh, $repl_table) = @args{@required_args};
|
||||||
|
|
||||||
|
|
||||||
my $tries = $self->{'OptionParser'}->get('replicate-check-retries') || 1;
|
my $tries = $self->{'OptionParser'}->get('replicate-check-retries') || 1;
|
||||||
my $diffs;
|
my $diffs;
|
||||||
|
|
||||||
while ($tries--) {
|
while ($tries--) {
|
||||||
my $sql
|
my $sql
|
||||||
= "SELECT CONCAT(db, '.', tbl) AS `table`, "
|
= "SELECT CONCAT(db, '.', tbl) AS `table`, "
|
||||||
@@ -11271,6 +11271,10 @@ sub main {
|
|||||||
|
|
||||||
# Wait for the last checksum of this table to replicate
|
# Wait for the last checksum of this table to replicate
|
||||||
# to each slave.
|
# to each slave.
|
||||||
|
# MySQL 8+ replication is slower than 5.7 and the old wait_for_last_checksum alone
|
||||||
|
# was failing. The new wait_for_slaves checks that Read_Master_Log_Pos on slaves is
|
||||||
|
# greather or equal Position in the master
|
||||||
|
wait_for_slaves(master_dbh => $args{Cxn}->dbh(), master_slave => $ms, slaves => $slaves);
|
||||||
wait_for_last_checksum(
|
wait_for_last_checksum(
|
||||||
tbl => $tbl,
|
tbl => $tbl,
|
||||||
repl_table => $repl_table,
|
repl_table => $repl_table,
|
||||||
@@ -12337,6 +12341,20 @@ sub have_more_chunks {
|
|||||||
return 1; # more chunks
|
return 1; # more chunks
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub wait_for_slaves {
|
||||||
|
my (%args) = @_;
|
||||||
|
my @required_args = qw(master_dbh master_slave slaves);
|
||||||
|
foreach my $arg ( @required_args ) {
|
||||||
|
die "I need a $arg argument" unless $args{$arg};
|
||||||
|
}
|
||||||
|
my ($master_dbh, $ms, $slaves) = @args{@required_args};
|
||||||
|
|
||||||
|
my $master_status = $ms->get_master_status($master_dbh);
|
||||||
|
foreach my $slave ( @$slaves ) {
|
||||||
|
$ms->wait_for_master(master_status => $master_status, slave_dbh => $slave->dbh());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sub wait_for_last_checksum {
|
sub wait_for_last_checksum {
|
||||||
my (%args) = @_;
|
my (%args) = @_;
|
||||||
my @required_args = qw(tbl repl_table slaves max_chunk have_time OptionParser);
|
my @required_args = qw(tbl repl_table slaves max_chunk have_time OptionParser);
|
||||||
|
@@ -42,14 +42,14 @@ $sb->load_file('master', 't/pt-table-checksum/samples/issue_94.sql');
|
|||||||
$slave_dbh->do("update test.issue_94 set c=''");
|
$slave_dbh->do("update test.issue_94 set c=''");
|
||||||
|
|
||||||
$output = output(
|
$output = output(
|
||||||
sub { pt_table_checksum::main(@args, qw(-d test -t issue_94)) },
|
sub { pt_table_checksum::main(@args, qw(-d test --ignore-databases mysql -t issue_94)) },
|
||||||
trf => sub { return PerconaTest::count_checksum_results(@_, 'DIFFS') },
|
trf => sub { return PerconaTest::count_checksum_results(@_, 'DIFFS') },
|
||||||
);
|
);
|
||||||
is(
|
is(
|
||||||
$output,
|
$output,
|
||||||
"1",
|
"1",
|
||||||
"Diff when column not ignored"
|
"Diff when column not ignored"
|
||||||
);
|
) or diag($output);
|
||||||
|
|
||||||
$output = output(
|
$output = output(
|
||||||
sub { pt_table_checksum::main(@args, qw(-d test -t issue_94),
|
sub { pt_table_checksum::main(@args, qw(-d test -t issue_94),
|
||||||
@@ -60,7 +60,7 @@ is(
|
|||||||
$output,
|
$output,
|
||||||
"0",
|
"0",
|
||||||
"No diff when column ignored"
|
"No diff when column ignored"
|
||||||
);
|
) or diag($output);
|
||||||
|
|
||||||
$output = output(
|
$output = output(
|
||||||
sub { pt_table_checksum::main(@args, qw(-d test -t issue_94),
|
sub { pt_table_checksum::main(@args, qw(-d test -t issue_94),
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
CREATE DATABASE IF NOT EXISTS test;
|
||||||
USE test;
|
USE test;
|
||||||
DROP TABLE IF EXISTS `issue_94`;
|
DROP TABLE IF EXISTS `issue_94`;
|
||||||
CREATE TABLE `issue_94` (
|
CREATE TABLE `issue_94` (
|
||||||
|
Reference in New Issue
Block a user