mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-07 04:49:48 +00:00
PT-139 wait_for_master returns error if no channel was specified in a multi master env
This commit is contained in:
@@ -6237,6 +6237,9 @@ sub lock_and_wait {
|
||||
slave_dbh => $dst->{dbh},
|
||||
timeout => $timeout,
|
||||
);
|
||||
if ($wait->{error}) {
|
||||
die $result->{error};
|
||||
}
|
||||
if ( defined $wait->{result} && $wait->{result} != -1 ) {
|
||||
return; # slave caught up
|
||||
}
|
||||
@@ -7011,6 +7014,15 @@ 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 =>'This server returned more than one row for SHOW SLAVE STATUS 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)";
|
||||
@@ -7030,6 +7042,7 @@ sub wait_for_master {
|
||||
return {
|
||||
result => $result,
|
||||
waited => $waited,
|
||||
error => undef,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -7079,6 +7092,10 @@ 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) ) {
|
||||
|
@@ -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) ) {
|
||||
|
@@ -803,6 +803,17 @@ SKIP: {
|
||||
'Got warning message if we cannot determine slave in a multi source config without --channel param',
|
||||
);
|
||||
|
||||
my $wfm = $ms->wait_for_master(
|
||||
master_status => $ms->get_master_status($dbh),
|
||||
slave_dbh => $slave1_dbh,
|
||||
timeout => 1,
|
||||
);
|
||||
like(
|
||||
$wfm->{error},
|
||||
qr/"channel" was not specified on the command line/,
|
||||
'Wait for master returned error',
|
||||
);
|
||||
|
||||
# Now try specifying a channel name
|
||||
$ms->{channel} = 'masterchan1';
|
||||
$css = $ms->get_slave_status($slave1_dbh);
|
||||
@@ -812,6 +823,17 @@ SKIP: {
|
||||
'Returned the correct slave',
|
||||
);
|
||||
|
||||
$wfm = $ms->wait_for_master(
|
||||
master_status => $ms->get_master_status($dbh),
|
||||
slave_dbh => $slave1_dbh,
|
||||
timeout => 1,
|
||||
);
|
||||
is(
|
||||
$wfm->{error},
|
||||
undef,
|
||||
'Wait for master returned no error',
|
||||
);
|
||||
|
||||
$sb->stop_sandbox(qw(chan_master1 chan_master2 chan_slave1));
|
||||
}
|
||||
# #############################################################################
|
||||
|
Reference in New Issue
Block a user