~percona-toolkit-dev/percona-toolkit/fix-password-comma-bug-886077

« back to all changes in this revision

Viewing changes to lib/CopyRowsInsertSelect.pm

  • Committer: Daniel Nichter
  • Date: 2012-02-07 20:10:11 UTC
  • mfrom: (174 2.0)
  • mto: This revision was merged to the branch mainline in revision 189.
  • Revision ID: daniel@percona.com-20120207201011-sok2c1f2ay9qr3gm
Merge trunk r174.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
use strict;
27
27
use warnings FATAL => 'all';
28
28
use English qw(-no_match_vars);
29
 
use constant MKDEBUG => $ENV{MKDEBUG} || 0;
 
29
use constant PTDEBUG => $ENV{PTDEBUG} || 0;
30
30
 
31
31
# Sub: new
32
32
#
79
79
         $msg->($sql);
80
80
      }
81
81
      else {
82
 
         MKDEBUG && _d($dbh, $sql);
 
82
         PTDEBUG && _d($dbh, $sql);
83
83
         my $error;
84
84
         $self->{Retry}->retry(
85
85
            wait  => sub { sleep 1; },
86
86
            tries => 3,
87
87
            try   => sub {
88
 
               my ( %args ) = @_;
89
 
                  eval {
90
 
                     $dbh->do($sql);
91
 
                  };
92
 
                  if ( $EVAL_ERROR ) {
93
 
                     MKDEBUG && _d($EVAL_ERROR);
94
 
                     if ( $EVAL_ERROR =~ m/Lock wait timeout exceeded/ ) {
95
 
                        $error = $EVAL_ERROR;
96
 
                        if ( $args{tryno} > 1 ) {
97
 
                           $msg->("Lock wait timeout exceeded; retrying $sql");
98
 
                        }
99
 
                        return;
100
 
                     }
101
 
                     die $EVAL_ERROR;
102
 
                  }
103
 
                  return 1;
104
 
            },
105
 
            on_failure => sub { die $error; },
 
88
               $dbh->do($sql);
 
89
               return;
 
90
            },
 
91
            fail => sub {
 
92
               my (%args) = @_;
 
93
               my $error = $args{error};
 
94
               PTDEBUG && _d($error);
 
95
               if ( $error =~ m/Lock wait timeout exceeded/ ) {
 
96
                  $msg->("Lock wait timeout exceeded; retrying $sql");
 
97
                  return 1; # call wait, call try
 
98
               }
 
99
               return 0; # call final_fail
 
100
            },
 
101
            final_fail => sub {
 
102
               my (%args) = @_;
 
103
               die $args{error};
 
104
            },
106
105
         );
107
106
      }
108
107