mirror of
https://github.com/percona/percona-toolkit.git
synced 2026-04-26 01:02:25 +08:00
Removed PerconaTest::{wait_until_no_lag|wait_until_slaves_running}, replaced them with Sandbox::wait_for_slaves
This commit is contained in:
@@ -246,42 +246,6 @@ sub wait_until {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub wait_until_slave_running {
|
|
||||||
my (@dbhs) = @_;
|
|
||||||
foreach my $dbh (@dbhs) {
|
|
||||||
PTDEVDEBUG && _d('Waiting for slaves to be running');
|
|
||||||
wait_until(
|
|
||||||
sub {
|
|
||||||
my $row = $dbh->selectrow_hashref('SHOW SLAVE STATUS');
|
|
||||||
my $sqlt = $row->{slave_sql_running} || $row->{Slave_SQL_Running} || 'NULL';
|
|
||||||
my $iot = $row->{Slave_IO_Running} || $row->{slave_io_running} || 'NULL';
|
|
||||||
PTDEVDEBUG && _d('Slave SQL:', $sqlt, 'Slave IO:', $iot);
|
|
||||||
return $sqlt eq 'Yes' && $iot eq 'Yes';
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sub wait_until_no_lag {
|
|
||||||
my (@dbhs) = @_;
|
|
||||||
foreach my $dbh (@dbhs) {
|
|
||||||
PTDEVDEBUG && _d('Waiting for no slave lag');
|
|
||||||
wait_until( # slaves aren't lagging
|
|
||||||
sub {
|
|
||||||
my $row = $dbh->selectrow_hashref('SHOW SLAVE STATUS');
|
|
||||||
my $lag = exists $row->{Seconds_Behind_Master}
|
|
||||||
? $row->{Seconds_Behind_Master}
|
|
||||||
: $row->{seconds_behind_master};
|
|
||||||
PTDEVDEBUG && _d('Slave lag:', $lag);
|
|
||||||
if ( !defined $lag ) {
|
|
||||||
BAIL_OUT("Slave is stopped: " . Dumper($row));
|
|
||||||
}
|
|
||||||
return $lag ? 0 : 1;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Wait t seconds for code to return.
|
# Wait t seconds for code to return.
|
||||||
sub wait_for {
|
sub wait_for {
|
||||||
my ( $code, $t ) = @_;
|
my ( $code, $t ) = @_;
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ my $scripts = "$trunk/t/pt-table-checksum/scripts/";
|
|||||||
$master_dbh->do('drop table if exists percona.checksums');
|
$master_dbh->do('drop table if exists percona.checksums');
|
||||||
|
|
||||||
# Must not be lagging.
|
# Must not be lagging.
|
||||||
wait_until_no_lag($slave1_dbh, $slave2_dbh);
|
$sb->wait_for_slaves();
|
||||||
|
|
||||||
# This big fancy command waits until it sees the checksum for sakila.city
|
# This big fancy command waits until it sees the checksum for sakila.city
|
||||||
# in the repl table on the master, then it stops slave2 for 2 seconds,
|
# in the repl table on the master, then it stops slave2 for 2 seconds,
|
||||||
@@ -96,7 +96,7 @@ is(
|
|||||||
);
|
);
|
||||||
|
|
||||||
# Now wait until the SQL thread is started again.
|
# Now wait until the SQL thread is started again.
|
||||||
wait_until_slave_running($slave1_dbh, $slave2_dbh);
|
$sb->wait_for_slaves();
|
||||||
|
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Wait for --replicate table to replicate.
|
# Wait for --replicate table to replicate.
|
||||||
@@ -130,7 +130,7 @@ like(
|
|||||||
);
|
);
|
||||||
|
|
||||||
$slave2_dbh->do("START SLAVE");
|
$slave2_dbh->do("START SLAVE");
|
||||||
wait_until_slave_running($slave2_dbh);
|
$sb->wait_for_slaves();
|
||||||
|
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Done.
|
# Done.
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ pt_table_checksum::main(@args, qw(-t sakila.city --quiet));
|
|||||||
# ############################################################################
|
# ############################################################################
|
||||||
|
|
||||||
# Stop slave1.
|
# Stop slave1.
|
||||||
PerconaTest::wait_until_no_lag($slave1_dbh, $slave2_dbh);
|
$sb->wait_for_slaves();
|
||||||
$slave1_dbh->do('stop slave sql_thread');
|
$slave1_dbh->do('stop slave sql_thread');
|
||||||
wait_until(sub {
|
wait_until(sub {
|
||||||
my $ss = $slave1_dbh->selectrow_hashref("SHOW SLAVE STATUS");
|
my $ss = $slave1_dbh->selectrow_hashref("SHOW SLAVE STATUS");
|
||||||
@@ -98,7 +98,7 @@ is(
|
|||||||
$slave1_dbh->do('START SLAVE sql_thread');
|
$slave1_dbh->do('START SLAVE sql_thread');
|
||||||
$slave2_dbh->do('STOP SLAVE');
|
$slave2_dbh->do('STOP SLAVE');
|
||||||
$slave2_dbh->do('START SLAVE');
|
$slave2_dbh->do('START SLAVE');
|
||||||
PerconaTest::wait_until_slave_running($slave1_dbh, $slave2_dbh);
|
$sb->wait_for_slaves();
|
||||||
|
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Done.
|
# Done.
|
||||||
|
|||||||
Reference in New Issue
Block a user