mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-10 21:19:59 +00:00
Update all tests except resume.t for new OobNibbleIterator. Let NibbleIterator handle resume in pt-table-checksum.
This commit is contained in:
@@ -3490,6 +3490,14 @@ sub new {
|
||||
: 0;
|
||||
MKDEBUG && _d('One nibble:', $one_nibble ? 'yes' : 'no');
|
||||
|
||||
if ( my $nibble = $args{resume} ) {
|
||||
if ( !defined $nibble->{lower_boundary}
|
||||
&& !defined $nibble->{upper_boundary} ) {
|
||||
MKDEBUG && _d('Resuming from one nibble table');
|
||||
$one_nibble = 1;
|
||||
}
|
||||
}
|
||||
|
||||
my $index = _find_best_index(%args, mysql_index => $mysql_index);
|
||||
if ( !$index && !$one_nibble ) {
|
||||
die "There is no good index and the table is oversized.";
|
||||
@@ -3526,6 +3534,7 @@ sub new {
|
||||
limit => 0,
|
||||
nibble_sql => $nibble_sql,
|
||||
explain_nibble_sql => $explain_nibble_sql,
|
||||
no_more_boundaries => $args{resume} ? 1 : 0,
|
||||
};
|
||||
}
|
||||
else {
|
||||
@@ -3543,11 +3552,15 @@ sub new {
|
||||
my $from = $q->quote(@{$tbl}{qw(db tbl)}) . " FORCE INDEX(`$index`)";
|
||||
my $order_by = join(', ', map {$q->quote($_)} @{$index_cols});
|
||||
|
||||
my $first_lb_where = $where ? "($where)" : '';
|
||||
if ( $args{resume} ) {
|
||||
$first_lb_where .= ($where ? " AND " : '') . $asc->{boundaries}->{'>'};
|
||||
}
|
||||
my $first_lb_sql
|
||||
= "SELECT /*!40001 SQL_NO_CACHE */ "
|
||||
. join(', ', map { $q->quote($_) } @{$asc->{scols}})
|
||||
. " FROM $from"
|
||||
. ($where ? " WHERE $where" : '')
|
||||
. ($first_lb_where ? " WHERE $first_lb_where" : '')
|
||||
. " ORDER BY $order_by"
|
||||
. " LIMIT 1"
|
||||
. " /*first lower boundary*/";
|
||||
@@ -3612,6 +3625,7 @@ sub new {
|
||||
nibble_sql => $nibble_sql,
|
||||
explain_ub_sql => "EXPLAIN $ub_sql",
|
||||
explain_nibble_sql => $explain_nibble_sql,
|
||||
resume => $args{resume},
|
||||
sql => {
|
||||
columns => $asc->{scols},
|
||||
from => $from,
|
||||
@@ -3916,7 +3930,17 @@ sub _get_bounds {
|
||||
|
||||
my $dbh = $self->{Cxn}->dbh();
|
||||
|
||||
$self->{first_lower} = $dbh->selectrow_arrayref($self->{first_lb_sql});
|
||||
if ( my $nibble = $self->{resume} ) {
|
||||
my $sth = $dbh->prepare($self->{first_lb_sql});
|
||||
my @ub = split ',', $nibble->{upper_boundary};
|
||||
MKDEBUG && _d($sth->{Statement}, 'params:', @ub);
|
||||
$sth->execute(@ub);
|
||||
$self->{first_lower} = $sth->fetchrow_arrayref();
|
||||
$sth->finish();
|
||||
}
|
||||
else {
|
||||
$self->{first_lower} = $dbh->selectrow_arrayref($self->{first_lb_sql});
|
||||
}
|
||||
$self->{next_lower} = $self->{first_lower};
|
||||
MKDEBUG && _d('First lower boundary:', Dumper($self->{next_lower}));
|
||||
|
||||
@@ -3940,6 +3964,12 @@ sub _next_boundaries {
|
||||
return 1; # continue nibbling
|
||||
}
|
||||
|
||||
if ( !$self->{next_lower} ) {
|
||||
MKDEBUG && _d('At end of table');
|
||||
$self->{no_more_boundaries} = 1; # for next call
|
||||
return; # stop nibbling
|
||||
}
|
||||
|
||||
if ( $self->identical_boundaries($self->{lower}, $self->{next_lower}) ) {
|
||||
MKDEBUG && _d('Infinite loop detected');
|
||||
my $tbl = $self->{tbl};
|
||||
@@ -6166,27 +6196,18 @@ sub main {
|
||||
}
|
||||
}
|
||||
elsif ( $last_chunk ) { # resuming
|
||||
my $next_lb = next_lower_boundary(
|
||||
%args,
|
||||
last_chunk => $last_chunk,
|
||||
Quoter => $q,
|
||||
);
|
||||
if ( !$next_lb ) {
|
||||
# This can happen if the tool stops after the last checksum
|
||||
# of a table. So we just start with the next table.
|
||||
MKDEBUG && _d('Resuming from last chunk in table;',
|
||||
'getting next table');
|
||||
$oktonibble = 0; # don't nibbling table; next table
|
||||
}
|
||||
else {
|
||||
if ( have_more_chunks(%args, last_chunk => $last_chunk) ) {
|
||||
$nibble_iter->set_nibble_number($last_chunk->{chunk});
|
||||
$nibble_iter->set_boundary('next_lower', $next_lb);
|
||||
MKDEBUG && _d('Resuming from', $last_chunk->{chunk},
|
||||
'at', $last_chunk->{ts});
|
||||
MKDEBUG && _d('Have more chunks; resuming from',
|
||||
$last_chunk->{chunk}, 'at', $last_chunk->{ts});
|
||||
if ( !$o->get('quiet') ) {
|
||||
print "Resuming from $tbl->{db}.$tbl->{tbl} chunk "
|
||||
. "$last_chunk->{chunk}, timestamp $last_chunk->{ts}\n";
|
||||
}
|
||||
}
|
||||
else {
|
||||
# Problem resuming or no next lower boundary.
|
||||
$oktonibble = 0; # don't nibble table; next table
|
||||
}
|
||||
|
||||
# Just need to call us once to kick-start the resume process.
|
||||
@@ -6555,6 +6576,7 @@ sub main {
|
||||
past_dms => $checksum_dml,
|
||||
past_select => $past_cols,
|
||||
callbacks => $callbacks,
|
||||
resume => $last_chunk,
|
||||
OptionParser => $o,
|
||||
Quoter => $q,
|
||||
TableNibbler => $tn,
|
||||
@@ -7105,22 +7127,23 @@ sub last_chunk {
|
||||
return $last_chunk;
|
||||
}
|
||||
|
||||
sub next_lower_boundary {
|
||||
sub have_more_chunks {
|
||||
my (%args) = @_;
|
||||
my @required_args = qw(Cxn tbl last_chunk NibbleIterator Quoter);
|
||||
my @required_args = qw(tbl last_chunk NibbleIterator);
|
||||
foreach my $arg ( @required_args ) {
|
||||
die "I need a $arg argument" unless $args{$arg};
|
||||
}
|
||||
my ($cxn, $tbl, $last_chunk, $nibble_iter, $q) = @args{@required_args};
|
||||
my ($tbl, $last_chunk, $nibble_iter) = @args{@required_args};
|
||||
|
||||
# If the last chunk (which should be the max chunk) is 1 and there
|
||||
# was no chunk index, then the table was checksummed in a single chunk.
|
||||
if ( $last_chunk->{chunk} == 1
|
||||
&& !$last_chunk->{chunk_index}
|
||||
&& !$nibble_iter->nibble_index() ) {
|
||||
return;
|
||||
# If there's no next lower boundary, then this is the last
|
||||
# chunk of the table.
|
||||
if ( !$nibble_iter->boundaries()->{next_lower} ) {
|
||||
MKDEBUG && _d('No more rows in table; resuming from next table');
|
||||
return 0;
|
||||
}
|
||||
|
||||
# The previous chunk index must match the current chunk index,
|
||||
# else we don't know what to do.
|
||||
my $chunk_index = $nibble_iter->nibble_index() || '';
|
||||
if ( ($last_chunk->{chunk_index} || '')
|
||||
ne ($nibble_iter->nibble_index() || '') ) {
|
||||
@@ -7136,28 +7159,10 @@ sub next_lower_boundary {
|
||||
. "line options. This table will be skipped and checksumming "
|
||||
. "will resume with the next table.\n");
|
||||
$tbl->{checksum_results}->{errors}++;
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
my $sql = $nibble_iter->sql();
|
||||
my $next_lb_sql
|
||||
= "SELECT /*!40001 SQL_NO_CACHE */ "
|
||||
. join(', ', map { $q->quote($_) } @{$sql->{columns}})
|
||||
. " FROM $sql->{from}"
|
||||
. " WHERE " . $sql->{boundaries}->{'>'}
|
||||
. ($sql->{where} ? " AND ($sql->{where})" : '')
|
||||
. " ORDER BY $sql->{order_by}"
|
||||
. " LIMIT 1"
|
||||
. " /*resume next chunk boundary*/";
|
||||
MKDEBUG && _d($next_lb_sql);
|
||||
my $sth = $cxn->dbh()->prepare($next_lb_sql);
|
||||
|
||||
my @ub = split ',', $last_chunk->{upper_boundary};
|
||||
MKDEBUG && _d($sth->{Statement}, 'params:', @ub);
|
||||
$sth->execute(@ub);
|
||||
my $next_lb = $sth->fetchrow_arrayref();
|
||||
$sth->finish();
|
||||
return $next_lb;
|
||||
return 1; # more chunks
|
||||
}
|
||||
|
||||
# Catches signals so we can exit gracefully.
|
||||
|
@@ -108,15 +108,15 @@ ok(
|
||||
$row = $master_dbh->selectrow_arrayref("select count(*) from percona.checksums");
|
||||
is(
|
||||
$row->[0],
|
||||
78,
|
||||
'78 checksums on master'
|
||||
86,
|
||||
'86 checksums on master'
|
||||
);
|
||||
|
||||
$row = $slave_dbh->selectrow_arrayref("select count(*) from percona.checksums");
|
||||
is(
|
||||
$row->[0],
|
||||
78,
|
||||
'78 checksums on slave'
|
||||
86,
|
||||
'86 checksums on slave'
|
||||
);
|
||||
|
||||
# ############################################################################
|
||||
@@ -177,13 +177,14 @@ is_deeply(
|
||||
[qw(issue_21 1)],
|
||||
[qw(issue_21 2)],
|
||||
[qw(issue_21 3)],
|
||||
[qw(issue_21 4)], # lower oob
|
||||
[qw(issue_21 5)], # upper oob
|
||||
# fake row for chunk 999 is gone
|
||||
[qw(other_tbl 1)], # this row is still here
|
||||
],
|
||||
"--emptry-replicate-table on by default"
|
||||
) or print STDERR Dumper($row);
|
||||
|
||||
|
||||
# ############################################################################
|
||||
# --[no]recheck
|
||||
# ############################################################################
|
||||
|
@@ -13,6 +13,8 @@ use Test::More;
|
||||
|
||||
use PerconaTest;
|
||||
use Sandbox;
|
||||
shift @INC; # our unshift (above)
|
||||
shift @INC; # PerconaTest's unshift
|
||||
require "$trunk/bin/pt-table-checksum";
|
||||
|
||||
my $dp = new DSNParser(opts=>$dsn_opts);
|
||||
|
@@ -13,6 +13,8 @@ use Test::More;
|
||||
|
||||
use PerconaTest;
|
||||
use Sandbox;
|
||||
shift @INC; # our unshift (above)
|
||||
shift @INC; # PerconaTest's unshift
|
||||
require "$trunk/bin/pt-table-checksum";
|
||||
|
||||
my $dp = new DSNParser(opts=>$dsn_opts);
|
||||
@@ -32,89 +34,41 @@ else {
|
||||
my $master_dsn = 'h=127.1,P=12345,u=msandbox,p=msandbox';
|
||||
my @args = ($master_dsn, qw(--lock-wait-timeout 3 -d issue_519 --explain --explain --chunk-size 3), '--max-load', '');
|
||||
my $output;
|
||||
my $out = "t/pt-table-checksum/samples/";
|
||||
|
||||
$sb->load_file('master', "t/pt-table-checksum/samples/issue_519.sql");
|
||||
|
||||
my $default_output = "--
|
||||
-- issue_519.t
|
||||
--
|
||||
|
||||
REPLACE INTO `percona`.`checksums` (db, tbl, chunk, chunk_index, lower_boundary, upper_boundary, this_cnt, this_crc) SELECT ?, ?, ?, ?, ?, ?, COUNT(*) AS cnt, COALESCE(LOWER(CONV(BIT_XOR(CAST(CRC32(CONCAT_WS('#', `i`, `y`, `t`, CONCAT(ISNULL(`t`)))) AS UNSIGNED)), 10, 16)), 0) AS crc FROM `issue_519`.`t` FORCE INDEX(`PRIMARY`) WHERE ((`i` >= ?)) AND ((`i` <= ?)) ORDER BY `i` /*checksum chunk*/
|
||||
|
||||
SELECT /*!40001 SQL_NO_CACHE */ `i` FROM `issue_519`.`t` FORCE INDEX(`PRIMARY`) WHERE ((`i` >= ?)) ORDER BY `i` LIMIT ?, 2 /*next chunk boundary*/
|
||||
|
||||
1 1 3
|
||||
2 4 6
|
||||
3 7 9
|
||||
4 10 11
|
||||
|
||||
";
|
||||
|
||||
$output = output(
|
||||
sub { pt_table_checksum::main(@args) },
|
||||
);
|
||||
|
||||
is(
|
||||
$output,
|
||||
$default_output,
|
||||
ok(
|
||||
no_diff(
|
||||
sub { pt_table_checksum::main(@args) },
|
||||
"$out/chunkidx001.txt",
|
||||
),
|
||||
"Chooses chunk index by default"
|
||||
);
|
||||
|
||||
$output = output(
|
||||
sub { pt_table_checksum::main(@args, qw(--chunk-index dog)) },
|
||||
);
|
||||
|
||||
is(
|
||||
$output,
|
||||
$default_output,
|
||||
ok(
|
||||
no_diff(
|
||||
sub { pt_table_checksum::main(@args, qw(--chunk-index dog)) },
|
||||
"$out/chunkidx001.txt",
|
||||
),
|
||||
"Chooses chunk index if --chunk-index doesn't exist"
|
||||
);
|
||||
|
||||
$output = output(
|
||||
sub { pt_table_checksum::main(@args, qw(--chunk-index myidx)) },
|
||||
);
|
||||
|
||||
is(
|
||||
$output,
|
||||
"--
|
||||
-- issue_519.t
|
||||
--
|
||||
|
||||
REPLACE INTO `percona`.`checksums` (db, tbl, chunk, chunk_index, lower_boundary, upper_boundary, this_cnt, this_crc) SELECT ?, ?, ?, ?, ?, ?, COUNT(*) AS cnt, COALESCE(LOWER(CONV(BIT_XOR(CAST(CRC32(CONCAT_WS('#', `i`, `y`, `t`, CONCAT(ISNULL(`t`)))) AS UNSIGNED)), 10, 16)), 0) AS crc FROM `issue_519`.`t` FORCE INDEX(`myidx`) WHERE ((`i` > ?) OR (`i` = ? AND `y` >= ?)) AND ((`i` < ?) OR (`i` = ? AND `y` <= ?)) ORDER BY `i`, `y` /*checksum chunk*/
|
||||
|
||||
SELECT /*!40001 SQL_NO_CACHE */ `i`, `i`, `y` FROM `issue_519`.`t` FORCE INDEX(`myidx`) WHERE ((`i` > ?) OR (`i` = ? AND `y` >= ?)) ORDER BY `i`, `y` LIMIT ?, 2 /*next chunk boundary*/
|
||||
|
||||
1 1,1,2000 3,3,2002
|
||||
2 4,4,2003 6,6,2005
|
||||
3 7,7,2006 9,9,2008
|
||||
4 10,10,2009 11,11,2010
|
||||
|
||||
",
|
||||
ok(
|
||||
no_diff(
|
||||
sub { pt_table_checksum::main(@args, qw(--chunk-index myidx)) },
|
||||
"$out/chunkidx002.txt",
|
||||
),
|
||||
"Use --chunk-index"
|
||||
);
|
||||
|
||||
$output = output(
|
||||
sub { pt_table_checksum::main(@args, qw(--chunk-index y)) },
|
||||
);
|
||||
|
||||
# XXX I'm not sure what this tests thinks it's testing because index y
|
||||
# is a single column index, so there's really not "left-most".
|
||||
is(
|
||||
$output,
|
||||
"--
|
||||
-- issue_519.t
|
||||
--
|
||||
|
||||
REPLACE INTO `percona`.`checksums` (db, tbl, chunk, chunk_index, lower_boundary, upper_boundary, this_cnt, this_crc) SELECT ?, ?, ?, ?, ?, ?, COUNT(*) AS cnt, COALESCE(LOWER(CONV(BIT_XOR(CAST(CRC32(CONCAT_WS('#', `i`, `y`, `t`, CONCAT(ISNULL(`t`)))) AS UNSIGNED)), 10, 16)), 0) AS crc FROM `issue_519`.`t` FORCE INDEX(`y`) WHERE ((`y` >= ?)) AND ((`y` <= ?)) ORDER BY `y` /*checksum chunk*/
|
||||
|
||||
SELECT /*!40001 SQL_NO_CACHE */ `y` FROM `issue_519`.`t` FORCE INDEX(`y`) WHERE ((`y` >= ?)) ORDER BY `y` LIMIT ?, 2 /*next chunk boundary*/
|
||||
|
||||
1 2000 2002
|
||||
2 2003 2005
|
||||
3 2006 2008
|
||||
4 2009 2010
|
||||
|
||||
",
|
||||
ok(
|
||||
no_diff(
|
||||
sub { pt_table_checksum::main(@args, qw(--chunk-index y)) },
|
||||
"$out/chunkidx003.txt",
|
||||
),
|
||||
"Chunks on left-most --chunk-index column"
|
||||
);
|
||||
|
||||
@@ -127,46 +81,22 @@ SELECT /*!40001 SQL_NO_CACHE */ `y` FROM `issue_519`.`t` FORCE INDEX(`y`) WHERE
|
||||
# when --where is given but no explicit --chunk-index|column is given.
|
||||
# Given the --where clause, MySQL will prefer the y index.
|
||||
|
||||
$output = output(
|
||||
sub { pt_table_checksum::main(@args, "--where", "y > 2009") },
|
||||
);
|
||||
|
||||
is(
|
||||
$output,
|
||||
"--
|
||||
-- issue_519.t
|
||||
--
|
||||
|
||||
REPLACE INTO `percona`.`checksums` (db, tbl, chunk, chunk_index, lower_boundary, upper_boundary, this_cnt, this_crc) SELECT ?, ?, ?, ?, ?, ?, COUNT(*) AS cnt, COALESCE(LOWER(CONV(BIT_XOR(CAST(CRC32(CONCAT_WS('#', `i`, `y`, `t`, CONCAT(ISNULL(`t`)))) AS UNSIGNED)), 10, 16)), 0) AS crc FROM `issue_519`.`t` FORCE INDEX(`y`) WHERE ((`y` >= ?)) AND ((`y` <= ?)) AND (y > 2009) ORDER BY `y` /*checksum chunk*/
|
||||
|
||||
SELECT /*!40001 SQL_NO_CACHE */ `y` FROM `issue_519`.`t` FORCE INDEX(`y`) WHERE ((`y` >= ?)) AND (y > 2009) ORDER BY `y` LIMIT ?, 2 /*next chunk boundary*/
|
||||
|
||||
1 2010 2010
|
||||
|
||||
",
|
||||
ok(
|
||||
no_diff(
|
||||
sub { pt_table_checksum::main(@args, "--where", "y > 2009") },
|
||||
"$out/chunkidx004.txt",
|
||||
),
|
||||
"Auto-chosen --chunk-index for --where (issue 378)"
|
||||
);
|
||||
|
||||
# If user specifies --chunk-index, then ignore the index MySQL wants to
|
||||
# use (y in this case) and use the user's index.
|
||||
$output = output(
|
||||
sub { pt_table_checksum::main(@args, qw(--chunk-index PRIMARY),
|
||||
"--where", "y > 2009") },
|
||||
);
|
||||
|
||||
is(
|
||||
$output,
|
||||
"--
|
||||
-- issue_519.t
|
||||
--
|
||||
|
||||
REPLACE INTO `percona`.`checksums` (db, tbl, chunk, chunk_index, lower_boundary, upper_boundary, this_cnt, this_crc) SELECT ?, ?, ?, ?, ?, ?, COUNT(*) AS cnt, COALESCE(LOWER(CONV(BIT_XOR(CAST(CRC32(CONCAT_WS('#', `i`, `y`, `t`, CONCAT(ISNULL(`t`)))) AS UNSIGNED)), 10, 16)), 0) AS crc FROM `issue_519`.`t` FORCE INDEX(`PRIMARY`) WHERE ((`i` >= ?)) AND ((`i` <= ?)) AND (y > 2009) ORDER BY `i` /*checksum chunk*/
|
||||
|
||||
SELECT /*!40001 SQL_NO_CACHE */ `i` FROM `issue_519`.`t` FORCE INDEX(`PRIMARY`) WHERE ((`i` >= ?)) AND (y > 2009) ORDER BY `i` LIMIT ?, 2 /*next chunk boundary*/
|
||||
|
||||
1 11 11
|
||||
|
||||
",
|
||||
ok(
|
||||
no_diff(
|
||||
sub { pt_table_checksum::main(@args, qw(--chunk-index PRIMARY),
|
||||
"--where", "y > 2009") },
|
||||
"$out/chunkidx005.txt",
|
||||
),
|
||||
"Explicit --chunk-index overrides MySQL's index for --where"
|
||||
);
|
||||
|
||||
|
@@ -13,6 +13,8 @@ use Test::More;
|
||||
|
||||
use PerconaTest;
|
||||
use Sandbox;
|
||||
shift @INC; # our unshift (above)
|
||||
shift @INC; # PerconaTest's unshift
|
||||
require "$trunk/bin/pt-table-checksum";
|
||||
|
||||
my $dp = new DSNParser(opts=>$dsn_opts);
|
||||
@@ -81,11 +83,12 @@ is_deeply(
|
||||
[301, 400],
|
||||
[401, 500],
|
||||
[501, 600],
|
||||
[undef, 1], # lower oob
|
||||
[600, undef], # upper oob
|
||||
],
|
||||
"--chunk-time=0 disables auto-adjusting --chunk-size"
|
||||
);
|
||||
|
||||
|
||||
# ############################################################################
|
||||
# Sub-second chunk-time.
|
||||
# ############################################################################
|
||||
|
@@ -13,6 +13,8 @@ use Test::More;
|
||||
|
||||
use PerconaTest;
|
||||
use Sandbox;
|
||||
shift @INC; # our unshift (above)
|
||||
shift @INC; # PerconaTest's unshift
|
||||
require "$trunk/bin/pt-table-checksum";
|
||||
|
||||
my $dp = new DSNParser(opts=>$dsn_opts);
|
||||
|
@@ -13,6 +13,8 @@ use Test::More;
|
||||
|
||||
use PerconaTest;
|
||||
use Sandbox;
|
||||
shift @INC; # our unshift (above)
|
||||
shift @INC; # PerconaTest's unshift
|
||||
require "$trunk/bin/pt-table-checksum";
|
||||
|
||||
my $dp = new DSNParser(opts=>$dsn_opts);
|
||||
|
@@ -14,6 +14,8 @@ use Test::More;
|
||||
use Data::Dumper;
|
||||
use PerconaTest;
|
||||
use Sandbox;
|
||||
shift @INC; # our unshift (above)
|
||||
shift @INC; # PerconaTest's unshift
|
||||
require "$trunk/bin/pt-table-checksum";
|
||||
|
||||
my $vp = new VersionParser();
|
||||
|
@@ -13,6 +13,8 @@ use Test::More;
|
||||
|
||||
use PerconaTest;
|
||||
use Sandbox;
|
||||
shift @INC; # our unshift (above)
|
||||
shift @INC; # PerconaTest's unshift
|
||||
require "$trunk/bin/pt-table-checksum";
|
||||
|
||||
my $dp = new DSNParser(opts=>$dsn_opts);
|
||||
|
@@ -13,6 +13,8 @@ use Test::More;
|
||||
|
||||
use PerconaTest;
|
||||
use Sandbox;
|
||||
shift @INC; # our unshift (above)
|
||||
shift @INC; # PerconaTest's unshift
|
||||
require "$trunk/bin/pt-table-checksum";
|
||||
|
||||
my $dp = new DSNParser(opts=>$dsn_opts);
|
||||
|
@@ -13,6 +13,8 @@ use Test::More;
|
||||
|
||||
use PerconaTest;
|
||||
use Sandbox;
|
||||
shift @INC; # our unshift (above)
|
||||
shift @INC; # PerconaTest's unshift
|
||||
require "$trunk/bin/pt-table-checksum";
|
||||
|
||||
my $dp = new DSNParser(opts=>$dsn_opts);
|
||||
|
@@ -13,6 +13,8 @@ use Test::More;
|
||||
|
||||
use PerconaTest;
|
||||
use Sandbox;
|
||||
shift @INC; # our unshift (above)
|
||||
shift @INC; # PerconaTest's unshift
|
||||
require "$trunk/bin/pt-table-checksum";
|
||||
|
||||
my $dp = new DSNParser(opts=>$dsn_opts);
|
||||
|
@@ -13,6 +13,8 @@ use Test::More;
|
||||
|
||||
use PerconaTest;
|
||||
use Sandbox;
|
||||
shift @INC; # our unshift (above)
|
||||
shift @INC; # PerconaTest's unshift
|
||||
require "$trunk/bin/pt-table-checksum";
|
||||
|
||||
my $dp = new DSNParser(opts=>$dsn_opts);
|
||||
@@ -60,6 +62,8 @@ is_deeply(
|
||||
[ '1', '300' ],
|
||||
[ '1000', '2220293' ],
|
||||
[ '65553510', '18446744073709551615' ],
|
||||
[ undef, '1' ], # lower oob
|
||||
[ '18446744073709551615', undef ], # upper oob
|
||||
],
|
||||
"Uses very large int as chunk boundary"
|
||||
);
|
||||
@@ -67,5 +71,5 @@ is_deeply(
|
||||
# #############################################################################
|
||||
# Done.
|
||||
# #############################################################################
|
||||
#$sb->wipe_clean($master_dbh);
|
||||
$sb->wipe_clean($master_dbh);
|
||||
exit;
|
||||
|
@@ -13,6 +13,8 @@ use Test::More;
|
||||
|
||||
use PerconaTest;
|
||||
use Sandbox;
|
||||
shift @INC; # our unshift (above)
|
||||
shift @INC; # PerconaTest's unshift
|
||||
require "$trunk/bin/pt-table-checksum";
|
||||
|
||||
my $dp = new DSNParser(opts=>$dsn_opts);
|
||||
@@ -44,9 +46,9 @@ $output = output(
|
||||
stderr => 1,
|
||||
);
|
||||
|
||||
like(
|
||||
$output,
|
||||
qr/^\S+\s+0\s+0\s+11\s+2\s+/m,
|
||||
is(
|
||||
PerconaTest::count_checksum_results($output, 'rows'),
|
||||
11,
|
||||
"Checksums table despite invalid datetime"
|
||||
);
|
||||
|
||||
|
@@ -12,6 +12,8 @@ use English qw(-no_match_vars);
|
||||
use Test::More tests => 17;
|
||||
|
||||
use PerconaTest;
|
||||
shift @INC; # our unshift (above)
|
||||
shift @INC; # PerconaTest's unshift
|
||||
require "$trunk/bin/pt-table-checksum";
|
||||
|
||||
my $output;
|
||||
|
@@ -19,6 +19,8 @@ $ENV{PERCONA_TOOLKIT_TEST_USE_DSN_NAMES} = 1;
|
||||
|
||||
use PerconaTest;
|
||||
use Sandbox;
|
||||
shift @INC; # our unshift (above)
|
||||
shift @INC; # PerconaTest's unshift
|
||||
require "$trunk/bin/pt-table-checksum";
|
||||
|
||||
my $dp = new DSNParser(opts=>$dsn_opts);
|
||||
|
@@ -19,7 +19,10 @@ $ENV{PERCONA_TOOLKIT_TEST_USE_DSN_NAMES} = 1;
|
||||
|
||||
use PerconaTest;
|
||||
use Sandbox;
|
||||
shift @INC; # our unshift (above)
|
||||
shift @INC; # PerconaTest's unshift
|
||||
require "$trunk/bin/pt-table-checksum";
|
||||
|
||||
my $dp = new DSNParser(opts=>$dsn_opts);
|
||||
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
|
||||
my $master_dbh = $sb->get_dbh_for('master');
|
||||
|
@@ -13,6 +13,8 @@ use Test::More;
|
||||
|
||||
use PerconaTest;
|
||||
use Sandbox;
|
||||
shift @INC; # our unshift (above)
|
||||
shift @INC; # PerconaTest's unshift
|
||||
require "$trunk/bin/pt-table-checksum";
|
||||
|
||||
my $dp = new DSNParser(opts=>$dsn_opts);
|
||||
|
@@ -4,6 +4,10 @@
|
||||
|
||||
REPLACE INTO `percona`.`checksums` (db, tbl, chunk, chunk_index, lower_boundary, upper_boundary, this_cnt, this_crc) SELECT ?, ?, ?, ?, ?, ?, COUNT(*) AS cnt, COALESCE(LOWER(CONV(BIT_XOR(CAST(CRC32(CONCAT_WS('#', `i`, `c`)) AS UNSIGNED)), 10, 16)), 0) AS crc FROM `test`.`ascii` FORCE INDEX(`c`) WHERE ((`c` >= ?)) AND ((`c` <= ?)) ORDER BY `c` /*checksum chunk*/
|
||||
|
||||
REPLACE INTO `percona`.`checksums` (db, tbl, chunk, chunk_index, lower_boundary, upper_boundary, this_cnt, this_crc) SELECT ?, ?, ?, ?, ?, ?, COUNT(*), '0' FROM `test`.`ascii` FORCE INDEX(`c`) WHERE ((`c` < ?)) ORDER BY `c` /*past lower chunk*/
|
||||
|
||||
REPLACE INTO `percona`.`checksums` (db, tbl, chunk, chunk_index, lower_boundary, upper_boundary, this_cnt, this_crc) SELECT ?, ?, ?, ?, ?, ?, COUNT(*), '0' FROM `test`.`ascii` FORCE INDEX(`c`) WHERE ((`c` > ?)) ORDER BY `c` /*past upper chunk*/
|
||||
|
||||
SELECT /*!40001 SQL_NO_CACHE */ `c` FROM `test`.`ascii` FORCE INDEX(`c`) WHERE ((`c` >= ?)) ORDER BY `c` LIMIT ?, 2 /*next chunk boundary*/
|
||||
|
||||
1 burt
|
||||
@@ -14,4 +18,6 @@ SELECT /*!40001 SQL_NO_CACHE */ `c` FROM `test`.`ascii` FORCE INDEX(`c`) WHERE (
|
||||
6 Natalie Sean
|
||||
7 sidney Zesus!
|
||||
8 Zesus!! ZESUS!!!
|
||||
9
|
||||
10 ZESUS!!!
|
||||
|
||||
|
@@ -1,2 +1,2 @@
|
||||
ERRORS DIFFS ROWS CHUNKS SKIPPED TABLE
|
||||
0 0 142 8 0 test.ascii
|
||||
0 0 142 10 0 test.ascii
|
||||
|
19
t/pt-table-checksum/samples/chunkidx001.txt
Normal file
19
t/pt-table-checksum/samples/chunkidx001.txt
Normal file
@@ -0,0 +1,19 @@
|
||||
--
|
||||
-- issue_519.t
|
||||
--
|
||||
|
||||
REPLACE INTO `percona`.`checksums` (db, tbl, chunk, chunk_index, lower_boundary, upper_boundary, this_cnt, this_crc) SELECT ?, ?, ?, ?, ?, ?, COUNT(*) AS cnt, COALESCE(LOWER(CONV(BIT_XOR(CAST(CRC32(CONCAT_WS('#', `i`, `y`, `t`, CONCAT(ISNULL(`t`)))) AS UNSIGNED)), 10, 16)), 0) AS crc FROM `issue_519`.`t` FORCE INDEX(`PRIMARY`) WHERE ((`i` >= ?)) AND ((`i` <= ?)) ORDER BY `i` /*checksum chunk*/
|
||||
|
||||
REPLACE INTO `percona`.`checksums` (db, tbl, chunk, chunk_index, lower_boundary, upper_boundary, this_cnt, this_crc) SELECT ?, ?, ?, ?, ?, ?, COUNT(*), '0' FROM `issue_519`.`t` FORCE INDEX(`PRIMARY`) WHERE ((`i` < ?)) ORDER BY `i` /*past lower chunk*/
|
||||
|
||||
REPLACE INTO `percona`.`checksums` (db, tbl, chunk, chunk_index, lower_boundary, upper_boundary, this_cnt, this_crc) SELECT ?, ?, ?, ?, ?, ?, COUNT(*), '0' FROM `issue_519`.`t` FORCE INDEX(`PRIMARY`) WHERE ((`i` > ?)) ORDER BY `i` /*past upper chunk*/
|
||||
|
||||
SELECT /*!40001 SQL_NO_CACHE */ `i` FROM `issue_519`.`t` FORCE INDEX(`PRIMARY`) WHERE ((`i` >= ?)) ORDER BY `i` LIMIT ?, 2 /*next chunk boundary*/
|
||||
|
||||
1 1 3
|
||||
2 4 6
|
||||
3 7 9
|
||||
4 10 11
|
||||
5 1
|
||||
6 11
|
||||
|
19
t/pt-table-checksum/samples/chunkidx002.txt
Normal file
19
t/pt-table-checksum/samples/chunkidx002.txt
Normal file
@@ -0,0 +1,19 @@
|
||||
--
|
||||
-- issue_519.t
|
||||
--
|
||||
|
||||
REPLACE INTO `percona`.`checksums` (db, tbl, chunk, chunk_index, lower_boundary, upper_boundary, this_cnt, this_crc) SELECT ?, ?, ?, ?, ?, ?, COUNT(*) AS cnt, COALESCE(LOWER(CONV(BIT_XOR(CAST(CRC32(CONCAT_WS('#', `i`, `y`, `t`, CONCAT(ISNULL(`t`)))) AS UNSIGNED)), 10, 16)), 0) AS crc FROM `issue_519`.`t` FORCE INDEX(`myidx`) WHERE ((`i` > ?) OR (`i` = ? AND `y` >= ?)) AND ((`i` < ?) OR (`i` = ? AND `y` <= ?)) ORDER BY `i`, `y` /*checksum chunk*/
|
||||
|
||||
REPLACE INTO `percona`.`checksums` (db, tbl, chunk, chunk_index, lower_boundary, upper_boundary, this_cnt, this_crc) SELECT ?, ?, ?, ?, ?, ?, COUNT(*), '0' FROM `issue_519`.`t` FORCE INDEX(`myidx`) WHERE ((`i` < ?) OR (`i` = ? AND `y` < ?)) ORDER BY `i`, `y` /*past lower chunk*/
|
||||
|
||||
REPLACE INTO `percona`.`checksums` (db, tbl, chunk, chunk_index, lower_boundary, upper_boundary, this_cnt, this_crc) SELECT ?, ?, ?, ?, ?, ?, COUNT(*), '0' FROM `issue_519`.`t` FORCE INDEX(`myidx`) WHERE ((`i` > ?) OR (`i` = ? AND `y` > ?)) ORDER BY `i`, `y` /*past upper chunk*/
|
||||
|
||||
SELECT /*!40001 SQL_NO_CACHE */ `i`, `i`, `y` FROM `issue_519`.`t` FORCE INDEX(`myidx`) WHERE ((`i` > ?) OR (`i` = ? AND `y` >= ?)) ORDER BY `i`, `y` LIMIT ?, 2 /*next chunk boundary*/
|
||||
|
||||
1 1,1,2000 3,3,2002
|
||||
2 4,4,2003 6,6,2005
|
||||
3 7,7,2006 9,9,2008
|
||||
4 10,10,2009 11,11,2010
|
||||
5 1,1,2000
|
||||
6 11,11,2010
|
||||
|
19
t/pt-table-checksum/samples/chunkidx003.txt
Normal file
19
t/pt-table-checksum/samples/chunkidx003.txt
Normal file
@@ -0,0 +1,19 @@
|
||||
--
|
||||
-- issue_519.t
|
||||
--
|
||||
|
||||
REPLACE INTO `percona`.`checksums` (db, tbl, chunk, chunk_index, lower_boundary, upper_boundary, this_cnt, this_crc) SELECT ?, ?, ?, ?, ?, ?, COUNT(*) AS cnt, COALESCE(LOWER(CONV(BIT_XOR(CAST(CRC32(CONCAT_WS('#', `i`, `y`, `t`, CONCAT(ISNULL(`t`)))) AS UNSIGNED)), 10, 16)), 0) AS crc FROM `issue_519`.`t` FORCE INDEX(`y`) WHERE ((`y` >= ?)) AND ((`y` <= ?)) ORDER BY `y` /*checksum chunk*/
|
||||
|
||||
REPLACE INTO `percona`.`checksums` (db, tbl, chunk, chunk_index, lower_boundary, upper_boundary, this_cnt, this_crc) SELECT ?, ?, ?, ?, ?, ?, COUNT(*), '0' FROM `issue_519`.`t` FORCE INDEX(`y`) WHERE ((`y` < ?)) ORDER BY `y` /*past lower chunk*/
|
||||
|
||||
REPLACE INTO `percona`.`checksums` (db, tbl, chunk, chunk_index, lower_boundary, upper_boundary, this_cnt, this_crc) SELECT ?, ?, ?, ?, ?, ?, COUNT(*), '0' FROM `issue_519`.`t` FORCE INDEX(`y`) WHERE ((`y` > ?)) ORDER BY `y` /*past upper chunk*/
|
||||
|
||||
SELECT /*!40001 SQL_NO_CACHE */ `y` FROM `issue_519`.`t` FORCE INDEX(`y`) WHERE ((`y` >= ?)) ORDER BY `y` LIMIT ?, 2 /*next chunk boundary*/
|
||||
|
||||
1 2000 2002
|
||||
2 2003 2005
|
||||
3 2006 2008
|
||||
4 2009 2010
|
||||
5 2000
|
||||
6 2010
|
||||
|
16
t/pt-table-checksum/samples/chunkidx004.txt
Normal file
16
t/pt-table-checksum/samples/chunkidx004.txt
Normal file
@@ -0,0 +1,16 @@
|
||||
--
|
||||
-- issue_519.t
|
||||
--
|
||||
|
||||
REPLACE INTO `percona`.`checksums` (db, tbl, chunk, chunk_index, lower_boundary, upper_boundary, this_cnt, this_crc) SELECT ?, ?, ?, ?, ?, ?, COUNT(*) AS cnt, COALESCE(LOWER(CONV(BIT_XOR(CAST(CRC32(CONCAT_WS('#', `i`, `y`, `t`, CONCAT(ISNULL(`t`)))) AS UNSIGNED)), 10, 16)), 0) AS crc FROM `issue_519`.`t` FORCE INDEX(`y`) WHERE ((`y` >= ?)) AND ((`y` <= ?)) AND (y > 2009) ORDER BY `y` /*checksum chunk*/
|
||||
|
||||
REPLACE INTO `percona`.`checksums` (db, tbl, chunk, chunk_index, lower_boundary, upper_boundary, this_cnt, this_crc) SELECT ?, ?, ?, ?, ?, ?, COUNT(*), '0' FROM `issue_519`.`t` FORCE INDEX(`y`) WHERE ((`y` < ?)) AND (y > 2009) ORDER BY `y` /*past lower chunk*/
|
||||
|
||||
REPLACE INTO `percona`.`checksums` (db, tbl, chunk, chunk_index, lower_boundary, upper_boundary, this_cnt, this_crc) SELECT ?, ?, ?, ?, ?, ?, COUNT(*), '0' FROM `issue_519`.`t` FORCE INDEX(`y`) WHERE ((`y` > ?)) AND (y > 2009) ORDER BY `y` /*past upper chunk*/
|
||||
|
||||
SELECT /*!40001 SQL_NO_CACHE */ `y` FROM `issue_519`.`t` FORCE INDEX(`y`) WHERE ((`y` >= ?)) AND (y > 2009) ORDER BY `y` LIMIT ?, 2 /*next chunk boundary*/
|
||||
|
||||
1 2010 2010
|
||||
2 2010
|
||||
3 2010
|
||||
|
16
t/pt-table-checksum/samples/chunkidx005.txt
Normal file
16
t/pt-table-checksum/samples/chunkidx005.txt
Normal file
@@ -0,0 +1,16 @@
|
||||
--
|
||||
-- issue_519.t
|
||||
--
|
||||
|
||||
REPLACE INTO `percona`.`checksums` (db, tbl, chunk, chunk_index, lower_boundary, upper_boundary, this_cnt, this_crc) SELECT ?, ?, ?, ?, ?, ?, COUNT(*) AS cnt, COALESCE(LOWER(CONV(BIT_XOR(CAST(CRC32(CONCAT_WS('#', `i`, `y`, `t`, CONCAT(ISNULL(`t`)))) AS UNSIGNED)), 10, 16)), 0) AS crc FROM `issue_519`.`t` FORCE INDEX(`PRIMARY`) WHERE ((`i` >= ?)) AND ((`i` <= ?)) AND (y > 2009) ORDER BY `i` /*checksum chunk*/
|
||||
|
||||
REPLACE INTO `percona`.`checksums` (db, tbl, chunk, chunk_index, lower_boundary, upper_boundary, this_cnt, this_crc) SELECT ?, ?, ?, ?, ?, ?, COUNT(*), '0' FROM `issue_519`.`t` FORCE INDEX(`PRIMARY`) WHERE ((`i` < ?)) AND (y > 2009) ORDER BY `i` /*past lower chunk*/
|
||||
|
||||
REPLACE INTO `percona`.`checksums` (db, tbl, chunk, chunk_index, lower_boundary, upper_boundary, this_cnt, this_crc) SELECT ?, ?, ?, ?, ?, ?, COUNT(*), '0' FROM `issue_519`.`t` FORCE INDEX(`PRIMARY`) WHERE ((`i` > ?)) AND (y > 2009) ORDER BY `i` /*past upper chunk*/
|
||||
|
||||
SELECT /*!40001 SQL_NO_CACHE */ `i` FROM `issue_519`.`t` FORCE INDEX(`PRIMARY`) WHERE ((`i` >= ?)) AND (y > 2009) ORDER BY `i` LIMIT ?, 2 /*next chunk boundary*/
|
||||
|
||||
1 11 11
|
||||
2 11
|
||||
3 11
|
||||
|
@@ -4,9 +4,15 @@
|
||||
|
||||
REPLACE INTO `percona`.`checksums` (db, tbl, chunk, chunk_index, lower_boundary, upper_boundary, this_cnt, this_crc) SELECT ?, ?, ?, ?, ?, ?, COUNT(*) AS cnt, COALESCE(LOWER(CONV(BIT_XOR(CAST(CRC32(CONCAT_WS('#', `c`, CONCAT(ISNULL(`c`)))) AS UNSIGNED)), 10, 16)), 0) AS crc FROM `osc`.`t2` FORCE INDEX(`c`) WHERE (((? IS NULL OR `c` >= ?))) AND (((? IS NULL OR `c` <= ?))) ORDER BY `c` /*checksum chunk*/
|
||||
|
||||
REPLACE INTO `percona`.`checksums` (db, tbl, chunk, chunk_index, lower_boundary, upper_boundary, this_cnt, this_crc) SELECT ?, ?, ?, ?, ?, ?, COUNT(*), '0' FROM `osc`.`t2` FORCE INDEX(`c`) WHERE ((((? IS NOT NULL AND `c` IS NULL) OR (`c` < ?)))) ORDER BY `c` /*past lower chunk*/
|
||||
|
||||
REPLACE INTO `percona`.`checksums` (db, tbl, chunk, chunk_index, lower_boundary, upper_boundary, this_cnt, this_crc) SELECT ?, ?, ?, ?, ?, ?, COUNT(*), '0' FROM `osc`.`t2` FORCE INDEX(`c`) WHERE ((((? IS NULL AND `c` IS NOT NULL) OR (`c` > ?)))) ORDER BY `c` /*past upper chunk*/
|
||||
|
||||
SELECT /*!40001 SQL_NO_CACHE */ `c`, `c` FROM `osc`.`t2` FORCE INDEX(`c`) WHERE (((? IS NULL OR `c` >= ?))) ORDER BY `c` LIMIT ?, 2 /*next chunk boundary*/
|
||||
|
||||
1 a,a b,b
|
||||
2 b,b d,d
|
||||
3 d,d g,g
|
||||
4 a,a
|
||||
5 g,g
|
||||
|
||||
|
@@ -27,12 +27,12 @@ ERRORS DIFFS ROWS CHUNKS SKIPPED TABLE
|
||||
0 0 109 1 0 sakila.country
|
||||
0 0 599 1 0 sakila.customer
|
||||
0 0 1000 1 0 sakila.film
|
||||
0 0 5462 6 0 sakila.film_actor
|
||||
0 0 5462 8 0 sakila.film_actor
|
||||
0 0 1000 1 0 sakila.film_category
|
||||
0 0 1000 1 0 sakila.film_text
|
||||
0 0 4581 5 0 sakila.inventory
|
||||
0 0 4581 7 0 sakila.inventory
|
||||
0 0 6 1 0 sakila.language
|
||||
0 0 16049 17 0 sakila.payment
|
||||
0 0 16044 17 0 sakila.rental
|
||||
0 0 16049 19 0 sakila.payment
|
||||
0 0 16044 19 0 sakila.rental
|
||||
0 0 2 1 0 sakila.staff
|
||||
0 0 2 1 0 sakila.store
|
||||
|
@@ -13,6 +13,8 @@ use Test::More;
|
||||
|
||||
use PerconaTest;
|
||||
use Sandbox;
|
||||
shift @INC; # our unshift (above)
|
||||
shift @INC; # PerconaTest's unshift
|
||||
require "$trunk/bin/pt-table-checksum";
|
||||
|
||||
my $dp = new DSNParser(opts=>$dsn_opts);
|
||||
|
@@ -13,6 +13,8 @@ use Test::More;
|
||||
|
||||
use PerconaTest;
|
||||
use Sandbox;
|
||||
shift @INC; # our unshift (above)
|
||||
shift @INC; # PerconaTest's unshift
|
||||
require "$trunk/bin/pt-table-checksum";
|
||||
|
||||
my $dp = new DSNParser(opts=>$dsn_opts);
|
||||
|
Reference in New Issue
Block a user