Report DIFFS as the true number of unique chunks that differ across all slaves.

This commit is contained in:
Daniel Nichter
2012-07-27 11:30:33 -06:00
parent 1875c92674
commit 203b0a9cb6
2 changed files with 21 additions and 8 deletions

View File

@@ -7690,7 +7690,7 @@ sub main {
);
# Check each slave for checksum diffs.
my $max_diffs = 0;
my %diff_chunks;
foreach my $slave ( @$slaves ) {
eval {
my $diffs = $rc->find_replication_differences(
@@ -7700,10 +7700,9 @@ sub main {
);
PTDEBUG && _d(scalar @$diffs, 'checksum diffs on',
$slave->name());
if ( my $n_diffs = scalar @$diffs ) {
# https://bugs.launchpad.net/percona-toolkit/+bug/1030031
$max_diffs = $n_diffs if $n_diffs > $max_diffs;
}
# Save unique chunks that differ.
# https://bugs.launchpad.net/percona-toolkit/+bug/1030031
map { $diff_chunks{ $_->{chunk} }++ } @$diffs;
};
if ($EVAL_ERROR) {
if ( $o->get('quiet') < 2 ) {
@@ -7716,7 +7715,7 @@ sub main {
$tbl->{checksum_results}->{errors}++;
}
}
$tbl->{checksum_results}->{diffs} = $max_diffs;
$tbl->{checksum_results}->{diffs} = scalar keys %diff_chunks;
}
# Print table's checksum results if we're not being quiet,

View File

@@ -42,7 +42,7 @@ elsif ( !$slave2_dbh ) {
plan skip_all => 'Cannot connect to sandbox slave2';
}
else {
plan tests => 9;
plan tests => 10;
}
# The sandbox servers run with lock_wait_timeout=3 and it's not dynamic
@@ -155,7 +155,6 @@ $slave1_dbh->do("SET SQL_LOG_BIN=1");
$output = output(
sub { pt_table_checksum::main(@args, qw(-t test.t --chunk-size 10)) },
stderr => 1,
);
is(
@@ -164,6 +163,21 @@ is(
"Bug 1030031 (wrong DIFFS): 2 diffs"
);
# Restore slave2, but then give it 1 diff that's not the same chunk#
# as slave1, so there's 3 unique chunk that differ.
$slave2_dbh->do("UPDATE test.t SET c='e' WHERE id=5");
$slave2_dbh->do("UPDATE test.t SET c='' WHERE id=26");
$output = output(
sub { pt_table_checksum::main(@args, qw(-t test.t --chunk-size 10)) },
);
is(
PerconaTest::count_checksum_results($output, 'diffs'),
3,
"Bug 1030031 (wrong DIFFS): 3 diffs"
);
# #############################################################################
# Done.
# #############################################################################