Don't die on slave lag check, return undef and wait forever.

This commit is contained in:
Daniel Nichter
2015-11-03 15:32:55 -08:00
parent a1e74634fd
commit e7bfc1c4e6
2 changed files with 38 additions and 5 deletions

21
bin/foo.pm Normal file
View File

@@ -0,0 +1,21 @@
package pt_online_schema_change_plugin;
use strict;
use warnings;
sub new {
my ( $class, %args ) = @_;
my $self = {};
return bless $self, $class;
}
sub before_swap_tables {
my ($self, %args) = @_;
print `mysql -e "select * From mysql.innodb_index_stats where database_name='test'"`;
print `mysql -e "select * From mysql.innodb_table_stats where database_name='test'"`;
sleep 12;
print `mysql -e "select * From mysql.innodb_index_stats where database_name='test'"`;
print `mysql -e "select * From mysql.innodb_table_stats where database_name='test'"`;
}
1;

View File

@@ -8462,13 +8462,25 @@ sub main {
if ( !$dbh || !$dbh->ping() ) {
eval { $dbh = $cxn->connect() }; # connect or die trying
if ( $EVAL_ERROR ) {
$oktorun = 0; # flag for cleanup tasks
chomp $EVAL_ERROR;
die "Lost connection to replica " . $cxn->name()
. " while attempting to get its lag ($EVAL_ERROR)\n";
# As the docs say: "The tool waits forever for replicas
# to stop lagging. If any replica is stopped, the tool
# waits forever until the replica is started."
# https://bugs.launchpad.net/percona-toolkit/+bug/1402051
PTDEBUG && _d('Cannot connect to', $cxn->name(), ':',
$EVAL_ERROR);
# Make ReplicaLagWaiter::wait() report slave is stopped.
return undef;
}
}
return $ms->get_slave_lag($dbh);
my $lag;
eval {
$lag = $ms->get_slave_lag($dbh);
};
if ( $EVAL_ERROR ) {
PTDEBUG && _d('Cannot get lag for', $cxn->name(), ':',
$EVAL_ERROR);
}
return $lag; # undef if error
};
}