~percona-toolkit-dev/percona-toolkit/release-2.2.11

« back to all changes in this revision

Viewing changes to lib/RowChecksum.pm

pt-table-checksum-PXC-inconsistent-results-upon-resume-1311654

Show diffs side-by-side

added added

removed removed

Lines of Context:
459
459
   }
460
460
   my ($dbh, $repl_table) = @args{@required_args};
461
461
 
462
 
   my $sql
463
 
      = "SELECT CONCAT(db, '.', tbl) AS `table`, "
464
 
      . "chunk, chunk_index, lower_boundary, upper_boundary, "
465
 
      . "COALESCE(this_cnt-master_cnt, 0) AS cnt_diff, "
466
 
      . "COALESCE("
467
 
      .   "this_crc <> master_crc OR ISNULL(master_crc) <> ISNULL(this_crc), 0"
468
 
      . ") AS crc_diff, this_cnt, master_cnt, this_crc, master_crc "
469
 
      . "FROM $repl_table "
470
 
      . "WHERE (master_cnt <> this_cnt OR master_crc <> this_crc "
471
 
      .        "OR ISNULL(master_crc) <> ISNULL(this_crc))"
472
 
      . ($args{where} ? " AND ($args{where})" : "");
473
 
   PTDEBUG && _d($sql);
474
 
   my $diffs = $dbh->selectall_arrayref($sql, { Slice => {} });
 
462
    
 
463
   my $tries = $self->{'OptionParser'}->get('replicate-check-retries') || 1; 
 
464
   my $diffs;
 
465
   while ($tries--) {
 
466
      my $sql
 
467
         = "SELECT CONCAT(db, '.', tbl) AS `table`, "
 
468
         . "chunk, chunk_index, lower_boundary, upper_boundary, "
 
469
         . "COALESCE(this_cnt-master_cnt, 0) AS cnt_diff, "
 
470
         . "COALESCE("
 
471
         .   "this_crc <> master_crc OR ISNULL(master_crc) <> ISNULL(this_crc), 0"
 
472
         . ") AS crc_diff, this_cnt, master_cnt, this_crc, master_crc "
 
473
         . "FROM $repl_table "
 
474
         . "WHERE (master_cnt <> this_cnt OR master_crc <> this_crc "
 
475
         .        "OR ISNULL(master_crc) <> ISNULL(this_crc)) "
 
476
         . ($args{where} ? " AND ($args{where})" : "");
 
477
      PTDEBUG && _d($sql);
 
478
      $diffs = $dbh->selectall_arrayref($sql, { Slice => {} });
 
479
      if (!@$diffs || !$tries) { # if no differences are found OR we are out of tries left...
 
480
         last;                   # get out now
 
481
      }
 
482
      sleep 1;            
 
483
   }
475
484
   return $diffs;
476
485
}
477
486