From e7bfc1c4e63e0ac76a93cb334007c791732b200b Mon Sep 17 00:00:00 2001 From: Daniel Nichter Date: Tue, 3 Nov 2015 15:32:55 -0800 Subject: [PATCH] Don't die on slave lag check, return undef and wait forever. --- bin/foo.pm | 21 +++++++++++++++++++++ bin/pt-online-schema-change | 22 +++++++++++++++++----- 2 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 bin/foo.pm diff --git a/bin/foo.pm b/bin/foo.pm new file mode 100644 index 00000000..bc4c9a56 --- /dev/null +++ b/bin/foo.pm @@ -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; diff --git a/bin/pt-online-schema-change b/bin/pt-online-schema-change index 435d9c6b..9fc55371 100755 --- a/bin/pt-online-schema-change +++ b/bin/pt-online-schema-change @@ -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 }; }