Fix for 911385: pt-table-checksum v2 fails when --resume + --ignore-database is used

This commit is contained in:
Brian Fraser
2012-11-08 13:42:29 -03:00
parent fb345eb3fd
commit 426d599566
3 changed files with 39 additions and 17 deletions

View File

@@ -5281,7 +5281,7 @@ sub _get_hash_func {
} }
my ($dbh) = @args{@required_args}; my ($dbh) = @args{@required_args};
my $o = $self->{OptionParser}; my $o = $self->{OptionParser};
my @funcs = qw(CRC32 FNV1A_64 FNV_64 MD5 SHA1); my @funcs = qw(CRC32 FNV1A_64 FNV_64 MURMUR_HASH MD5 SHA1);
if ( my $func = $o->get('function') ) { if ( my $func = $o->get('function') ) {
unshift @funcs, $func; unshift @funcs, $func;
@@ -5302,7 +5302,7 @@ sub _get_hash_func {
PTDEBUG && _d('Chosen hash func:', $result); PTDEBUG && _d('Chosen hash func:', $result);
return $func; return $func;
} }
die $error || 'No hash functions (CRC32, MD5, etc.) are available'; die($error || 'No hash functions (CRC32, MD5, etc.) are available');
} }
sub _get_crc_width { sub _get_crc_width {
@@ -6782,9 +6782,10 @@ sub _iterate_dbh {
} }
if ( !$self->{db} ) { if ( !$self->{db} ) {
do { while ( @{$self->{dbs}} ) {
$self->{db} = shift @{$self->{dbs}}; $self->{db} = shift @{$self->{dbs}};
} until $self->_resume_from_database($self->{db}); last if $self->_resume_from_database($self->{db});
}
PTDEBUG && _d('Next database:', $self->{db}); PTDEBUG && _d('Next database:', $self->{db});
return unless $self->{db}; return unless $self->{db};
} }

View File

@@ -327,9 +327,10 @@ sub _iterate_dbh {
} }
if ( !$self->{db} ) { if ( !$self->{db} ) {
do { while ( @{$self->{dbs}} ) {
$self->{db} = shift @{$self->{dbs}}; $self->{db} = shift @{$self->{dbs}};
} until $self->_resume_from_database($self->{db}); last if $self->_resume_from_database($self->{db});
}
PTDEBUG && _d('Next database:', $self->{db}); PTDEBUG && _d('Next database:', $self->{db});
return unless $self->{db}; return unless $self->{db};
} }

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 => 30; use Test::More;
use SchemaIterator; use SchemaIterator;
use FileIterator; use FileIterator;
@@ -77,6 +77,7 @@ sub test_so {
my $res = ""; my $res = "";
my @objs; my @objs;
eval {
while ( my $obj = $si->next() ) { while ( my $obj = $si->next() ) {
if ( $args{return_objs} ) { if ( $args{return_objs} ) {
push @objs, $obj; push @objs, $obj;
@@ -91,6 +92,7 @@ sub test_so {
} }
} }
} }
};
return \@objs if $args{return_objs}; return \@objs if $args{return_objs};
@@ -114,6 +116,9 @@ sub test_so {
$args{test_name}, $args{test_name},
); );
} }
elsif ( $args{lives_ok} ) {
is($EVAL_ERROR, '', $args{test_name});
}
else { else {
is( is(
$res, $res,
@@ -406,8 +411,23 @@ test_so(
test_name => "Resume from ignored table" test_name => "Resume from ignored table"
); );
# ############################################################################
# pt-table-checksum v2 fails when --resume + --ignore-database is used
# https://bugs.launchpad.net/percona-toolkit/+bug/911385
# ############################################################################
# Actually, the important bit here si that it doesn't die, not the results.
test_so(
filters => ['--ignore-databases', 'sakila,mysql'],
result => "", # hack; uses lives_ok instead
lives_ok => 1,
test_name => "Bug 911385: pt-table-checksum v2 fails when --resume + --ignore-database is used"
);
# ############################################################################# # #############################################################################
# Done. # Done.
# ############################################################################# # #############################################################################
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox"); ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
done_testing;
exit; exit;