mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-10-19 00:43:58 +00:00
PT-139 Detect only 1 slave using rep channels
If there is only one slave but it is using replication channels but --channel was not specified as a parameter, get_slave_status will return null.
This commit is contained in:
@@ -457,7 +457,12 @@ sub get_slave_status {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$ss = $sss_rows->[0];
|
||||
if ($sss_rows->[0]->{channel_name} && $sss_rows->[0]->{channel_name} ne $self->{channel}) {
|
||||
warn 'This server is using replication channels but "channel" was not specified on the command line';
|
||||
return undef;
|
||||
} else {
|
||||
$ss = $sss_rows->[0];
|
||||
}
|
||||
}
|
||||
|
||||
if ( $ss && %$ss ) {
|
||||
|
@@ -814,6 +814,20 @@ SKIP: {
|
||||
'Wait for master returned error',
|
||||
);
|
||||
|
||||
# After stopping one of the replication channels, show slave status returns only one slave
|
||||
# but it has a channel name and we didn't specified a channels name in the command line.
|
||||
# It should return undef
|
||||
$slave1_dbh->do("STOP SLAVE for channel 'masterchan2'");
|
||||
|
||||
$css = $ms->get_slave_status($slave1_dbh);
|
||||
is (
|
||||
$css,
|
||||
undef,
|
||||
'Cannot determine slave in a multi source config without --channel param (only one server)'
|
||||
);
|
||||
|
||||
$slave1_dbh->do("START SLAVE for channel 'masterchan2'");
|
||||
|
||||
# Now try specifying a channel name
|
||||
$ms->{channel} = 'masterchan1';
|
||||
$css = $ms->get_slave_status($slave1_dbh);
|
||||
|
Reference in New Issue
Block a user