mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-12-22 03:00:29 +08:00
MasterSlave check for errors on get_slave_status calls
This commit is contained in:
@@ -3952,8 +3952,11 @@ sub wait_for_master {
|
|||||||
my $result;
|
my $result;
|
||||||
my $waited;
|
my $waited;
|
||||||
if ( $master_status ) {
|
if ( $master_status ) {
|
||||||
my $slave_status = $self->get_slave_status($slave_dbh);
|
my $slave_status;
|
||||||
if (!$slave_status) {
|
eval {
|
||||||
|
$slave_status = $self->get_slave_status($slave_dbh);
|
||||||
|
};
|
||||||
|
if ($EVAL_ERROR) {
|
||||||
return {
|
return {
|
||||||
result => undef,
|
result => undef,
|
||||||
waited => 0,
|
waited => 0,
|
||||||
|
|||||||
@@ -527,8 +527,11 @@ sub wait_for_master {
|
|||||||
my $result;
|
my $result;
|
||||||
my $waited;
|
my $waited;
|
||||||
if ( $master_status ) {
|
if ( $master_status ) {
|
||||||
my $slave_status = $self->get_slave_status($slave_dbh);
|
my $slave_status;
|
||||||
if (!$slave_status) {
|
eval {
|
||||||
|
$slave_status = $self->get_slave_status($slave_dbh);
|
||||||
|
};
|
||||||
|
if ($EVAL_ERROR) {
|
||||||
return {
|
return {
|
||||||
result => undef,
|
result => undef,
|
||||||
waited => 0,
|
waited => 0,
|
||||||
|
|||||||
@@ -4233,8 +4233,11 @@ sub wait_for_master {
|
|||||||
my $result;
|
my $result;
|
||||||
my $waited;
|
my $waited;
|
||||||
if ( $master_status ) {
|
if ( $master_status ) {
|
||||||
my $slave_status = $self->get_slave_status($slave_dbh);
|
my $slave_status;
|
||||||
if (!$slave_status) {
|
eval {
|
||||||
|
$slave_status = $self->get_slave_status($slave_dbh);
|
||||||
|
};
|
||||||
|
if ($EVAL_ERROR) {
|
||||||
return {
|
return {
|
||||||
result => undef,
|
result => undef,
|
||||||
waited => 0,
|
waited => 0,
|
||||||
|
|||||||
@@ -4555,8 +4555,11 @@ sub wait_for_master {
|
|||||||
my $result;
|
my $result;
|
||||||
my $waited;
|
my $waited;
|
||||||
if ( $master_status ) {
|
if ( $master_status ) {
|
||||||
my $slave_status = $self->get_slave_status($slave_dbh);
|
my $slave_status;
|
||||||
if (!$slave_status) {
|
eval {
|
||||||
|
$slave_status = $self->get_slave_status($slave_dbh);
|
||||||
|
};
|
||||||
|
if ($EVAL_ERROR) {
|
||||||
return {
|
return {
|
||||||
result => undef,
|
result => undef,
|
||||||
waited => 0,
|
waited => 0,
|
||||||
|
|||||||
@@ -10851,8 +10851,11 @@ sub wait_for_master {
|
|||||||
my $result;
|
my $result;
|
||||||
my $waited;
|
my $waited;
|
||||||
if ( $master_status ) {
|
if ( $master_status ) {
|
||||||
my $slave_status = $self->get_slave_status($slave_dbh);
|
my $slave_status;
|
||||||
if (!$slave_status) {
|
eval {
|
||||||
|
$slave_status = $self->get_slave_status($slave_dbh);
|
||||||
|
};
|
||||||
|
if ($EVAL_ERROR) {
|
||||||
return {
|
return {
|
||||||
result => undef,
|
result => undef,
|
||||||
waited => 0,
|
waited => 0,
|
||||||
|
|||||||
@@ -2641,8 +2641,11 @@ sub wait_for_master {
|
|||||||
my $result;
|
my $result;
|
||||||
my $waited;
|
my $waited;
|
||||||
if ( $master_status ) {
|
if ( $master_status ) {
|
||||||
my $slave_status = $self->get_slave_status($slave_dbh);
|
my $slave_status;
|
||||||
if (!$slave_status) {
|
eval {
|
||||||
|
$slave_status = $self->get_slave_status($slave_dbh);
|
||||||
|
};
|
||||||
|
if ($EVAL_ERROR) {
|
||||||
return {
|
return {
|
||||||
result => undef,
|
result => undef,
|
||||||
waited => 0,
|
waited => 0,
|
||||||
|
|||||||
@@ -3052,8 +3052,11 @@ sub wait_for_master {
|
|||||||
my $result;
|
my $result;
|
||||||
my $waited;
|
my $waited;
|
||||||
if ( $master_status ) {
|
if ( $master_status ) {
|
||||||
my $slave_status = $self->get_slave_status($slave_dbh);
|
my $slave_status;
|
||||||
if (!$slave_status) {
|
eval {
|
||||||
|
$slave_status = $self->get_slave_status($slave_dbh);
|
||||||
|
};
|
||||||
|
if ($EVAL_ERROR) {
|
||||||
return {
|
return {
|
||||||
result => undef,
|
result => undef,
|
||||||
waited => 0,
|
waited => 0,
|
||||||
|
|||||||
@@ -5463,8 +5463,11 @@ sub wait_for_master {
|
|||||||
my $result;
|
my $result;
|
||||||
my $waited;
|
my $waited;
|
||||||
if ( $master_status ) {
|
if ( $master_status ) {
|
||||||
my $slave_status = $self->get_slave_status($slave_dbh);
|
my $slave_status;
|
||||||
if (!$slave_status) {
|
eval {
|
||||||
|
$slave_status = $self->get_slave_status($slave_dbh);
|
||||||
|
};
|
||||||
|
if ($EVAL_ERROR) {
|
||||||
return {
|
return {
|
||||||
result => undef,
|
result => undef,
|
||||||
waited => 0,
|
waited => 0,
|
||||||
|
|||||||
@@ -7035,8 +7035,11 @@ sub wait_for_master {
|
|||||||
my $result;
|
my $result;
|
||||||
my $waited;
|
my $waited;
|
||||||
if ( $master_status ) {
|
if ( $master_status ) {
|
||||||
my $slave_status = $self->get_slave_status($slave_dbh);
|
my $slave_status;
|
||||||
if (!$slave_status) {
|
eval {
|
||||||
|
$slave_status = $self->get_slave_status($slave_dbh);
|
||||||
|
};
|
||||||
|
if ($EVAL_ERROR) {
|
||||||
return {
|
return {
|
||||||
result => undef,
|
result => undef,
|
||||||
waited => 0,
|
waited => 0,
|
||||||
|
|||||||
@@ -533,8 +533,11 @@ sub wait_for_master {
|
|||||||
my $result;
|
my $result;
|
||||||
my $waited;
|
my $waited;
|
||||||
if ( $master_status ) {
|
if ( $master_status ) {
|
||||||
my $slave_status = $self->get_slave_status($slave_dbh);
|
my $slave_status;
|
||||||
if (!$slave_status) {
|
eval {
|
||||||
|
$slave_status = $self->get_slave_status($slave_dbh);
|
||||||
|
};
|
||||||
|
if ($EVAL_ERROR) {
|
||||||
return {
|
return {
|
||||||
result => undef,
|
result => undef,
|
||||||
waited => 0,
|
waited => 0,
|
||||||
|
|||||||
@@ -752,7 +752,7 @@ like(
|
|||||||
|
|
||||||
SKIP: {
|
SKIP: {
|
||||||
|
|
||||||
skip "Only test on mysql 5.7" if ( $sandbox_version lt '5.7' );
|
skip "Only test on mysql 5.7",6 if ( $sandbox_version lt '5.7' );
|
||||||
|
|
||||||
my ($master1_dbh, $master1_dsn) = $sb->start_sandbox(
|
my ($master1_dbh, $master1_dsn) = $sb->start_sandbox(
|
||||||
server => 'chan_master1',
|
server => 'chan_master1',
|
||||||
@@ -772,42 +772,53 @@ SKIP: {
|
|||||||
$sb->load_file('chan_master2', "sandbox/gtid_on.sql", undef, no_wait => 1);
|
$sb->load_file('chan_master2', "sandbox/gtid_on.sql", undef, no_wait => 1);
|
||||||
$sb->load_file('chan_slave1', "sandbox/slave_channels.sql", undef, no_wait => 1);
|
$sb->load_file('chan_slave1', "sandbox/slave_channels.sql", undef, no_wait => 1);
|
||||||
|
|
||||||
my $chan_slaves = $ms->get_slaves(
|
my $chan_slaves;
|
||||||
dbh => $master1_dbh,
|
eval {
|
||||||
dsn => $master1_dsn,
|
$chan_slaves = $ms->get_slaves(
|
||||||
make_cxn => sub {
|
dbh => $master1_dbh,
|
||||||
my $cxn = new Cxn(
|
dsn => $master1_dsn,
|
||||||
@_,
|
make_cxn => sub {
|
||||||
DSNParser => $dp,
|
my $cxn = new Cxn(
|
||||||
OptionParser => $o,
|
@_,
|
||||||
);
|
DSNParser => $dp,
|
||||||
$cxn->connect();
|
OptionParser => $o,
|
||||||
return $cxn;
|
);
|
||||||
},
|
$cxn->connect();
|
||||||
);
|
return $cxn;
|
||||||
|
},
|
||||||
our $message;
|
);
|
||||||
local $SIG{__WARN__} = sub {
|
|
||||||
$message = shift;
|
|
||||||
};
|
};
|
||||||
my $css = $ms->get_slave_status($slave1_dbh);
|
|
||||||
local $SIG{__WARN__} = undef;
|
#local $SIG{__WARN__} = sub {
|
||||||
|
# $message = shift;
|
||||||
|
#};
|
||||||
|
my $css;
|
||||||
|
eval {
|
||||||
|
$css = $ms->get_slave_status($slave1_dbh);
|
||||||
|
};
|
||||||
|
#local $SIG{__WARN__} = undef;
|
||||||
is (
|
is (
|
||||||
$css,
|
$css,
|
||||||
undef,
|
undef,
|
||||||
'Cannot determine slave in a multi source config without --channel param'
|
'Cannot determine slave in a multi source config without --channel param'
|
||||||
);
|
);
|
||||||
|
|
||||||
like (
|
like (
|
||||||
$message,
|
$EVAL_ERROR,
|
||||||
qr/This server returned more than one row for SHOW SLAVE STATUS/,
|
qr/This server returned more than one row for SHOW SLAVE STATUS/,
|
||||||
'Got warning message if we cannot determine slave in a multi source config without --channel param',
|
'Got warning message if we cannot determine slave in a multi source config without --channel param',
|
||||||
);
|
);
|
||||||
|
|
||||||
my $wfm = $ms->wait_for_master(
|
my $wfm;
|
||||||
master_status => $ms->get_master_status($dbh),
|
eval {
|
||||||
slave_dbh => $slave1_dbh,
|
$wfm = $ms->wait_for_master(
|
||||||
timeout => 1,
|
master_status => $ms->get_master_status($dbh),
|
||||||
);
|
slave_dbh => $slave1_dbh,
|
||||||
|
timeout => 1,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
warn ">>>>>> @_" if @_;
|
||||||
|
|
||||||
like(
|
like(
|
||||||
$wfm->{error},
|
$wfm->{error},
|
||||||
qr/"channel" was not specified on the command line/,
|
qr/"channel" was not specified on the command line/,
|
||||||
@@ -819,7 +830,9 @@ SKIP: {
|
|||||||
# It should return undef
|
# It should return undef
|
||||||
$slave1_dbh->do("STOP SLAVE for channel 'masterchan2'");
|
$slave1_dbh->do("STOP SLAVE for channel 'masterchan2'");
|
||||||
|
|
||||||
$css = $ms->get_slave_status($slave1_dbh);
|
eval {
|
||||||
|
$css = $ms->get_slave_status($slave1_dbh);
|
||||||
|
};
|
||||||
is (
|
is (
|
||||||
$css,
|
$css,
|
||||||
undef,
|
undef,
|
||||||
|
|||||||
Reference in New Issue
Block a user