Merge lp:~percona-toolkit-dev/percona-toolkit/fix-ptc-innodb-bug-994010 into lp:percona-toolkit/2.1

Proposed by Daniel Nichter
Status: Merged
Approved by: Daniel Nichter
Approved revision: 245
Merged at revision: 244
Proposed branch: lp:~percona-toolkit-dev/percona-toolkit/fix-ptc-innodb-bug-994010
Merge into: lp:percona-toolkit/2.1
Diff against target: 125 lines (+88/-7)
3 files modified
bin/pt-table-checksum (+5/-1)
sandbox/start-sandbox (+11/-6)
t/pt-table-checksum/skip_innodb.t (+72/-0)
To merge this branch: bzr merge lp:~percona-toolkit-dev/percona-toolkit/fix-ptc-innodb-bug-994010
Reviewer Review Type Date Requested Status
Daniel Nichter Approve
Review via email: mp+104770@code.launchpad.net
To post a comment you must log in.
245. By Daniel Nichter

Check if lwt is not defined, since 0 could be a valid value.

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-04-03 19:42:45 +0000
3+++ bin/pt-table-checksum 2012-05-04 16:20:29 +0000
4@@ -6015,7 +6015,11 @@
5 PTDEBUG && _d($dbh, $sql);
6 my (undef, $curr_lwt) = $dbh->selectrow_array($sql);
7 PTDEBUG && _d('innodb_lock_wait_timeout on server:', $curr_lwt);
8- if ( $curr_lwt > $lock_wait_timeout ) {
9+ if ( !defined $curr_lwt ) {
10+ PTDEBUG && _d('innodb_lock_wait_timeout does not exist;',
11+ 'InnoDB is probably disabled');
12+ }
13+ elsif ( $curr_lwt > $lock_wait_timeout ) {
14 warn "Failed to $set_lwt: $EVAL_ERROR\n"
15 . "The current innodb_lock_wait_timeout value "
16 . "$curr_lwt is greater than the --lock-wait-timeout "
17
18=== modified file 'sandbox/start-sandbox'
19--- sandbox/start-sandbox 2011-12-21 19:10:57 +0000
20+++ sandbox/start-sandbox 2012-05-04 16:20:29 +0000
21@@ -43,16 +43,21 @@
22 if [ -n "$GENLOG" ]; then
23 echo "log=genlog" >> /tmp/$port/my.sandbox.cnf
24 fi
25+ if [ -n "$SKIP_INNODB" ]; then
26+ echo "skip-innodb" >> /tmp/$port/my.sandbox.cnf
27+ fi
28
29 # Start the sandbox and check that it has InnoDB.
30 /tmp/$port/start
31 if [ $? -eq 0 ]; then
32- /tmp/$port/use -e 'SHOW /*!40100 ENGINE*/ INNODB STATUS' | grep 'INNODB MONITOR OUTPUT' >/dev/null 2>&1
33- # grep exits 0 if lines are found
34- if [ $? -ne 0 ]; then
35- echo "****** WARNING sandbox doesn't have a working InnoDB! ******" >&2
36- cat /tmp/$port/data/mysqld.log >&2
37- exit 1
38+ if [ -z "$SKIP_INNODB" ]; then
39+ /tmp/$port/use -e 'SHOW /*!40100 ENGINE*/ INNODB STATUS' | grep 'INNODB MONITOR OUTPUT' >/dev/null 2>&1
40+ # grep exits 0 if lines are found
41+ if [ $? -ne 0 ]; then
42+ echo "****** WARNING sandbox doesn't have a working InnoDB! ******" >&2
43+ cat /tmp/$port/data/mysqld.log >&2
44+ exit 1
45+ fi
46 fi
47 else
48 echo "Sandbox $type $port failed to start." >&2
49
50=== added file 't/pt-table-checksum/skip_innodb.t'
51--- t/pt-table-checksum/skip_innodb.t 1970-01-01 00:00:00 +0000
52+++ t/pt-table-checksum/skip_innodb.t 2012-05-04 16:20:29 +0000
53@@ -0,0 +1,72 @@
54+#!/usr/bin/env perl
55+
56+BEGIN {
57+ die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
58+ unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
59+ unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
60+};
61+
62+use strict;
63+use warnings FATAL => 'all';
64+use English qw(-no_match_vars);
65+use Test::More;
66+
67+use PerconaTest;
68+use Sandbox;
69+shift @INC; # our unshift (above)
70+shift @INC; # PerconaTest's unshift
71+require "$trunk/bin/pt-table-checksum";
72+
73+diag(`$trunk/sandbox/stop-sandbox 12348 >/dev/null`);
74+diag(`SKIP_INNODB=1 $trunk/sandbox/start-sandbox master 12348 >/dev/null`);
75+
76+diag(`$trunk/sandbox/stop-sandbox 12349 >/dev/null`);
77+diag(`SKIP_INNODB=1 $trunk/sandbox/start-sandbox slave 12349 12348 >/dev/null`);
78+
79+my $dp = new DSNParser(opts=>$dsn_opts);
80+my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
81+my $master_dbh = $sb->get_dbh_for('master1');
82+my $slave_dbh = $sb->get_dbh_for('master2');
83+
84+if ( !$master_dbh ) {
85+ plan skip_all => 'Cannot connect to sandbox master 12348';
86+}
87+elsif ( !$slave_dbh ) {
88+ plan skip_all => 'Cannot connect to sandbox slave 12349';
89+}
90+else {
91+ plan tests => 2;
92+}
93+
94+# The sandbox servers run with lock_wait_timeout=3 and it's not dynamic
95+# so we need to specify --lock-wait-timeout=3 else the tool will die.
96+# And --max-load "" prevents waiting for status variables.
97+my $master_dsn = 'h=127.1,P=12348,u=msandbox,p=msandbox';
98+my $slave_dnn = 'P=12349';
99+my @args = ($master_dsn, qw(--lock-wait-timeout 3), '--max-load', '');
100+my $output;
101+my $retval;
102+
103+$output = output(
104+ sub { $retval = pt_table_checksum::main(@args) },
105+ stderr => 1,
106+);
107+
108+like(
109+ $output,
110+ qr/mysql/,
111+ "Ran without InnoDB (bug 994010)"
112+);
113+
114+is(
115+ $retval,
116+ 0,
117+ "0 exit status (bug 994010)"
118+);
119+
120+# #############################################################################
121+# Done.
122+# #############################################################################
123+diag(`$trunk/sandbox/stop-sandbox 12349 >/dev/null`);
124+diag(`$trunk/sandbox/stop-sandbox 12348 >/dev/null`);
125+exit;

Subscribers

People subscribed via source and target branches