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
1=== modified file 'bin/pt-table-checksum'
2--- bin/pt-table-checksum 2012-11-13 15:22:01 +0000
3+++ bin/pt-table-checksum 2012-11-16 14:27:22 +0000
4@@ -8810,6 +8810,7 @@
5 );
6 PTDEBUG && _d(scalar @$diffs, 'checksum diffs on',
7 $slave->name());
8+ $diffs = filter_tables_replicate_check_only($diffs, $o);
9 if ( @$diffs ) {
10 $exit_status |= 1;
11 if ( $o->get('quiet') < 2 ) {
12@@ -9943,6 +9944,30 @@
13 }
14 }
15
16+sub filter_tables_replicate_check_only {
17+ my ($diffs, $o) = @_;
18+ my @filtered_diffs;
19+
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(
23+ file_itr => "Fake",
24+ OptionParser => $o,
25+ Quoter => "Quoter",
26+ TableParser => "TableParser",
27+ );
28+
29+ for my $diff (@$diffs) {
30+ my ($db, $table) = Quoter->split_unquote($diff->{table});
31+ next unless $filter->database_is_allowed($db)
32+ && $filter->table_is_allowed($db, $table);
33+ push @filtered_diffs, $diff;
34+
35+ }
36+
37+ return \@filtered_diffs;
38+}
39+
40 sub check_repl_table {
41 my ( %args ) = @_;
42 my @required_args = qw(dbh repl_table slaves
43
44=== modified file 't/pt-table-checksum/bugs.t'
45--- t/pt-table-checksum/bugs.t 2012-11-08 20:38:04 +0000
46+++ t/pt-table-checksum/bugs.t 2012-11-16 14:27:22 +0000
47@@ -176,6 +176,23 @@
48 );
49
50 # #############################################################################
51+# pt-table-checksum does't ignore tables for --replicate-check-only
52+# https://bugs.launchpad.net/percona-toolkit/+bug/1074179
53+# #############################################################################
54+
55+$output = output(
56+ sub { pt_table_checksum::main(@args, qw(--replicate-check-only --ignore-tables-regex=t)) },
57+ stderr => 1,
58+);
59+
60+chomp($output);
61+
62+is(
63+ $output,
64+ '',
65+ "Bug 1074179: ignore-tables-regex works with --replicate-check-only"
66+);
67+# #############################################################################
68 # pt-table-checksum can crash with --columns if none match
69 # https://bugs.launchpad.net/percona-toolkit/+bug/1016131
70 # #############################################################################

Subscribers

People subscribed via source and target branches