mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-09 18:30:16 +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 $tries = $self->{'OptionParser'}->get('replicate-check-retries') || 1;
|
||||
my $diffs;
|
||||
|
||||
while ($tries--) {
|
||||
my $sql
|
||||
= "SELECT CONCAT(db, '.', tbl) AS `table`, "
|
||||
@@ -6258,7 +6258,7 @@ sub find_replication_differences {
|
||||
if (!@$diffs || !$tries) { # if no differences are found OR we are out of tries left...
|
||||
last; # get out now
|
||||
}
|
||||
sleep 1;
|
||||
sleep 1;
|
||||
}
|
||||
return $diffs;
|
||||
}
|
||||
@@ -11271,6 +11271,10 @@ sub main {
|
||||
|
||||
# Wait for the last checksum of this table to replicate
|
||||
# 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(
|
||||
tbl => $tbl,
|
||||
repl_table => $repl_table,
|
||||
@@ -12337,6 +12341,20 @@ sub have_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 {
|
||||
my (%args) = @_;
|
||||
my @required_args = qw(tbl repl_table slaves max_chunk have_time OptionParser);
|
||||
|
Reference in New Issue
Block a user