mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-10 13:11:32 +00:00
Check slave threads and read-only in Sandbox::ok().
This commit is contained in:
@@ -178,7 +178,7 @@ sub master_is_ok {
|
||||
}
|
||||
|
||||
sub slave_is_ok {
|
||||
my ($self, $slave, $master) = @_;
|
||||
my ($self, $slave, $master, $ro) = @_;
|
||||
|
||||
my $slave_dbh = $self->get_dbh_for($slave);
|
||||
if ( !$slave_dbh ) {
|
||||
@@ -200,6 +200,23 @@ sub slave_is_ok {
|
||||
return 1;
|
||||
}
|
||||
|
||||
foreach my $thd ( qw(slave_io_running slave_sql_running) ) {
|
||||
if ( $status->[0]->{$thd} ne 'Yes' ) {
|
||||
warn "Sandbox $slave " . $port_for{$slave} . " $thd thread "
|
||||
. "is not running\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $ro ) {
|
||||
my $row = $slave_dbh->selectrow_arrayref(
|
||||
"SHOW VARIABLES LIKE 'read_only'");
|
||||
if ( !$row || $row->[1] ne 'ON' ) {
|
||||
warn "Sandbox $slave " . $port_for{$slave} . " is not read-only\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !defined $status->[0]->{seconds_behind_master} ) {
|
||||
warn "Sandbox $slave " . $port_for{$slave} . " is stopped\n";
|
||||
return 1;
|
||||
@@ -239,7 +256,7 @@ sub ok {
|
||||
my ($self) = @_;
|
||||
return 0 unless $self->master_is_ok('master');
|
||||
return 0 unless $self->slave_is_ok('slave1', 'master');
|
||||
return 0 unless $self->slave_is_ok('slave2', 'slave1');
|
||||
return 0 unless $self->slave_is_ok('slave2', 'slave1', 1);
|
||||
return 0 if $self->leftover_servers();
|
||||
return 1;
|
||||
}
|
||||
|
Reference in New Issue
Block a user