mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-10-20 17:49:56 +00:00
Merged fix-911385-schemaiterator-resume-plus-ignore-db
This commit is contained in:
@@ -6767,11 +6767,16 @@ sub next {
|
|||||||
|
|
||||||
if ( !$self->{initialized} ) {
|
if ( !$self->{initialized} ) {
|
||||||
$self->{initialized} = 1;
|
$self->{initialized} = 1;
|
||||||
if ( $self->{resume}->{tbl}
|
if ( $self->{resume}->{tbl} ) {
|
||||||
&& !$self->table_is_allowed(@{$self->{resume}}{qw(db tbl)}) ) {
|
if ( !$self->table_is_allowed(@{$self->{resume}}{qw(db tbl)}) ) {
|
||||||
PTDEBUG && _d('Will resume after',
|
PTDEBUG && _d('Will resume after',
|
||||||
join('.', @{$self->{resume}}{qw(db tbl)}));
|
join('.', @{$self->{resume}}{qw(db tbl)}));
|
||||||
$self->{resume}->{after} = 1;
|
$self->{resume}->{after}->{tbl} = 1;
|
||||||
|
}
|
||||||
|
if ( !$self->database_is_allowed($self->{resume}->{db}) ) {
|
||||||
|
PTDEBUG && _d('Will resume after', $self->{resume}->{db});
|
||||||
|
$self->{resume}->{after}->{db} = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6869,16 +6874,17 @@ sub _iterate_dbh {
|
|||||||
if ( !defined $self->{dbs} ) {
|
if ( !defined $self->{dbs} ) {
|
||||||
my $sql = 'SHOW DATABASES';
|
my $sql = 'SHOW DATABASES';
|
||||||
PTDEBUG && _d($sql);
|
PTDEBUG && _d($sql);
|
||||||
my @dbs = grep { $self->database_is_allowed($_) }
|
my @dbs = grep {
|
||||||
@{$dbh->selectcol_arrayref($sql)};
|
$self->_resume_from_database($_)
|
||||||
|
&&
|
||||||
|
$self->database_is_allowed($_)
|
||||||
|
} @{$dbh->selectcol_arrayref($sql)};
|
||||||
PTDEBUG && _d('Found', scalar @dbs, 'databases');
|
PTDEBUG && _d('Found', scalar @dbs, 'databases');
|
||||||
$self->{dbs} = \@dbs;
|
$self->{dbs} = \@dbs;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !$self->{db} ) {
|
if ( !$self->{db} ) {
|
||||||
do {
|
|
||||||
$self->{db} = shift @{$self->{dbs}};
|
$self->{db} = shift @{$self->{dbs}};
|
||||||
} until $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};
|
||||||
}
|
}
|
||||||
@@ -7051,12 +7057,18 @@ sub _resume_from_database {
|
|||||||
my ($self, $db) = @_;
|
my ($self, $db) = @_;
|
||||||
|
|
||||||
return 1 unless $self->{resume}->{db};
|
return 1 unless $self->{resume}->{db};
|
||||||
|
|
||||||
if ( $db eq $self->{resume}->{db} ) {
|
if ( $db eq $self->{resume}->{db} ) {
|
||||||
PTDEBUG && _d('At resume db', $db);
|
if ( !$self->{resume}->{after}->{db} ) {
|
||||||
|
PTDEBUG && _d('Resuming from db', $db);
|
||||||
delete $self->{resume}->{db};
|
delete $self->{resume}->{db};
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
PTDEBUG && _d('Resuming after db', $db);
|
||||||
|
delete $self->{resume}->{db};
|
||||||
|
delete $self->{resume}->{tbl};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -7067,7 +7079,7 @@ sub _resume_from_table {
|
|||||||
return 1 unless $self->{resume}->{tbl};
|
return 1 unless $self->{resume}->{tbl};
|
||||||
|
|
||||||
if ( $tbl eq $self->{resume}->{tbl} ) {
|
if ( $tbl eq $self->{resume}->{tbl} ) {
|
||||||
if ( !$self->{resume}->{after} ) {
|
if ( !$self->{resume}->{after}->{tbl} ) {
|
||||||
PTDEBUG && _d('Resuming from table', $tbl);
|
PTDEBUG && _d('Resuming from table', $tbl);
|
||||||
delete $self->{resume}->{tbl};
|
delete $self->{resume}->{tbl};
|
||||||
return 1;
|
return 1;
|
||||||
|
@@ -203,11 +203,16 @@ sub next {
|
|||||||
|
|
||||||
if ( !$self->{initialized} ) {
|
if ( !$self->{initialized} ) {
|
||||||
$self->{initialized} = 1;
|
$self->{initialized} = 1;
|
||||||
if ( $self->{resume}->{tbl}
|
if ( $self->{resume}->{tbl} ) {
|
||||||
&& !$self->table_is_allowed(@{$self->{resume}}{qw(db tbl)}) ) {
|
if ( !$self->table_is_allowed(@{$self->{resume}}{qw(db tbl)}) ) {
|
||||||
PTDEBUG && _d('Will resume after',
|
PTDEBUG && _d('Will resume after',
|
||||||
join('.', @{$self->{resume}}{qw(db tbl)}));
|
join('.', @{$self->{resume}}{qw(db tbl)}));
|
||||||
$self->{resume}->{after} = 1;
|
$self->{resume}->{after}->{tbl} = 1;
|
||||||
|
}
|
||||||
|
if ( !$self->database_is_allowed($self->{resume}->{db}) ) {
|
||||||
|
PTDEBUG && _d('Will resume after', $self->{resume}->{db});
|
||||||
|
$self->{resume}->{after}->{db} = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -320,16 +325,17 @@ sub _iterate_dbh {
|
|||||||
# This happens once, the first time we're called.
|
# This happens once, the first time we're called.
|
||||||
my $sql = 'SHOW DATABASES';
|
my $sql = 'SHOW DATABASES';
|
||||||
PTDEBUG && _d($sql);
|
PTDEBUG && _d($sql);
|
||||||
my @dbs = grep { $self->database_is_allowed($_) }
|
my @dbs = grep {
|
||||||
@{$dbh->selectcol_arrayref($sql)};
|
$self->_resume_from_database($_)
|
||||||
|
&&
|
||||||
|
$self->database_is_allowed($_)
|
||||||
|
} @{$dbh->selectcol_arrayref($sql)};
|
||||||
PTDEBUG && _d('Found', scalar @dbs, 'databases');
|
PTDEBUG && _d('Found', scalar @dbs, 'databases');
|
||||||
$self->{dbs} = \@dbs;
|
$self->{dbs} = \@dbs;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !$self->{db} ) {
|
if ( !$self->{db} ) {
|
||||||
do {
|
|
||||||
$self->{db} = shift @{$self->{dbs}};
|
$self->{db} = shift @{$self->{dbs}};
|
||||||
} until $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};
|
||||||
}
|
}
|
||||||
@@ -523,12 +529,20 @@ sub _resume_from_database {
|
|||||||
|
|
||||||
# "Resume" from any db if we're not, in fact, resuming.
|
# "Resume" from any db if we're not, in fact, resuming.
|
||||||
return 1 unless $self->{resume}->{db};
|
return 1 unless $self->{resume}->{db};
|
||||||
|
|
||||||
if ( $db eq $self->{resume}->{db} ) {
|
if ( $db eq $self->{resume}->{db} ) {
|
||||||
PTDEBUG && _d('At resume db', $db);
|
if ( !$self->{resume}->{after}->{db} ) {
|
||||||
|
PTDEBUG && _d('Resuming from db', $db);
|
||||||
delete $self->{resume}->{db};
|
delete $self->{resume}->{db};
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
PTDEBUG && _d('Resuming after db', $db);
|
||||||
|
# If we're not resuming from the resume db, then
|
||||||
|
# we aren't resuming from the resume table either.
|
||||||
|
delete $self->{resume}->{db};
|
||||||
|
delete $self->{resume}->{tbl};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -540,7 +554,7 @@ sub _resume_from_table {
|
|||||||
return 1 unless $self->{resume}->{tbl};
|
return 1 unless $self->{resume}->{tbl};
|
||||||
|
|
||||||
if ( $tbl eq $self->{resume}->{tbl} ) {
|
if ( $tbl eq $self->{resume}->{tbl} ) {
|
||||||
if ( !$self->{resume}->{after} ) {
|
if ( !$self->{resume}->{after}->{tbl} ) {
|
||||||
PTDEBUG && _d('Resuming from table', $tbl);
|
PTDEBUG && _d('Resuming from table', $tbl);
|
||||||
delete $self->{resume}->{tbl};
|
delete $self->{resume}->{tbl};
|
||||||
return 1;
|
return 1;
|
||||||
|
@@ -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,6 +411,44 @@ 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
|
||||||
|
# ############################################################################
|
||||||
|
|
||||||
|
test_so(
|
||||||
|
filters => ['--ignore-databases', 'sakila,mysql'],
|
||||||
|
result => "",
|
||||||
|
lives_ok => 1,
|
||||||
|
resume => 'sakila.payment',
|
||||||
|
test_name => "Bug 911385: ptc works with --resume + --ignore-database"
|
||||||
|
);
|
||||||
|
|
||||||
|
$dbh->do("CREATE DATABASE zakila");
|
||||||
|
$dbh->do("CREATE TABLE zakila.bug_911385 (i int)");
|
||||||
|
test_so(
|
||||||
|
filters => ['--ignore-databases', 'sakila,mysql'],
|
||||||
|
result => "zakila.bug_911385 ",
|
||||||
|
resume => 'sakila.payment',
|
||||||
|
test_name => "Bug 911385: ...and continues to the next db"
|
||||||
|
);
|
||||||
|
$dbh->do("DROP DATABASE zakila");
|
||||||
|
|
||||||
|
test_so(
|
||||||
|
filters => [qw(--ignore-tables-regex payment --ignore-databases mysql)],
|
||||||
|
result => "",
|
||||||
|
lives_ok => 1,
|
||||||
|
resume => 'sakila.payment',
|
||||||
|
test_name => "Bug 911385: ptc works with --resume + --ignore-tables-regex"
|
||||||
|
);
|
||||||
|
|
||||||
|
test_so(
|
||||||
|
filters => [qw(--ignore-tables-regex payment --ignore-databases mysql)],
|
||||||
|
result => "sakila.rental sakila.staff sakila.store ",
|
||||||
|
resume => 'sakila.payment',
|
||||||
|
test_name => "Bug 911385: ...and continues to the next table"
|
||||||
|
);
|
||||||
|
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Bug 1047335: pt-duplicate-key-checker fails when it encounters a crashed table
|
# Bug 1047335: pt-duplicate-key-checker fails when it encounters a crashed table
|
||||||
# https://bugs.launchpad.net/percona-toolkit/+bug/1047335
|
# https://bugs.launchpad.net/percona-toolkit/+bug/1047335
|
||||||
@@ -514,3 +557,4 @@ diag(`$trunk/sandbox/stop-sandbox $master3_port >/dev/null`);
|
|||||||
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;
|
done_testing;
|
||||||
|
exit;
|
||||||
|
Reference in New Issue
Block a user