mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-09 18:30:16 +00:00
Update issue_388.t, issue_47.t, issue_602.t. Rename issue_81.t to error_handling.t. Move issue_69.t tests into basics.t and remove issue_69.t.
This commit is contained in:
@@ -6179,8 +6179,8 @@ my %warn_code = (
|
|||||||
# Error: 1265 SQLSTATE: 01000 (WARN_DATA_TRUNCATED)
|
# Error: 1265 SQLSTATE: 01000 (WARN_DATA_TRUNCATED)
|
||||||
# Message: Data truncated for column '%s' at row %ld
|
# Message: Data truncated for column '%s' at row %ld
|
||||||
1265 => {
|
1265 => {
|
||||||
pattern => qr/for column '(?:lower|upper)_boundary'/,
|
# any pattern
|
||||||
warning => "WHERE clause too large for boundaries.",
|
# use MySQL's message for this warning
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -6242,18 +6242,23 @@ sub exec_nibble {
|
|||||||
my $warnings = $dbh->selectall_arrayref($sql_warn, { Slice => {} } );
|
my $warnings = $dbh->selectall_arrayref($sql_warn, { Slice => {} } );
|
||||||
foreach my $warning ( @$warnings ) {
|
foreach my $warning ( @$warnings ) {
|
||||||
my $code = ($warning->{code} || 0);
|
my $code = ($warning->{code} || 0);
|
||||||
|
my $message = $warning->{message};
|
||||||
if ( $ignore_code{$code} ) {
|
if ( $ignore_code{$code} ) {
|
||||||
MKDEBUG && _d('Ignoring warning:', $code, $warning->{message});
|
MKDEBUG && _d('Ignoring warning:', $code, $message);
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
elsif ( $warn_code{$code}
|
elsif ( $warn_code{$code}
|
||||||
&& $warning->{message} =~ m/$warn_code{$code}->{pattern}/ )
|
&& (!$warn_code{$code}->{pattern}
|
||||||
|
|| $message =~ m/$warn_code{$code}->{pattern}/) )
|
||||||
{
|
{
|
||||||
if ( !$tbl->{"warned_code_$code"} ) { # warn once per table
|
if ( !$tbl->{"warned_code_$code"} ) { # warn once per table
|
||||||
if ( $o->get('quiet') < 2 ) {
|
if ( $o->get('quiet') < 2 ) {
|
||||||
warn ts("Checksum query for table $tbl->{db}.$tbl->{tbl} "
|
warn ts("Checksum query for table $tbl->{db}.$tbl->{tbl} "
|
||||||
. "caused MySQL error $code: "
|
. "caused MySQL error $code: "
|
||||||
. $warn_code{$code}->{warning} . "\n");
|
. ($warn_code{$code}->{message}
|
||||||
|
? $warn_code{$code}->{message}
|
||||||
|
: $message)
|
||||||
|
. "\n");
|
||||||
}
|
}
|
||||||
$tbl->{"warned_code_$code"} = 1;
|
$tbl->{"warned_code_$code"} = 1;
|
||||||
$tbl->{checksum_results}->{errors}++;
|
$tbl->{checksum_results}->{errors}++;
|
||||||
|
@@ -31,7 +31,7 @@ elsif ( !@{$master_dbh->selectall_arrayref('show databases like "sakila"')} ) {
|
|||||||
plan skip_all => 'sakila database is not loaded';
|
plan skip_all => 'sakila database is not loaded';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
plan tests => 8;
|
plan tests => 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
# The sandbox servers run with lock_wait_timeout=3 and it's not dynamic
|
# The sandbox servers run with lock_wait_timeout=3 and it's not dynamic
|
||||||
@@ -174,8 +174,26 @@ is_deeply(
|
|||||||
"--emptry-replicate-table on by default"
|
"--emptry-replicate-table on by default"
|
||||||
) or print STDERR Dumper($row);
|
) or print STDERR Dumper($row);
|
||||||
|
|
||||||
|
|
||||||
|
# ############################################################################
|
||||||
|
# --[no]recheck
|
||||||
|
# ############################################################################
|
||||||
|
|
||||||
|
$exit_status = pt_table_checksum::main(@args,
|
||||||
|
qw(--quiet --quiet --chunk-time 0 --chunk-size 100 -t sakila.city));
|
||||||
|
|
||||||
|
$slave_dbh->do("update percona.checksums set this_crc='' where db='sakila' and tbl='city' and (chunk=1 or chunk=6)");
|
||||||
|
|
||||||
|
ok(
|
||||||
|
no_diff(
|
||||||
|
sub { pt_table_checksum::main(@args, qw(--no-recheck)) },
|
||||||
|
"$sample/no-recheck.txt",
|
||||||
|
),
|
||||||
|
"--no-recheck (just --replicate-check)"
|
||||||
|
);
|
||||||
|
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Done.
|
# Done.
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
$sb->wipe_clean($master_dbh);
|
#$sb->wipe_clean($master_dbh);
|
||||||
exit;
|
exit;
|
||||||
|
@@ -23,12 +23,14 @@ if ( !$master_dbh ) {
|
|||||||
plan skip_all => 'Cannot connect to sandbox master';
|
plan skip_all => 'Cannot connect to sandbox master';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
plan tests => 1;
|
plan tests => 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# 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.
|
||||||
|
my $master_dsn = 'h=127.1,P=12345,u=msandbox,p=msandbox';
|
||||||
|
my @args = ($master_dsn, qw(--lock-wait-timeout 3));
|
||||||
my $output;
|
my $output;
|
||||||
my $cnf='/tmp/12345/my.sandbox.cnf';
|
|
||||||
my $cmd = "$trunk/bin/pt-table-checksum -F $cnf 127.0.0.1";
|
|
||||||
|
|
||||||
$sb->create_dbs($master_dbh, [qw(test)]);
|
$sb->create_dbs($master_dbh, [qw(test)]);
|
||||||
|
|
||||||
@@ -36,8 +38,26 @@ $sb->create_dbs($master_dbh, [qw(test)]);
|
|||||||
# Issue 81: put some data that's too big into the boundaries table
|
# Issue 81: put some data that's too big into the boundaries table
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
$sb->load_file('master', 't/pt-table-checksum/samples/checksum_tbl_truncated.sql');
|
$sb->load_file('master', 't/pt-table-checksum/samples/checksum_tbl_truncated.sql');
|
||||||
$output = `$cmd --ignore-databases sakila,mysql --empty-replicate-table --replicate test.checksum 2>&1`;
|
|
||||||
like($output, qr/boundaries/, 'Truncation causes an error');
|
$output = output(
|
||||||
|
sub { pt_table_checksum::main(@args,
|
||||||
|
qw(--replicate test.truncated_checksums -t sakila.film_category),
|
||||||
|
qw(--chunk-time 0 --chunk-size 100) ) },
|
||||||
|
stderr => 1,
|
||||||
|
);
|
||||||
|
|
||||||
|
like(
|
||||||
|
$output,
|
||||||
|
qr/MySQL error 1265: Data truncated/,
|
||||||
|
"MySQL error 1265: Data truncated for column"
|
||||||
|
);
|
||||||
|
|
||||||
|
my (@errors) = $output =~ m/error/;
|
||||||
|
is(
|
||||||
|
scalar @errors,
|
||||||
|
1,
|
||||||
|
"Only one warning for MySQL error 1265"
|
||||||
|
);
|
||||||
|
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Done.
|
# Done.
|
@@ -26,8 +26,11 @@ else {
|
|||||||
plan tests => 2;
|
plan tests => 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# 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.
|
||||||
|
my $master_dsn = 'h=127.1,P=12345,u=msandbox,p=msandbox';
|
||||||
|
my @args = ($master_dsn, qw(--lock-wait-timeout 3));
|
||||||
my $output;
|
my $output;
|
||||||
my $cnf = '/tmp/12345/my.sandbox.cnf';
|
|
||||||
|
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Issue 388: mk-table-checksum crashes when column with comma in the name
|
# Issue 388: mk-table-checksum crashes when column with comma in the name
|
||||||
@@ -39,7 +42,9 @@ $sb->load_file('master', 't/lib/samples/tables/issue-388.sql', 'test');
|
|||||||
|
|
||||||
$dbh->do('insert into test.foo values (null, "john, smith")');
|
$dbh->do('insert into test.foo values (null, "john, smith")');
|
||||||
|
|
||||||
$output = `$trunk/bin/pt-table-checksum -F $cnf h=127.1 -d test 2>&1`;
|
$output = output(
|
||||||
|
sub { pt_table_checksum::main(@args, qw(-d test)) },
|
||||||
|
);
|
||||||
|
|
||||||
unlike(
|
unlike(
|
||||||
$output,
|
$output,
|
||||||
@@ -49,7 +54,7 @@ unlike(
|
|||||||
|
|
||||||
like(
|
like(
|
||||||
$output,
|
$output,
|
||||||
qr/test\s+foo\s+0\s+127.1\s+MyISAM\s+NULL\s+1906802343/,
|
qr/^\S+\s+0\s+0\s+1\s+1\s+/m,
|
||||||
'Checksums the table (issue 388)'
|
'Checksums the table (issue 388)'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@@ -18,21 +18,20 @@ require "$trunk/bin/pt-table-checksum";
|
|||||||
my $dp = new DSNParser(opts=>$dsn_opts);
|
my $dp = new DSNParser(opts=>$dsn_opts);
|
||||||
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
|
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
|
||||||
my $master_dbh = $sb->get_dbh_for('master');
|
my $master_dbh = $sb->get_dbh_for('master');
|
||||||
my $slave_dbh = $sb->get_dbh_for('slave1');
|
|
||||||
|
|
||||||
if ( !$master_dbh ) {
|
if ( !$master_dbh ) {
|
||||||
plan skip_all => 'Cannot connect to sandbox master';
|
plan skip_all => 'Cannot connect to sandbox master';
|
||||||
}
|
}
|
||||||
elsif ( !$slave_dbh ) {
|
|
||||||
plan skip_all => 'Cannot connect to sandbox slave';
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
plan tests => 2;
|
plan tests => 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# 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.
|
||||||
|
my $master_dsn = 'h=127.1,P=12345,u=msandbox,p=msandbox';
|
||||||
|
my @args = ($master_dsn, qw(--lock-wait-timeout 3));
|
||||||
my $output;
|
my $output;
|
||||||
my $cnf='/tmp/12345/my.sandbox.cnf';
|
my $row;
|
||||||
my $cmd = "$trunk/bin/pt-table-checksum -F $cnf 127.0.0.1";
|
|
||||||
|
|
||||||
$sb->create_dbs($master_dbh, [qw(test)]);
|
$sb->create_dbs($master_dbh, [qw(test)]);
|
||||||
$sb->load_file('master', 't/pt-table-checksum/samples/issue_47.sql');
|
$sb->load_file('master', 't/pt-table-checksum/samples/issue_47.sql');
|
||||||
@@ -41,15 +40,31 @@ $sb->load_file('master', 't/pt-table-checksum/samples/issue_47.sql');
|
|||||||
# Issue 47: TableChunker::range_num broken for very large bigint
|
# Issue 47: TableChunker::range_num broken for very large bigint
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
|
|
||||||
$output = `/tmp/12345/use -e 'SELECT * FROM test.issue_47'`;
|
# pt-table-checksum 2.0 doesn't use TableChunker; it uses NibbleIterator.
|
||||||
like($output, qr/18446744073709551615/, 'Loaded max unsigned bigint for testing issue 47');
|
# But we'll test this anyway to make sure that NibbleIterator can't handle
|
||||||
|
# very larger integers.
|
||||||
|
|
||||||
$output = `$cmd P=12346 -d test -t issue_47 --chunk-size 4 2>&1`;
|
$output = pt_table_checksum::main(@args, qw(-t test.issue_47),
|
||||||
unlike($output, qr/Chunk size is too small/, 'Unsigned bigint chunks (issue 47)');
|
qw(--chunk-time 0 --chunk-size 3 --quiet));
|
||||||
|
is(
|
||||||
|
$output,
|
||||||
|
"0",
|
||||||
|
"No error nibbling very large int"
|
||||||
|
);
|
||||||
|
|
||||||
|
$row = $master_dbh->selectall_arrayref("select lower_boundary, upper_boundary from percona.checksums where db='test' and tbl='issue_47' order by chunk");
|
||||||
|
is_deeply(
|
||||||
|
$row,
|
||||||
|
[
|
||||||
|
[ '1', '300' ],
|
||||||
|
[ '1000', '2220293' ],
|
||||||
|
[ '65553510', '18446744073709551615' ],
|
||||||
|
],
|
||||||
|
"Uses very large int as chunk boundary"
|
||||||
|
);
|
||||||
|
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Done.
|
# Done.
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
$sb->wipe_clean($master_dbh);
|
#$sb->wipe_clean($master_dbh);
|
||||||
$sb->wipe_clean($slave_dbh);
|
|
||||||
exit;
|
exit;
|
||||||
|
@@ -26,8 +26,12 @@ else {
|
|||||||
plan tests => 1;
|
plan tests => 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# 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.
|
||||||
|
my $master_dsn = 'h=127.1,P=12345,u=msandbox,p=msandbox';
|
||||||
|
my @args = ($master_dsn, qw(--lock-wait-timeout 3));
|
||||||
my $output;
|
my $output;
|
||||||
my $cnf = '/tmp/12345/my.sandbox.cnf';
|
|
||||||
$sb->load_file('master', 't/pt-table-checksum/samples/issue_602.sql');
|
$sb->load_file('master', 't/pt-table-checksum/samples/issue_602.sql');
|
||||||
|
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
@@ -35,14 +39,13 @@ $sb->load_file('master', 't/pt-table-checksum/samples/issue_602.sql');
|
|||||||
# #############################################################################
|
# #############################################################################
|
||||||
|
|
||||||
$output = output(
|
$output = output(
|
||||||
sub {
|
sub { pt_table_checksum::main(@args, qw(-t issue_602.t --chunk-size 5)) },
|
||||||
pt_table_checksum::main("F=$cnf", qw(-t issue_602.t --chunk-size 5)) },
|
|
||||||
stderr => 1,
|
stderr => 1,
|
||||||
);
|
);
|
||||||
|
|
||||||
like(
|
like(
|
||||||
$output,
|
$output,
|
||||||
qr/^issue_602\s+t\s+2/m,
|
qr/^\S+\s+0\s+0\s+11\s+2\s+/m,
|
||||||
"Checksums table despite invalid datetime"
|
"Checksums table despite invalid datetime"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@@ -1,75 +0,0 @@
|
|||||||
#!/usr/bin/env perl
|
|
||||||
|
|
||||||
BEGIN {
|
|
||||||
die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
|
|
||||||
unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
|
|
||||||
unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
|
|
||||||
};
|
|
||||||
|
|
||||||
use strict;
|
|
||||||
use warnings FATAL => 'all';
|
|
||||||
use English qw(-no_match_vars);
|
|
||||||
use Test::More;
|
|
||||||
|
|
||||||
use PerconaTest;
|
|
||||||
use Sandbox;
|
|
||||||
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');
|
|
||||||
my $slave_dbh = $sb->get_dbh_for('slave1');
|
|
||||||
|
|
||||||
if ( !$master_dbh ) {
|
|
||||||
plan skip_all => 'Cannot connect to sandbox master';
|
|
||||||
}
|
|
||||||
elsif ( !$slave_dbh ) {
|
|
||||||
plan skip_all => 'Cannot connect to sandbox slave';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
plan tests => 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
`$trunk/sandbox/test-env reset >/dev/null`;
|
|
||||||
|
|
||||||
my $output;
|
|
||||||
my $cnf='/tmp/12345/my.sandbox.cnf';
|
|
||||||
my $cmd = "$trunk/bin/pt-table-checksum -F $cnf 127.0.0.1";
|
|
||||||
|
|
||||||
$sb->create_dbs($master_dbh, [qw(test)]);
|
|
||||||
$sb->load_file('master', 't/pt-table-checksum/samples/checksum_tbl.sql');
|
|
||||||
$sb->load_file('master', 't/pt-table-checksum/samples/issue_21.sql');
|
|
||||||
|
|
||||||
# #############################################################################
|
|
||||||
# Issue 69: mk-table-checksum should be able to re-checksum things that differ
|
|
||||||
# #############################################################################
|
|
||||||
|
|
||||||
`$cmd -d test --replicate test.checksum`;
|
|
||||||
$slave_dbh->do("update test.checksum set this_crc='' where test.checksum.tbl = 'issue_21'");
|
|
||||||
|
|
||||||
# Can't use $cmd; see http://code.google.com/p/maatkit/issues/detail?id=802
|
|
||||||
`$trunk/bin/pt-table-checksum h=127.1,P=12345,u=msandbox,p=msandbox -d test --replicate test.checksum --replicate-check 1 2>&1`;
|
|
||||||
|
|
||||||
$output = `$trunk/bin/pt-table-checksum h=127.1,P=12345,u=msandbox,p=msandbox -d test --replicate test.checksum --replicate-check 1 --recheck`;
|
|
||||||
like(
|
|
||||||
$output,
|
|
||||||
qr/^test\s+issue_21\s+0\s+127.1\s+InnoDB\s+5\s+b88b4eff\s+\d\s+NULL\s+NULL\s+NULL$/m,
|
|
||||||
'--recheck reports inconsistent table like --replicate'
|
|
||||||
);
|
|
||||||
|
|
||||||
# Now check that --recheck actually caused the inconsistent table to be
|
|
||||||
# re-checksummed on the master.
|
|
||||||
$output = 'foo';
|
|
||||||
$output = `$cmd --replicate test.checksum --replicate-check 1`;
|
|
||||||
is(
|
|
||||||
$output,
|
|
||||||
'',
|
|
||||||
'--recheck re-checksummed inconsistent table; it is now consistent'
|
|
||||||
);
|
|
||||||
|
|
||||||
# #############################################################################
|
|
||||||
# Done.
|
|
||||||
# #############################################################################
|
|
||||||
$sb->wipe_clean($master_dbh);
|
|
||||||
$sb->wipe_clean($slave_dbh);
|
|
||||||
exit;
|
|
@@ -1,15 +1,17 @@
|
|||||||
CREATE DATABASE IF NOT EXISTS test;
|
|
||||||
USE test;
|
USE test;
|
||||||
DROP TABLE IF EXISTS checksum;
|
DROP TABLE IF EXISTS truncated_checksums;
|
||||||
CREATE TABLE checksum (
|
CREATE TABLE truncated_checksums (
|
||||||
db char(64) NOT NULL,
|
db char(64) NOT NULL,
|
||||||
tbl char(64) NOT NULL,
|
tbl char(64) NOT NULL,
|
||||||
chunk int NOT NULL,
|
chunk int NOT NULL,
|
||||||
boundaries char(1) NOT NULL, -- should cause a truncation
|
chunk_time float NULL,
|
||||||
|
chunk_index varchar(200) NULL,
|
||||||
|
lower_boundary char(1) NOT NULL, -- will cause truncation error
|
||||||
|
upper_boundary char(1) NOT NULL, -- will cause truncation error
|
||||||
this_crc char(40) NOT NULL,
|
this_crc char(40) NOT NULL,
|
||||||
this_cnt int NOT NULL,
|
this_cnt int NOT NULL,
|
||||||
master_crc char(40) NULL,
|
master_crc char(40) NULL,
|
||||||
master_cnt int NULL,
|
master_cnt int NULL,
|
||||||
ts timestamp NOT NULL,
|
ts timestamp NOT NULL,
|
||||||
PRIMARY KEY (db, tbl, chunk)
|
PRIMARY KEY (db, tbl, chunk)
|
||||||
);
|
) ENGINE=InnoDB;
|
||||||
|
5
t/pt-table-checksum/samples/no-recheck.txt
Normal file
5
t/pt-table-checksum/samples/no-recheck.txt
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
Differences on h=127.0.0.1,P=12346
|
||||||
|
TABLE CHUNK CNT_DIFF CRC_DIFF CHUNK_INDEX LOWER_BOUNDARY UPPER_BOUNDARY
|
||||||
|
sakila.city 1 0 1 PRIMARY 1 100
|
||||||
|
sakila.city 6 0 1 PRIMARY 501 600
|
||||||
|
|
Reference in New Issue
Block a user