Fix for 1074179: pt-table-checksum does't ignore tables for --replicate-check-only

This commit is contained in:
Brian Fraser
2012-11-09 16:37:56 -03:00
parent 511a402911
commit d7a239b369
2 changed files with 42 additions and 0 deletions

View File

@@ -8686,6 +8686,7 @@ sub main {
); );
PTDEBUG && _d(scalar @$diffs, 'checksum diffs on', PTDEBUG && _d(scalar @$diffs, 'checksum diffs on',
$slave->name()); $slave->name());
$diffs = filter_tables_replicate_check_only($diffs, $o);
if ( @$diffs ) { if ( @$diffs ) {
$exit_status |= 1; $exit_status |= 1;
if ( $o->get('quiet') < 2 ) { if ( $o->get('quiet') < 2 ) {
@@ -9819,6 +9820,30 @@ sub print_checksum_diffs {
} }
} }
sub filter_tables_replicate_check_only {
my ($diffs, $o) = @_;
my @filtered_diffs;
# SchemaIterator has the methdos to filter the dbs & tables,
# but we don't actually need a real iterator beyond that
my $filter = new SchemaIterator(
file_itr => "Fake",
OptionParser => $o,
Quoter => "Quoter",
TableParser => "TableParser",
);
for my $diff (@$diffs) {
my ($db, $table) = Quoter->split_unquote($diff->{table});
next unless $filter->database_is_allowed($db)
&& $filter->table_is_allowed($db, $table);
push @filtered_diffs, $diff;
}
return \@filtered_diffs;
}
sub check_repl_table { sub check_repl_table {
my ( %args ) = @_; my ( %args ) = @_;
my @required_args = qw(dbh repl_table slaves my @required_args = qw(dbh repl_table slaves

View File

@@ -175,6 +175,23 @@ is(
"Bug 1030031 (wrong DIFFS): 3 diffs" "Bug 1030031 (wrong DIFFS): 3 diffs"
); );
# #############################################################################
# pt-table-checksum does't ignore tables for --replicate-check-only
# https://bugs.launchpad.net/percona-toolkit/+bug/1074179
# #############################################################################
$output = output(
sub { pt_table_checksum::main(@args, qw(--replicate-check-only --ignore-tables-regex=t)) },
stderr => 1,
);
chomp($output);
is(
$output,
'',
"Bug 1074179: ignore-tables-regex works with --replicate-check-only"
);
# ############################################################################# # #############################################################################
# pt-table-checksum can crash with --columns if none match # pt-table-checksum can crash with --columns if none match
# https://bugs.launchpad.net/percona-toolkit/+bug/1016131 # https://bugs.launchpad.net/percona-toolkit/+bug/1016131