Make explicit --chunk-size disable auto-sizing (set --chunk-time=0).

This commit is contained in:
Daniel Nichter
2011-11-16 11:30:51 -07:00
parent ef61f734cf
commit 14dc2366f6
3 changed files with 23 additions and 11 deletions

View File

@@ -5793,6 +5793,8 @@ sub main {
); );
$o->set('ignore-tables', \%ignore_tables); $o->set('ignore-tables', \%ignore_tables);
$o->set('chunk-time', 0) if $o->got('chunk-size');
if ( !$o->get('help') ) { if ( !$o->get('help') ) {
if ( @ARGV > 1 ) { if ( @ARGV > 1 ) {
$o->save_error("More than one host specified; only one allowed"); $o->save_error("More than one host specified; only one allowed");
@@ -7536,6 +7538,9 @@ MySQL with trying to checksum too much data.
If a table does not have any unique indexes, the chunk size may be inaccurate, If a table does not have any unique indexes, the chunk size may be inaccurate,
in which case L<"--chunk-size-limit"> can help prevent overloading MySQL. in which case L<"--chunk-size-limit"> can help prevent overloading MySQL.
If this option is specified on the command line, then the given
chunk size is always used and L<"--chunk-time"> is set to zero.
=item --chunk-size-limit =item --chunk-size-limit
type: float; default: 2.0; group: Safety type: float; default: 2.0; group: Safety
@@ -7946,7 +7951,7 @@ pt-table-checksum selects with USE, and never changes afterwards. See also
=item --resume =item --resume
Resume checksumming from the last completed chunk (disables L<"--[no]empty-replicate-table). If the tool is stopped before it finishes checksumming all Resume checksumming from the last completed chunk (disables L<"--[no]empty-replicate-table">). If the tool is stopped before it finishes checksumming all
tables, checksumming can resume from the last chunk of the last table tables, checksumming can resume from the last chunk of the last table
finished by specifying this option. finished by specifying this option.

View File

@@ -43,34 +43,34 @@ my $output;
# the first chunk should equal the chunk size, and the 2nd chunk should # the first chunk should equal the chunk size, and the 2nd chunk should
# larger, unless it takes your machine > 0.5s to select 100 rows. # larger, unless it takes your machine > 0.5s to select 100 rows.
pt_table_checksum::main(@args, qw(--quiet --chunk-size 100 -t sakila.city)); pt_table_checksum::main(@args, qw(--quiet -t sakila.rental));
$row = $master_dbh->selectrow_arrayref("select lower_boundary, upper_boundary from percona.checksums where db='sakila' and tbl='city' and chunk=1"); $row = $master_dbh->selectrow_arrayref("select lower_boundary, upper_boundary from percona.checksums where db='sakila' and tbl='rental' and chunk=1");
is_deeply( is_deeply(
$row, $row,
[1, 100], # 100 rows for --chunk-size=100 [1, 1001],
"First chunk is default size" "First chunk is default size"
); );
$row = $master_dbh->selectrow_arrayref("select lower_boundary, upper_boundary from percona.checksums where db='sakila' and tbl='city' and chunk=2"); $row = $master_dbh->selectrow_arrayref("select lower_boundary, upper_boundary from percona.checksums where db='sakila' and tbl='rental' and chunk=2");
is( is(
$row->[0], $row->[0],
101, 1002,
"2nd chunk lower boundary" "2nd chunk lower boundary"
); );
cmp_ok( cmp_ok(
$row->[1] - $row->[0], $row->[1] - $row->[0],
'>', '>',
100, 1000,
"2nd chunk is larger" "2nd chunk is larger"
); );
# ############################################################################ # ############################################################################
# Test --chunk-time here because it's linked to --chunk-size. # Explicit --chunk-size should override auto-sizing.
# ############################################################################ # ############################################################################
pt_table_checksum::main(@args, qw(--quiet --chunk-time 0 --chunk-size 100 -t sakila.city)); pt_table_checksum::main(@args, qw(--quiet --chunk-size 100 -t sakila.city));
# There's 600 rows in sakila.city so there should be 6 chunks. # There's 600 rows in sakila.city so there should be 6 chunks.
$row = $master_dbh->selectall_arrayref("select lower_boundary, upper_boundary from percona.checksums where db='sakila' and tbl='city'"); $row = $master_dbh->selectall_arrayref("select lower_boundary, upper_boundary from percona.checksums where db='sakila' and tbl='city'");
@@ -86,7 +86,7 @@ is_deeply(
[undef, 1], # lower oob [undef, 1], # lower oob
[600, undef], # upper oob [600, undef], # upper oob
], ],
"--chunk-time=0 disables auto-adjusting --chunk-size" "Explicit --chunk-size disables auto chunk sizing"
); );
# ############################################################################ # ############################################################################

View File

@@ -9,7 +9,7 @@ BEGIN {
use strict; use strict;
use warnings FATAL => 'all'; use warnings FATAL => 'all';
use English qw(-no_match_vars); use English qw(-no_match_vars);
use Test::More tests => 17; use Test::More tests => 18;
use PerconaTest; use PerconaTest;
shift @INC; # our unshift (above) shift @INC; # our unshift (above)
@@ -119,6 +119,13 @@ like(
"--quiet disables --progress" "--quiet disables --progress"
); );
$output = `$trunk/bin/pt-table-checksum --help --chunk-size 500`;
like(
$output,
qr/^ --chunk-time\s+0$/m,
"--chunk-size sets --chunk-time=0"
);
# ############################################################################ # ############################################################################
# Only 1 DSN should be allowed on the command line; no extra args. # Only 1 DSN should be allowed on the command line; no extra args.
# ############################################################################ # ############################################################################