Fix for 938660: pt-table-checksum chunk-size-limit of 0 does not disable chunk size limit checking

This commit is contained in:
Brian Fraser fraserb@gmail.com
2012-10-30 11:55:49 -03:00
parent d616a7e5e6
commit 1e3cc6131c
2 changed files with 26 additions and 11 deletions

View File

@@ -5831,7 +5831,7 @@ sub can_nibble {
$mysql_index = undef;
}
my $chunk_size_limit = $o->get('chunk-size-limit') || 1;
my $chunk_size_limit = $o->get('chunk-size-limit');
my $one_nibble = !defined $args{one_nibble} || $args{one_nibble}
? $row_est <= $chunk_size * $chunk_size_limit
: 0;
@@ -8878,7 +8878,8 @@ sub main {
# do || 1 so the limit is never 0 and empty tables are single-chunked.
# See: https://bugs.launchpad.net/percona-toolkit/+bug/987393
# This is used for the 1st purpose of --chunk-size-limit:
my $limit = $o->get('chunk-size-limit');
my $limit = $o->get('chunk-size-limit') || 1;
my $chunk_size_limit = $o->get('chunk-size-limit');
# ########################################################################
# Callbacks for each table's nibble iterator. All checksum work is done
@@ -8934,10 +8935,6 @@ sub main {
if ( $nibble_iter->one_nibble() ) {
PTDEBUG && _d('Getting table row estimate on replicas');
# This is used for the 2nd purpose for --chunkr-size-limit;
# see the large comment block above near my $limit = $o->...
my $chunk_size_limit = $o->get('chunk-size-limit') || 1;
my @too_large;
foreach my $slave ( @$slaves ) {
# TODO: This duplicates NibbleIterator::can_nibble();
@@ -8957,7 +8954,7 @@ sub main {
push @too_large, [$slave->name(), $n_rows || 0];
}
}
if ( @too_large ) {
if ( @too_large && $chunk_size_limit ) {
if ( $o->get('quiet') < 2 ) {
my $msg
= "Skipping table $tbl->{db}.$tbl->{tbl} because"
@@ -9054,7 +9051,8 @@ sub main {
vals => [ @{$boundary->{lower}}, $nibble_iter->chunk_size() ],
);
if ( lc($expl->{key} || '')
ne lc($nibble_iter->nibble_index() || '') ) {
ne lc($nibble_iter->nibble_index() || '')
&& $chunk_size_limit) {
PTDEBUG && _d('Cannot nibble next chunk, aborting table');
if ( $o->get('quiet') < 2 ) {
warn ts("Aborting table $tbl->{db}.$tbl->{tbl} at chunk "

View File

@@ -41,9 +41,6 @@ elsif ( !$slave1_dbh ) {
elsif ( !@{$master_dbh->selectall_arrayref("show databases like 'sakila'")} ) {
plan skip_all => 'sakila database is not loaded';
}
else {
plan tests => 38;
}
# The sandbox servers run with lock_wait_timeout=3 and it's not dynamic
# so we need to specify --lock-wait-timeout=3 else the tool will die.
@@ -334,6 +331,24 @@ is(
"52 rows checksummed"
);
# #############################################################################
# pt-table-checksum chunk-size-limit of 0 does not disable chunk size limit checking
# https://bugs.launchpad.net/percona-toolkit/+bug/938660
# #############################################################################
$output = output(
sub {
$exit_status = pt_table_checksum::main(@args, qw(-d test --chunk-size 2 --chunk-size-limit 0))
},
stderr => 1,
);
unlike(
$output,
qr/Skipping table test.t1/,
"Doesn't warns about skipping a large slave table if --chunk-size-limit 0"
);
# #############################################################################
# Crash if no host in DSN.
# https://bugs.launchpad.net/percona-toolkit/+bug/819450
@@ -481,4 +496,6 @@ is(
# #############################################################################
$sb->wipe_clean($master_dbh);
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
done_testing;
exit;