Merge lp:~percona-toolkit-dev/percona-toolkit/fix-ptc-slave-warn-bug-1087804 into lp:percona-toolkit/2.2

Proposed by Daniel Nichter
Status: Merged
Merged at revision: 507
Proposed branch: lp:~percona-toolkit-dev/percona-toolkit/fix-ptc-slave-warn-bug-1087804
Merge into: lp:percona-toolkit/2.2
Diff against target: 107 lines (+68/-2)
2 files modified
bin/pt-table-checksum (+16/-0)
t/pt-table-checksum/basics.t (+52/-2)
To merge this branch: bzr merge lp:~percona-toolkit-dev/percona-toolkit/fix-ptc-slave-warn-bug-1087804
Reviewer Review Type Date Requested Status
Daniel Nichter Approve
Review via email: mp+141775@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Daniel Nichter (daniel-nichter) :
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-12-20 23:05:06 +0000
3+++ bin/pt-table-checksum 2013-01-03 16:02:24 +0000
4@@ -8741,6 +8741,15 @@
5 } @$slaves;
6 }
7 PTDEBUG && _d(scalar @$slaves, 'slaves found');
8+ if ( !@$slaves && $o->get('recursion-method')->[0] ne 'none' ) {
9+ $exit_status |= 1;
10+ if ( $o->get('quiet') < 2 ) {
11+ warn "Diffs cannot be detected because no slaves were found. "
12+ . "Please read the --recursion-method documentation for "
13+ . "information.\n";
14+ }
15+ }
16+
17
18 # https://bugs.launchpad.net/percona-toolkit/+bug/938068
19 if ( $o->get('check-binlog-format') ) {
20@@ -11490,6 +11499,13 @@
21
22 Preferred recursion method for discovering replicas. pt-table-checksum
23 performs several L<"REPLICA CHECKS"> before and while running.
24+
25+Although replicas are not required to run pt-table-checksum, the tool
26+cannot detect diffs on slaves that it cannot discover. Therefore,
27+a warning is printed and the L<"EXIT STATUS"> is non-zero if no replicas
28+are found and the method is not C<none>. If this happens, try a different
29+recursion method, or use the C<dsn> method to specify the replicas to check.
30+
31 Possible methods are:
32
33 METHOD USES
34
35=== modified file 't/pt-table-checksum/basics.t'
36--- t/pt-table-checksum/basics.t 2012-12-20 23:05:06 +0000
37+++ t/pt-table-checksum/basics.t 2013-01-03 16:02:24 +0000
38@@ -361,10 +361,11 @@
39 stderr => 1,
40 );
41
42+# Before 2.2 the exit status was 0, but bug 1087804 changed this to 1.
43 is(
44 $exit_status,
45- 0,
46- "No host in DSN, zero exit status"
47+ 1,
48+ "No host in DSN, non-zero exit status"
49 );
50
51 is(
52@@ -491,6 +492,55 @@
53 );
54
55 # #############################################################################
56+# Bug 1087804: pt-table-checksum doesn't warn if no slaves are found
57+# #############################################################################
58+$sb->load_file('master', "$sample/dsn-table.sql");
59+$master_dbh->do('TRUNCATE TABLE dsns.dsns');
60+$sb->wait_for_slaves;
61+
62+my $slave1_dsn = $sb->dsn_for('slave1');
63+
64+$output = output(
65+ sub { $exit_status = pt_table_checksum::main(@args,
66+ qw(-t sakila.country),
67+ "--recursion-method", "dsn=$slave1_dsn,t=dsns.dsns")
68+ },
69+ stderr => 1,
70+);
71+
72+like(
73+ $output,
74+ qr/no slaves were found/,
75+ "Warns if no slaves are found"
76+);
77+
78+is(
79+ $exit_status,
80+ 1,
81+ '...exit status 1'
82+);
83+
84+$output = output(
85+ sub { $exit_status = pt_table_checksum::main(@args,
86+ qw(-t sakila.country),
87+ "--recursion-method", "none")
88+ },
89+ stderr => 1,
90+);
91+
92+unlike(
93+ $output,
94+ qr/no slaves were found/,
95+ "No warning if no slaves and --recursion-method=none"
96+);
97+
98+is(
99+ $exit_status,
100+ 0,
101+ '...exit status 0'
102+);
103+
104+# #############################################################################
105 # Done.
106 # #############################################################################
107 $sb->wipe_clean($master_dbh);

Subscribers

People subscribed via source and target branches