mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-10-19 17:04:00 +00:00
Use new style Retry in TableSyncer.pm.
This commit is contained in:
@@ -515,11 +515,12 @@ sub lock_and_wait {
|
|||||||
# If there is any error beyond this point, we need to unlock/commit.
|
# If there is any error beyond this point, we need to unlock/commit.
|
||||||
eval {
|
eval {
|
||||||
if ( my $timeout = $args{wait} ) {
|
if ( my $timeout = $args{wait} ) {
|
||||||
my $wait = $args{wait_retry_args}->{wait} || 10;
|
my $ms = $self->{MasterSlave};
|
||||||
my $tries = $args{wait_retry_args}->{tries} || 3;
|
my $tries = $args{wait_retry_args}->{tries} || 3;
|
||||||
|
my $wait;
|
||||||
$self->{Retry}->retry(
|
$self->{Retry}->retry(
|
||||||
wait => sub { sleep $wait; },
|
|
||||||
tries => $tries,
|
tries => $tries,
|
||||||
|
wait => sub { sleep $args{wait_retry_args}->{wait} || 10 },
|
||||||
try => sub {
|
try => sub {
|
||||||
my ( %args ) = @_;
|
my ( %args ) = @_;
|
||||||
# Be careful using $args{...} in this callback! %args in
|
# Be careful using $args{...} in this callback! %args in
|
||||||
@@ -532,12 +533,18 @@ sub lock_and_wait {
|
|||||||
# Always use the misc_dbh dbh to check the master's position
|
# Always use the misc_dbh dbh to check the master's position
|
||||||
# because the main dbh might be in use due to executing
|
# because the main dbh might be in use due to executing
|
||||||
# $src_sth.
|
# $src_sth.
|
||||||
my $ms = $self->{MasterSlave};
|
$wait = $ms->wait_for_master(
|
||||||
my $wait = $ms->wait_for_master(
|
|
||||||
master_status => $ms->get_master_status($src->{misc_dbh}),
|
master_status => $ms->get_master_status($src->{misc_dbh}),
|
||||||
slave_dbh => $dst->{dbh},
|
slave_dbh => $dst->{dbh},
|
||||||
timeout => $timeout,
|
timeout => $timeout,
|
||||||
);
|
);
|
||||||
|
if ( defined $wait->{result} && $wait->{result} != -1 ) {
|
||||||
|
return; # slave caught up
|
||||||
|
}
|
||||||
|
die; # call fail
|
||||||
|
},
|
||||||
|
fail => sub {
|
||||||
|
my (%args) = @_;
|
||||||
if ( !defined $wait->{result} ) {
|
if ( !defined $wait->{result} ) {
|
||||||
# Slave was stopped either before or during the wait.
|
# Slave was stopped either before or during the wait.
|
||||||
# Wait a few seconds and try again in hopes that the
|
# Wait a few seconds and try again in hopes that the
|
||||||
@@ -559,24 +566,16 @@ sub lock_and_wait {
|
|||||||
$msg .= " Sleeping $wait seconds then retrying "
|
$msg .= " Sleeping $wait seconds then retrying "
|
||||||
. ($tries - $args{tryno}) . " more times.";
|
. ($tries - $args{tryno}) . " more times.";
|
||||||
}
|
}
|
||||||
warn $msg;
|
warn "$msg\n";
|
||||||
return;
|
return 1; # call wait, call try
|
||||||
}
|
}
|
||||||
elsif ( $wait->{result} == -1 ) {
|
elsif ( $wait->{result} == -1 ) {
|
||||||
# No more retries will be attempted if we die here since
|
# MASTER_POS_WAIT timed out, don't retry since we've
|
||||||
# retry_on_die is not set. on_failure will be called.
|
# already waited as long as the user specified with --wait.
|
||||||
# Since we already waited as long as the user specified
|
return 0; # call final_fail
|
||||||
# with --wait, we don't need to retry and wait any longer.
|
|
||||||
die "Slave did not catch up to its master after waiting "
|
|
||||||
. "$timeout seconds with MASTER_POS_WAIT. Try inceasing "
|
|
||||||
. "the --wait time, or disable this feature by specifying "
|
|
||||||
. "--wait 0.";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return $result; # slave caught up
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
on_failure => sub {
|
final_fail => sub {
|
||||||
die "Slave did not catch up to its master after $tries attempts "
|
die "Slave did not catch up to its master after $tries attempts "
|
||||||
. "of waiting $timeout seconds with MASTER_POS_WAIT. "
|
. "of waiting $timeout seconds with MASTER_POS_WAIT. "
|
||||||
. "Check that the slave is running, increase the --wait "
|
. "Check that the slave is running, increase the --wait "
|
||||||
|
Reference in New Issue
Block a user