Merge lp:~percona-toolkit-dev/percona-toolkit/fix-change-master-bug-932614 into lp:percona-toolkit/2.1

Proposed by Daniel Nichter
Status: Merged
Merged at revision: 503
Proposed branch: lp:~percona-toolkit-dev/percona-toolkit/fix-change-master-bug-932614
Merge into: lp:percona-toolkit/2.1
Diff against target: 105 lines (+19/-23)
2 files modified
bin/pt-slave-restart (+12/-15)
t/pt-slave-restart/pt-slave-restart.t (+7/-8)
To merge this branch: bzr merge lp:~percona-toolkit-dev/percona-toolkit/fix-change-master-bug-932614
Reviewer Review Type Date Requested Status
Daniel Nichter Approve
Review via email: mp+139355@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-slave-restart'
2--- bin/pt-slave-restart 2012-12-03 03:48:11 +0000
3+++ bin/pt-slave-restart 2012-12-12 00:41:26 +0000
4@@ -4693,9 +4693,6 @@
5 . $o->get('skip-count'));
6 my $start = $dbh->prepare($start_sql);
7 my $stop = $dbh->prepare('STOP SLAVE');
8- my $chmt = $dbh->prepare(
9- 'CHANGE MASTER TO MASTER_LOG_FILE=?, MASTER_LOG_POS=?');
10-
11
12 # ########################################################################
13 # Lookup tables of things to do when a problem is detected.
14@@ -4717,8 +4714,14 @@
15 PTDEBUG && _d('Found relay log corruption');
16 # Can't do CHANGE MASTER TO with a running slave.
17 $stop->execute();
18- $chmt->execute(
19- @{$stat}{qw(relay_master_log_file exec_master_log_pos)});
20+
21+ # Cannot use ? placeholders for CHANGE MASTER values:
22+ # https://bugs.launchpad.net/percona-toolkit/+bug/932614
23+ my $sql = "CHANGE MASTER TO "
24+ . "MASTER_LOG_FILE='$stat->{relay_master_log_file}', "
25+ . "MASTER_LOG_POS=$stat->{exec_master_log_pos}";
26+ PTDEBUG && _d($sql);
27+ $dbh->do($sql);
28 },
29 skip => sub {
30 my ( $stat, $dbh ) = @_;
31@@ -4940,7 +4943,7 @@
32
33 =head1 SYNOPSIS
34
35-Usage: pt-slave-restart [OPTION...] [DSN]
36+Usage: pt-slave-restart [OPTIONS] [DSN]
37
38 pt-slave-restart watches one or more MySQL replication slaves for
39 errors, and tries to restart replication if it stops.
40@@ -4957,9 +4960,6 @@
41 need to. If you use this tool carelessly, you might miss the chance to really
42 solve the slave server's problems.
43
44-At the time of this release there is a bug that causes an invalid
45-C<CHANGE MASTER TO> statement to be executed.
46-
47 The authoritative source for updated information is always the online issue
48 tracking system. Issues that affect this tool will be marked as such. You can
49 see a list of such issues at the following URL:
50@@ -4974,12 +4974,9 @@
51 exponentially varying sleep time. You can specify errors to skip and run the
52 slaves until a certain binlog position.
53
54-Note: it has come to my attention that Yahoo! had or has an internal tool
55-called fix_repl, described to me by a past Yahoo! employee and mentioned in
56-the first edition of High Performance MySQL. Apparently this tool does the
57-same thing. Make no mistake, though: this is not a way to "fix replication."
58-In fact I would not even encourage its use on a regular basis; I use it only
59-when I have an error I know I just need to skip past.
60+Although this tool can help a slave advance past errors, you should not
61+rely on it to "fix" replication. If slave errors occur frequently or
62+unexpectedly, you should identify and fix the root cause.
63
64 =head1 OUTPUT
65
66
67=== modified file 't/pt-slave-restart/pt-slave-restart.t'
68--- t/pt-slave-restart/pt-slave-restart.t 2012-06-07 01:29:30 +0000
69+++ t/pt-slave-restart/pt-slave-restart.t 2012-12-12 00:41:26 +0000
70@@ -26,23 +26,22 @@
71 elsif ( !$slave_dbh ) {
72 plan skip_all => 'Cannot connect to sandbox slave';
73 }
74-else {
75- plan tests => 15;
76-}
77
78-$sb->create_dbs($master_dbh, ['test']);
79+$master_dbh->do('DROP DATABASE IF EXISTS test');
80+$master_dbh->do('CREATE DATABASE test');
81 $master_dbh->do('CREATE TABLE test.t (a INT)');
82-my $i = 0;
83-PerconaTest::wait_for_table($slave_dbh, 'test.t');
84+$sb->wait_for_slaves;
85
86 # Bust replication
87 $slave_dbh->do('DROP TABLE test.t');
88 $master_dbh->do('INSERT INTO test.t SELECT 1');
89 wait_until(
90 sub {
91- ! $slave_dbh->selectrow_hashref('show slave status')->{slave_sql_running};
92+ my $row = $slave_dbh->selectrow_hashref('show slave status');
93+ return $row->{last_sql_errno};
94 }
95 );
96+
97 my $r = $slave_dbh->selectrow_hashref('show slave status');
98 like($r->{last_error}, qr/Table 'test.t' doesn't exist'/, 'It is busted');
99
100@@ -140,4 +139,4 @@
101 $sb->wipe_clean($master_dbh);
102 $sb->wipe_clean($slave_dbh);
103 ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
104-exit;
105+done_testing;

Subscribers

People subscribed via source and target branches