Merge lp:~percona-toolkit-dev/percona-toolkit/fix-1074179-ptc-replicate-check-only-filters into lp:percona-toolkit/2.1

Proposed by Brian Fraser
Status: Merged
Approved by: Daniel Nichter
Approved revision: 457
Merged at revision: 471
Proposed branch: lp:~percona-toolkit-dev/percona-toolkit/fix-1074179-ptc-replicate-check-only-filters
Merge into: lp:percona-toolkit/2.1
Diff against target: 70 lines (+42/-0)
2 files modified
bin/pt-table-checksum (+25/-0)
t/pt-table-checksum/bugs.t (+17/-0)
To merge this branch: bzr merge lp:~percona-toolkit-dev/percona-toolkit/fix-1074179-ptc-replicate-check-only-filters
Reviewer Review Type Date Requested Status
Daniel Nichter Approve
Review via email: mp+134669@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Daniel Nichter (daniel-nichter) wrote :

Before merging, could you please add TODO or XXX to

20 + # SchemaIterator has the methdos to filter the dbs & tables,
21 + # but we don't actually need a real iterator beyond that
22 + my $filter = new SchemaIterator(

so we can grep for it later. We need to refactor-fix SchemaIterator so we can use its filters sub without fake input.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bin/pt-table-checksum'
--- bin/pt-table-checksum 2012-11-13 15:22:01 +0000
+++ bin/pt-table-checksum 2012-11-16 14:27:22 +0000
@@ -8810,6 +8810,7 @@
8810 );8810 );
8811 PTDEBUG && _d(scalar @$diffs, 'checksum diffs on',8811 PTDEBUG && _d(scalar @$diffs, 'checksum diffs on',
8812 $slave->name());8812 $slave->name());
8813 $diffs = filter_tables_replicate_check_only($diffs, $o);
8813 if ( @$diffs ) {8814 if ( @$diffs ) {
8814 $exit_status |= 1;8815 $exit_status |= 1;
8815 if ( $o->get('quiet') < 2 ) { 8816 if ( $o->get('quiet') < 2 ) {
@@ -9943,6 +9944,30 @@
9943}9944}
9944}9945}
99459946
9947sub filter_tables_replicate_check_only {
9948 my ($diffs, $o) = @_;
9949 my @filtered_diffs;
9950
9951 # SchemaIterator has the methdos to filter the dbs & tables,
9952 # but we don't actually need a real iterator beyond that
9953 my $filter = new SchemaIterator(
9954 file_itr => "Fake",
9955 OptionParser => $o,
9956 Quoter => "Quoter",
9957 TableParser => "TableParser",
9958 );
9959
9960 for my $diff (@$diffs) {
9961 my ($db, $table) = Quoter->split_unquote($diff->{table});
9962 next unless $filter->database_is_allowed($db)
9963 && $filter->table_is_allowed($db, $table);
9964 push @filtered_diffs, $diff;
9965
9966 }
9967
9968 return \@filtered_diffs;
9969}
9970
9946sub check_repl_table {9971sub check_repl_table {
9947 my ( %args ) = @_;9972 my ( %args ) = @_;
9948 my @required_args = qw(dbh repl_table slaves9973 my @required_args = qw(dbh repl_table slaves
99499974
=== modified file 't/pt-table-checksum/bugs.t'
--- t/pt-table-checksum/bugs.t 2012-11-08 20:38:04 +0000
+++ t/pt-table-checksum/bugs.t 2012-11-16 14:27:22 +0000
@@ -176,6 +176,23 @@
176);176);
177177
178# #############################################################################178# #############################################################################
179# pt-table-checksum does't ignore tables for --replicate-check-only
180# https://bugs.launchpad.net/percona-toolkit/+bug/1074179
181# #############################################################################
182
183$output = output(
184 sub { pt_table_checksum::main(@args, qw(--replicate-check-only --ignore-tables-regex=t)) },
185 stderr => 1,
186);
187
188chomp($output);
189
190is(
191 $output,
192 '',
193 "Bug 1074179: ignore-tables-regex works with --replicate-check-only"
194);
195# #############################################################################
179# pt-table-checksum can crash with --columns if none match196# pt-table-checksum can crash with --columns if none match
180# https://bugs.launchpad.net/percona-toolkit/+bug/1016131197# https://bugs.launchpad.net/percona-toolkit/+bug/1016131
181# #############################################################################198# #############################################################################

Subscribers

People subscribed via source and target branches