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

This commit is contained in:
Frank Cizmich
2014-07-17 17:50:37 -03:00
parent ce0a9b0422
commit fa8254712b
6 changed files with 45 additions and 19 deletions
+39 -13
View File
@@ -5977,19 +5977,32 @@ sub find_replication_differences {
}
my ($dbh, $repl_table) = @args{@required_args};
my $sql
= "SELECT CONCAT(db, '.', tbl) AS `table`, "
. "chunk, chunk_index, lower_boundary, upper_boundary, "
. "COALESCE(this_cnt-master_cnt, 0) AS cnt_diff, "
. "COALESCE("
. "this_crc <> master_crc OR ISNULL(master_crc) <> ISNULL(this_crc), 0"
. ") AS crc_diff, this_cnt, master_cnt, this_crc, master_crc "
. "FROM $repl_table "
. "WHERE (master_cnt <> this_cnt OR master_crc <> this_crc "
. "OR ISNULL(master_crc) <> ISNULL(this_crc))"
. ($args{where} ? " AND ($args{where})" : "");
PTDEBUG && _d($sql);
my $diffs = $dbh->selectall_arrayref($sql, { Slice => {} });
my $ts_clause = $self->{start_ts} ? " AND ts >= '$self->{start_ts}' " : ''; # issue 1311654
my $ok_to_leave = 0;
my $tries = 5; # number of times to try again if replication checksum don't agree.
my $diffs;
do {
my $sql
= "SELECT CONCAT(db, '.', tbl) AS `table`, "
. "chunk, chunk_index, lower_boundary, upper_boundary, "
. "COALESCE(this_cnt-master_cnt, 0) AS cnt_diff, "
. "COALESCE("
. "this_crc <> master_crc OR ISNULL(master_crc) <> ISNULL(this_crc), 0"
. ") AS crc_diff, this_cnt, master_cnt, this_crc, master_crc "
. "FROM $repl_table "
. "WHERE (master_cnt <> this_cnt OR master_crc <> this_crc "
. "OR ISNULL(master_crc) <> ISNULL(this_crc)) $ts_clause"
. ($args{where} ? " AND ($args{where})" : "");
PTDEBUG && _d($sql);
$diffs = $dbh->selectall_arrayref($sql, { Slice => {} });
$tries--;
if (@$diffs) {
sleep 1;
} else {
$ok_to_leave = 1;
}
} until ($ok_to_leave || !$tries);
return $diffs;
}
@@ -8917,6 +8930,7 @@ use sigtrap 'handler', \&sig_int, 'normal-signals';
my $oktorun = 1;
my $print_header = 1;
my $exit_status = 0;
my $start_ts = 0; # issue 1311654
# "exit codes 1 - 2, 126 - 165, and 255 [1] have special meanings,
# and should therefore be avoided for user-specified exit parameters"
@@ -8964,6 +8978,9 @@ sub main {
$print_header = 1;
$exit_status = 0;
$start_ts = full_ts(); # issue 1311654
PTDEBUG && _d("initial start_ts: [$start_ts]");
# ########################################################################
# Get configuration information.
# ########################################################################
@@ -10072,6 +10089,7 @@ sub main {
# Should be done automatically, but I like to be explicit.
$fetch_sth->finish();
$update_sth->finish();
$delete_sth->finish();
# Update rate, chunk size, and progress if the nibble actually
# selected some rows.
@@ -10382,6 +10400,14 @@ sub ts {
return $msg ? "$ts $msg" : $ts;
}
sub full_ts {
my ($msg) = @_;
my ($s, $m, $h, $d, $M, $Y) = localtime;
$Y += 1900;
my $ts = sprintf('%04d-%02d-%02dT%02d:%02d:%02d', $Y, $M+1, $d, $h, $m, $s);
return $msg ? "$ts $msg" : $ts;
}
sub nibble_is_safe {
my (%args) = @_;
my @required_args = qw(Cxn tbl NibbleIterator OptionParser);
+2 -2
View File
@@ -80,8 +80,8 @@ ok(
# other than to ensure that there's at least one for each table.
$row = $master_dbh->selectrow_arrayref("select count(*) from percona.checksums");
ok(
$row->[0] > 30 && $row->[0] < 50,
'Between 30 and 50 chunks'
$row->[0] > 30 && $row->[0] < 60,
'Between 30 and 60 chunks'
) or diag($row->[0]);
# ############################################################################
@@ -21,7 +21,7 @@ ERRORS DIFFS ROWS SKIPPED TABLE
0 0 0 0 mysql.time_zone_transition
0 0 0 0 mysql.time_zone_transition_type
0 0 2 0 mysql.user
0 0 38 0 percona_test.checksums
0 0 22 0 percona_test.checksums
0 0 1 0 percona_test.load_data
0 0 1 0 percona_test.sentinel
0 0 200 0 sakila.actor
@@ -20,7 +20,7 @@ ERRORS DIFFS ROWS SKIPPED TABLE
0 0 0 0 mysql.time_zone_transition
0 0 0 0 mysql.time_zone_transition_type
0 0 2 0 mysql.user
0 0 37 0 percona_test.checksums
0 0 22 0 percona_test.checksums
0 0 1 0 percona_test.load_data
0 0 1 0 percona_test.sentinel
0 0 200 0 sakila.actor
@@ -21,7 +21,7 @@ ERRORS DIFFS ROWS CHUNKS SKIPPED TABLE
0 0 0 1 0 mysql.time_zone_transition
0 0 0 1 0 mysql.time_zone_transition_type
0 0 2 1 0 mysql.user
0 0 38 1 0 percona_test.checksums
0 0 22 1 0 percona_test.checksums
0 0 1 1 0 percona_test.load_data
0 0 1 1 0 percona_test.sentinel
0 0 200 1 0 sakila.actor
@@ -20,7 +20,7 @@ ERRORS DIFFS ROWS CHUNKS SKIPPED TABLE
0 0 0 1 0 mysql.time_zone_transition
0 0 0 1 0 mysql.time_zone_transition_type
0 0 2 1 0 mysql.user
0 0 37 1 0 percona_test.checksums
0 0 22 1 0 percona_test.checksums
0 0 1 1 0 percona_test.load_data
0 0 1 1 0 percona_test.sentinel
0 0 200 1 0 sakila.actor