~bisscuitt/percona-toolkit/lsof_find

« back to all changes in this revision

Viewing changes to bin/pt-table-checksum

  • Committer: Frank Cizmich
  • Date: 2014-09-08 19:27:40 UTC
  • mfrom: (608.1.8 release-2.2.10)
  • Revision ID: frank.cizmich@percona.com-20140908192740-uab3exq8je1qbczh
merged release-2.2.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
{
58
58
package Percona::Toolkit;
59
59
 
60
 
our $VERSION = '2.2.9';
 
60
our $VERSION = '2.2.10';
61
61
 
62
62
use strict;
63
63
use warnings FATAL => 'all';
5977
5977
   }
5978
5978
   my ($dbh, $repl_table) = @args{@required_args};
5979
5979
 
5980
 
   my $sql
5981
 
      = "SELECT CONCAT(db, '.', tbl) AS `table`, "
5982
 
      . "chunk, chunk_index, lower_boundary, upper_boundary, "
5983
 
      . "COALESCE(this_cnt-master_cnt, 0) AS cnt_diff, "
5984
 
      . "COALESCE("
5985
 
      .   "this_crc <> master_crc OR ISNULL(master_crc) <> ISNULL(this_crc), 0"
5986
 
      . ") AS crc_diff, this_cnt, master_cnt, this_crc, master_crc "
5987
 
      . "FROM $repl_table "
5988
 
      . "WHERE (master_cnt <> this_cnt OR master_crc <> this_crc "
5989
 
      .        "OR ISNULL(master_crc) <> ISNULL(this_crc))"
5990
 
      . ($args{where} ? " AND ($args{where})" : "");
5991
 
   PTDEBUG && _d($sql);
5992
 
   my $diffs = $dbh->selectall_arrayref($sql, { Slice => {} });
 
5980
    
 
5981
   my $tries = $self->{'OptionParser'}->get('replicate-check-retries') || 1; 
 
5982
   my $diffs;
 
5983
   while ($tries--) {
 
5984
      my $sql
 
5985
         = "SELECT CONCAT(db, '.', tbl) AS `table`, "
 
5986
         . "chunk, chunk_index, lower_boundary, upper_boundary, "
 
5987
         . "COALESCE(this_cnt-master_cnt, 0) AS cnt_diff, "
 
5988
         . "COALESCE("
 
5989
         .   "this_crc <> master_crc OR ISNULL(master_crc) <> ISNULL(this_crc), 0"
 
5990
         . ") AS crc_diff, this_cnt, master_cnt, this_crc, master_crc "
 
5991
         . "FROM $repl_table "
 
5992
         . "WHERE (master_cnt <> this_cnt OR master_crc <> this_crc "
 
5993
         .        "OR ISNULL(master_crc) <> ISNULL(this_crc)) "
 
5994
         . ($args{where} ? " AND ($args{where})" : "");
 
5995
      PTDEBUG && _d($sql);
 
5996
      $diffs = $dbh->selectall_arrayref($sql, { Slice => {} });
 
5997
      if (!@$diffs || !$tries) { # if no differences are found OR we are out of tries left...
 
5998
         last;                   # get out now
 
5999
      }
 
6000
      sleep 1;            
 
6001
   }
5993
6002
   return $diffs;
5994
6003
}
5995
6004
 
8347
8356
 
8348
8357
use strict;
8349
8358
use warnings FATAL => 'all';
 
8359
use POSIX qw( ceil );
8350
8360
use English qw(-no_match_vars);
8351
8361
use constant PTDEBUG => $ENV{PTDEBUG} || 0;
8352
8362
 
8512
8522
      }
8513
8523
      else {
8514
8524
         PTDEBUG && _d('Initial', $var, 'value:', $init_val);
8515
 
         $val = int(($init_val * $threshold_factor) + $init_val);
8516
 
         $vars->{$var} = $val;
 
8525
         $val = ($init_val * $threshold_factor) + $init_val;
 
8526
         $vars->{$var} = int(ceil($val));
8517
8527
      }
8518
8528
      PTDEBUG && _d('Wait if', $var, '>=', $val);
8519
8529
   }
8964
8974
   $print_header = 1;
8965
8975
   $exit_status  = 0;
8966
8976
 
 
8977
 
8967
8978
   # ########################################################################
8968
8979
   # Get configuration information.
8969
8980
   # ########################################################################
10072
10083
         # Should be done automatically, but I like to be explicit.
10073
10084
         $fetch_sth->finish();
10074
10085
         $update_sth->finish();
 
10086
         $delete_sth->finish();
10075
10087
 
10076
10088
         # Update rate, chunk size, and progress if the nibble actually
10077
10089
         # selected some rows.
10382
10394
   return $msg ? "$ts $msg" : $ts;
10383
10395
}
10384
10396
 
 
10397
 
10385
10398
sub nibble_is_safe {
10386
10399
   my (%args) = @_;
10387
10400
   my @required_args = qw(Cxn tbl NibbleIterator OptionParser);
10561
10574
 
10562
10575
         if (   $error =~ m/Lock wait timeout exceeded/
10563
10576
             || $error =~ m/Query execution was interrupted/
 
10577
             || $error =~ m/Deadlock found/
10564
10578
         ) {
10565
10579
            # These errors/warnings can be retried, so don't print
10566
10580
            # a warning yet; do that in final_fail.
10584
10598
         my (%args) = @_;
10585
10599
         my $error = $args{error};
10586
10600
 
10587
 
         if (   $error =~ /Lock wait timeout exceeded/
10588
 
             || $error =~ /Query execution was interrupted/
 
10601
         if (   $error =~ m/Lock wait timeout exceeded/
 
10602
             || $error =~ m/Query execution was interrupted/
 
10603
             || $error =~ m/Deadlock found/
10589
10604
         ) {
10590
10605
            # These errors/warnings are not fatal but only cause this
10591
10606
            # nibble to be skipped.
12287
12302
if you run pt-table-checksum quietly in a cron job, for example, and later want
12288
12303
a report on the results of the cron job, perhaps to implement a Nagios check.
12289
12304
 
 
12305
=item --replicate-check-retries
 
12306
 
 
12307
type: int; default: 1
 
12308
 
 
12309
Retry checksum comparison this many times when a difference is encountered.
 
12310
Only when a difference persists after this number of checks is it considered valid.
 
12311
Using this option with a value of 2 or more alleviates spurious differences that 
 
12312
arise when using the --resume option.
 
12313
 
12290
12314
=item --replicate-database
12291
12315
 
12292
12316
type: string
12674
12698
 
12675
12699
=head1 VERSION
12676
12700
 
12677
 
pt-table-checksum 2.2.9
 
12701
pt-table-checksum 2.2.10
12678
12702
 
12679
12703
=cut