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 }; }