mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-12-19 01:09:21 +08:00
Don't die on slave lag check, return undef and wait forever.
This commit is contained in:
21
bin/foo.pm
Normal file
21
bin/foo.pm
Normal 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;
|
||||||
@@ -8462,13 +8462,25 @@ sub main {
|
|||||||
if ( !$dbh || !$dbh->ping() ) {
|
if ( !$dbh || !$dbh->ping() ) {
|
||||||
eval { $dbh = $cxn->connect() }; # connect or die trying
|
eval { $dbh = $cxn->connect() }; # connect or die trying
|
||||||
if ( $EVAL_ERROR ) {
|
if ( $EVAL_ERROR ) {
|
||||||
$oktorun = 0; # flag for cleanup tasks
|
# As the docs say: "The tool waits forever for replicas
|
||||||
chomp $EVAL_ERROR;
|
# to stop lagging. If any replica is stopped, the tool
|
||||||
die "Lost connection to replica " . $cxn->name()
|
# waits forever until the replica is started."
|
||||||
. " while attempting to get its lag ($EVAL_ERROR)\n";
|
# 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
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user