modified RowChecksum module and updated it in pt-table-checksum (only tool that uses it)

This commit is contained in:
Frank Cizmich
2014-07-31 18:26:45 -03:00
parent fa8254712b
commit b2bf471e7d
2 changed files with 41 additions and 27 deletions

View File

@@ -5977,9 +5977,10 @@ sub find_replication_differences {
} }
my ($dbh, $repl_table) = @args{@required_args}; my ($dbh, $repl_table) = @args{@required_args};
my $ts_clause = $self->{start_ts} ? " AND ts >= '$self->{start_ts}' " : ''; # issue 1311654
my $ts_clause = $self->{start_ts} ? " AND ts >= '$self->{start_ts}' " : ''; # only check rows created in this run
my $tries = 5; # try again up to five times if replication checksum don't agree.
my $ok_to_leave = 0; my $ok_to_leave = 0;
my $tries = 5; # number of times to try again if replication checksum don't agree.
my $diffs; my $diffs;
do { do {
my $sql my $sql
@@ -6001,7 +6002,6 @@ sub find_replication_differences {
} else { } else {
$ok_to_leave = 1; $ok_to_leave = 1;
} }
} until ($ok_to_leave || !$tries); } until ($ok_to_leave || !$tries);
return $diffs; return $diffs;
} }
@@ -8978,8 +8978,9 @@ sub main {
$print_header = 1; $print_header = 1;
$exit_status = 0; $exit_status = 0;
$start_ts = full_ts(); # issue 1311654 # get start time
PTDEBUG && _d("initial start_ts: [$start_ts]"); $start_ts = full_ts();
PTDEBUG && _d("initial start_ts: $start_ts");
# ######################################################################## # ########################################################################
# Get configuration information. # Get configuration information.

View File

@@ -459,6 +459,12 @@ sub find_replication_differences {
} }
my ($dbh, $repl_table) = @args{@required_args}; my ($dbh, $repl_table) = @args{@required_args};
my $ts_clause = $self->{start_ts} ? " AND ts >= '$self->{start_ts}' " : ''; # only check rows created in this run
my $tries = 5; # try again up to five times if replication checksum don't agree.
my $ok_to_leave = 0;
my $diffs;
do {
my $sql my $sql
= "SELECT CONCAT(db, '.', tbl) AS `table`, " = "SELECT CONCAT(db, '.', tbl) AS `table`, "
. "chunk, chunk_index, lower_boundary, upper_boundary, " . "chunk, chunk_index, lower_boundary, upper_boundary, "
@@ -468,10 +474,17 @@ sub find_replication_differences {
. ") AS crc_diff, this_cnt, master_cnt, this_crc, master_crc " . ") AS crc_diff, this_cnt, master_cnt, this_crc, master_crc "
. "FROM $repl_table " . "FROM $repl_table "
. "WHERE (master_cnt <> this_cnt OR master_crc <> this_crc " . "WHERE (master_cnt <> this_cnt OR master_crc <> this_crc "
. "OR ISNULL(master_crc) <> ISNULL(this_crc))" . "OR ISNULL(master_crc) <> ISNULL(this_crc)) $ts_clause"
. ($args{where} ? " AND ($args{where})" : ""); . ($args{where} ? " AND ($args{where})" : "");
PTDEBUG && _d($sql); PTDEBUG && _d($sql);
my $diffs = $dbh->selectall_arrayref($sql, { Slice => {} }); $diffs = $dbh->selectall_arrayref($sql, { Slice => {} });
$tries--;
if (@$diffs) {
sleep 1;
} else {
$ok_to_leave = 1;
}
} until ($ok_to_leave || !$tries);
return $diffs; return $diffs;
} }