diff --git a/bin/pt-table-checksum b/bin/pt-table-checksum index edc81a01..d4140a78 100755 --- a/bin/pt-table-checksum +++ b/bin/pt-table-checksum @@ -8892,9 +8892,12 @@ sub main { # so no checksum is written for the empty table. To fix this and # preserve the two purposes of this option, usages of the 2nd purpose # 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'); + # See: + # https://bugs.launchpad.net/percona-toolkit/+bug/987393 + # https://bugs.launchpad.net/percona-toolkit/+bug/938660 + # https://bugs.launchpad.net/percona-toolkit/+bug/987495 + # This is used for the 2nd purpose: + my $chunk_size_limit = $o->get('chunk-size-limit') || 1; # ######################################################################## # Callbacks for each table's nibble iterator. All checksum work is done @@ -8950,10 +8953,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(); @@ -9505,9 +9504,7 @@ sub nibble_is_safe { # shouldn't have changed. If chunking the table with a non-unique key, # oversize chunks are possible. if ( my $limit = $o->get('chunk-size-limit') ) { - my $oversize_chunk - = $limit ? ($expl->{rows} || 0) >= $tbl->{chunk_size} * $limit - : 0; + my $oversize_chunk = ($expl->{rows} || 0) >= $tbl->{chunk_size} * $limit; if ( $oversize_chunk && $nibble_iter->identical_boundaries($boundary->{upper}, $boundary->{next_lower}) ) { diff --git a/t/pt-table-checksum/basics.t b/t/pt-table-checksum/basics.t index 585d981c..88af4f9b 100644 --- a/t/pt-table-checksum/basics.t +++ b/t/pt-table-checksum/basics.t @@ -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,29 @@ 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 +# ############################################################################# + +# Decided _not_ to do this; we want to always check slave table size when +# single-chunking a table on the master. + +$output = output( + sub { + $exit_status = pt_table_checksum::main(@args, + qw(-d test --chunk-size 2 --chunk-size-limit 0)) + }, + stderr => 1, +); + +like( + $output, + qr/Skipping table test.t1/, + "--chunk-size-limit=0 does not disable #-of-rows checks on slaves" +); + # ############################################################################# # Crash if no host in DSN. # https://bugs.launchpad.net/percona-toolkit/+bug/819450 @@ -481,4 +501,4 @@ is( # ############################################################################# $sb->wipe_clean($master_dbh); ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox"); -exit; +done_testing;