PT-139 wait_for_master returns error if no channel was specified in a multi master env

This commit is contained in:
Carlos Salguero
2017-05-12 15:44:57 -03:00
parent 5744fdf583
commit 820448fca3
3 changed files with 51 additions and 2 deletions

View File

@@ -105,8 +105,7 @@ sub get_slaves {
},
}
);
}
elsif ( $methods->[0] =~ m/^dsn=/i ) {
} elsif ( $methods->[0] =~ m/^dsn=/i ) {
(my $dsn_table_dsn = join ",", @$methods) =~ s/^dsn=//i;
$slaves = $self->get_cxn_from_dsn_table(
%args,
@@ -531,6 +530,14 @@ sub wait_for_master {
my $result;
my $waited;
if ( $master_status ) {
my $slave_status = $self->get_slave_status($slave_dbh);
if (!$slave_status) {
return {
result => undef,
waited => 0,
error =>'Wait for master: this is a multi-master slave but "channel" was not specified on the command line',
};
}
my $server_version = VersionParser->new($slave_dbh);
my $channel_sql = $server_version > '5.6' && $self->{channel} ? ", '$self->{channel}'" : '';
my $sql = "SELECT MASTER_POS_WAIT('$master_status->{file}', $master_status->{position}, $timeout $channel_sql)";
@@ -614,6 +621,9 @@ sub catchup_to_master {
timeout => $timeout,
master_status => $master_status
);
if ($result->{error}) {
die $result->{error};
}
if ( !defined $result->{result} ) {
$slave_status = $self->get_slave_status($slave);
if ( !$self->slave_is_running($slave_status) ) {