Merge lp:~percona-toolkit-dev/percona-toolkit/fix-ptc-bug-1210537 into lp:~percona-toolkit-dev/percona-toolkit/release-2.2.5

Proposed by Daniel Nichter
Status: Merged
Approved by: Daniel Nichter
Approved revision: 626
Merged at revision: 622
Proposed branch: lp:~percona-toolkit-dev/percona-toolkit/fix-ptc-bug-1210537
Merge into: lp:~percona-toolkit-dev/percona-toolkit/release-2.2.5
Diff against target: 176 lines (+77/-20)
4 files modified
bin/pt-table-checksum (+13/-4)
lib/MasterSlave.pm (+14/-7)
t/lib/MasterSlave.t (+28/-9)
t/pt-table-checksum/bugs.t (+22/-0)
To merge this branch: bzr merge lp:~percona-toolkit-dev/percona-toolkit/fix-ptc-bug-1210537
Reviewer Review Type Date Requested Status
Daniel Nichter Approve
Review via email: mp+188894@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
=== modified file 'bin/pt-table-checksum'
--- bin/pt-table-checksum 2013-08-08 19:28:36 +0000
+++ bin/pt-table-checksum 2013-10-02 18:43:27 +0000
@@ -9208,15 +9208,24 @@
9208 }9208 }
92099209
9210 my $trimmed_nodes = Cxn->remove_duplicate_cxns(9210 my $trimmed_nodes = Cxn->remove_duplicate_cxns(
9211 cxns => [ $master_cxn, @$slaves ],9211 cxns => [ $master_cxn, @$slaves ],
9212 );9212 );
9213 ($master_cxn, @$slaves) = @$trimmed_nodes;9213 ($master_cxn, @$slaves) = @$trimmed_nodes;
92149214
9215 # If no slaves or nodes were found, and a recursion method was given
9216 # (implicitly or explicitly), and that method is not none, then warn
9217 # and continue but exit non-zero because there won't be any diffs but
9218 # this could be a false-positive from having no slaves/nodes to check.
9219 # https://bugs.launchpad.net/percona-toolkit/+bug/1210537
9215 PTDEBUG && _d(scalar @$slaves, 'slaves found');9220 PTDEBUG && _d(scalar @$slaves, 'slaves found');
9216 if ( !@$slaves && $o->get('recursion-method')->[0] ne 'none' ) {9221 if ( !@$slaves
9222 && (($o->get('recursion-method')->[0] || '') ne 'none'
9223 || $autodiscover_cluster))
9224 {
9217 $exit_status |= 1;9225 $exit_status |= 1;
9218 if ( $o->get('quiet') < 2 ) {9226 if ( $o->get('quiet') < 2 ) {
9219 warn "Diffs cannot be detected because no slaves were found. "9227 my $type = $autodiscover_cluster ? 'cluster nodes' : 'slaves';
9228 warn "Diffs cannot be detected because no $type were found. "
9220 . "Please read the --recursion-method documentation for "9229 . "Please read the --recursion-method documentation for "
9221 . "information.\n";9230 . "information.\n";
9222 }9231 }
92239232
=== modified file 'lib/MasterSlave.pm'
--- lib/MasterSlave.pm 2013-04-12 15:58:10 +0000
+++ lib/MasterSlave.pm 2013-10-02 18:43:27 +0000
@@ -32,8 +32,18 @@
32sub check_recursion_method {32sub check_recursion_method {
33 my ($methods) = @_;33 my ($methods) = @_;
3434
35 if ( @$methods != 1 ) {35 # Check that each method is valid.
36 if ( grep({ !m/processlist|hosts/i } @$methods)36 foreach my $method ( @$methods ) {
37 die "Invalid recursion method: " . ($method || 'undef') . "\n"
38 unless $method && $method =~ m/^(?:processlist$|hosts$|none$|cluster|dsn=)/i;
39 }
40
41 # Check for invalid combination of methods.
42 if ( @$methods > 1 ) {
43 if ( grep( { m/none/ } @$methods) && grep( {! m/none/ } @$methods) ) {
44 die "--recursion-method=none cannot be combined with other methods\n";
45 }
46 elsif ( grep({ !m/processlist|hosts/i } @$methods)
37 && $methods->[0] !~ /^dsn=/i )47 && $methods->[0] !~ /^dsn=/i )
38 {48 {
39 die "Invalid combination of recursion methods: "49 die "Invalid combination of recursion methods: "
@@ -41,11 +51,8 @@
41 . "Only hosts and processlist may be combined.\n"51 . "Only hosts and processlist may be combined.\n"
42 }52 }
43 }53 }
44 else {54
45 my ($method) = @$methods;55 return;
46 die "Invalid recursion method: " . ( $method || 'undef' )
47 unless $method && $method =~ m/^(?:processlist$|hosts$|none$|dsn=)/i;
48 }
49}56}
5057
51sub new {58sub new {
5259
=== modified file 't/lib/MasterSlave.t'
--- t/lib/MasterSlave.t 2012-08-14 23:08:06 +0000
+++ t/lib/MasterSlave.t 2013-10-02 18:43:27 +0000
@@ -11,10 +11,6 @@
11use English qw(-no_match_vars);11use English qw(-no_match_vars);
12use Test::More;12use Test::More;
1313
14if ( !$ENV{SLOW_TESTS} ) {
15 plan skip_all => "lib/MasterSlave.t is a top 5 slowest file; set SLOW_TESTS=1 to enable it.";
16}
17
18use MasterSlave;14use MasterSlave;
19use DSNParser;15use DSNParser;
20use VersionParser;16use VersionParser;
@@ -709,28 +705,51 @@
709# ############################################################################705# ############################################################################
710# Invalid recursion methods are caught706# Invalid recursion methods are caught
711# ############################################################################707# ############################################################################
712local $EVAL_ERROR;
713eval {708eval {
714 MasterSlave::check_recursion_method([qw(stuff)])709 MasterSlave::check_recursion_method([qw(stuff)])
715};710};
716
717like(711like(
718 $EVAL_ERROR,712 $EVAL_ERROR,
719 qr/Invalid recursion method: stuff/,713 qr/Invalid recursion method: stuff/,
720 "--recursion-method stuff causes error"714 "--recursion-method stuff causes error"
721);715);
722716
723local $EVAL_ERROR;
724eval {717eval {
725 MasterSlave::check_recursion_method([qw(processlist stuff)])718 MasterSlave::check_recursion_method([qw(processlist stuff)])
726};719};
727
728like(720like(
729 $EVAL_ERROR,721 $EVAL_ERROR,
730 qr/Invalid combination of recursion methods: processlist, stuff/,722 qr/Invalid recursion method: stuff/,
731 "--recursion-method processlist,stuff causes error",723 "--recursion-method processlist,stuff causes error",
732);724);
733725
726eval {
727 MasterSlave::check_recursion_method([qw(none hosts)])
728};
729like(
730 $EVAL_ERROR,
731 qr/none cannot be combined with other methods/,
732 "--recursion-method none,hosts"
733);
734
735eval {
736 MasterSlave::check_recursion_method([qw(cluster none)])
737};
738like(
739 $EVAL_ERROR,
740 qr/none cannot be combined with other methods/,
741 "--recursion-method cluster,none"
742);
743
744eval {
745 MasterSlave::check_recursion_method([qw(none none)])
746};
747like(
748 $EVAL_ERROR,
749 qr/Invalid combination of recursion methods: none, none/,
750 "--recursion-method none,none"
751);
752
734# #############################################################################753# #############################################################################
735# Done.754# Done.
736# #############################################################################755# #############################################################################
737756
=== modified file 't/pt-table-checksum/bugs.t'
--- t/pt-table-checksum/bugs.t 2013-03-02 02:02:13 +0000
+++ t/pt-table-checksum/bugs.t 2013-10-02 18:43:27 +0000
@@ -273,6 +273,28 @@
273}273}
274274
275# #############################################################################275# #############################################################################
276# pt-table-checksum --recursion-method cluster crashes
277# https://bugs.launchpad.net/percona-toolkit/+bug/1210537
278# #############################################################################
279
280$output = output(sub {
281 pt_table_checksum::main($master_dsn,
282 qw(--recursion-method cluster -t mysql.user)
283 )},
284 stderr => 1,
285);
286unlike(
287 $output,
288 qr/uninitialized value/,
289 "Bug 1210537: no crash with --recursion-method cluster"
290);
291like(
292 $output,
293 qr/mysql.user/,
294 "Bug 1210537: tool ran"
295);
296
297# #############################################################################
276# Done.298# Done.
277# #############################################################################299# #############################################################################
278$sb->wipe_clean($master_dbh);300$sb->wipe_clean($master_dbh);

Subscribers

People subscribed via source and target branches

to all changes: