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
=== modified file 'bin/pt-slave-restart'
--- bin/pt-slave-restart 2012-12-03 03:48:11 +0000
+++ bin/pt-slave-restart 2012-12-12 00:41:26 +0000
@@ -4693,9 +4693,6 @@
4693 . $o->get('skip-count'));4693 . $o->get('skip-count'));
4694 my $start = $dbh->prepare($start_sql);4694 my $start = $dbh->prepare($start_sql);
4695 my $stop = $dbh->prepare('STOP SLAVE');4695 my $stop = $dbh->prepare('STOP SLAVE');
4696 my $chmt = $dbh->prepare(
4697 'CHANGE MASTER TO MASTER_LOG_FILE=?, MASTER_LOG_POS=?');
4698
46994696
4700 # ########################################################################4697 # ########################################################################
4701 # Lookup tables of things to do when a problem is detected.4698 # Lookup tables of things to do when a problem is detected.
@@ -4717,8 +4714,14 @@
4717 PTDEBUG && _d('Found relay log corruption');4714 PTDEBUG && _d('Found relay log corruption');
4718 # Can't do CHANGE MASTER TO with a running slave.4715 # Can't do CHANGE MASTER TO with a running slave.
4719 $stop->execute();4716 $stop->execute();
4720 $chmt->execute(4717
4721 @{$stat}{qw(relay_master_log_file exec_master_log_pos)});4718 # Cannot use ? placeholders for CHANGE MASTER values:
4719 # https://bugs.launchpad.net/percona-toolkit/+bug/932614
4720 my $sql = "CHANGE MASTER TO "
4721 . "MASTER_LOG_FILE='$stat->{relay_master_log_file}', "
4722 . "MASTER_LOG_POS=$stat->{exec_master_log_pos}";
4723 PTDEBUG && _d($sql);
4724 $dbh->do($sql);
4722 },4725 },
4723 skip => sub {4726 skip => sub {
4724 my ( $stat, $dbh ) = @_;4727 my ( $stat, $dbh ) = @_;
@@ -4940,7 +4943,7 @@
49404943
4941=head1 SYNOPSIS4944=head1 SYNOPSIS
49424945
4943Usage: pt-slave-restart [OPTION...] [DSN]4946Usage: pt-slave-restart [OPTIONS] [DSN]
49444947
4945pt-slave-restart watches one or more MySQL replication slaves for4948pt-slave-restart watches one or more MySQL replication slaves for
4946errors, and tries to restart replication if it stops.4949errors, and tries to restart replication if it stops.
@@ -4957,9 +4960,6 @@
4957need to. If you use this tool carelessly, you might miss the chance to really4960need to. If you use this tool carelessly, you might miss the chance to really
4958solve the slave server's problems.4961solve the slave server's problems.
49594962
4960At the time of this release there is a bug that causes an invalid
4961C<CHANGE MASTER TO> statement to be executed.
4962
4963The authoritative source for updated information is always the online issue4963The authoritative source for updated information is always the online issue
4964tracking system. Issues that affect this tool will be marked as such. You can4964tracking system. Issues that affect this tool will be marked as such. You can
4965see a list of such issues at the following URL:4965see a list of such issues at the following URL:
@@ -4974,12 +4974,9 @@
4974exponentially varying sleep time. You can specify errors to skip and run the4974exponentially varying sleep time. You can specify errors to skip and run the
4975slaves until a certain binlog position.4975slaves until a certain binlog position.
49764976
4977Note: it has come to my attention that Yahoo! had or has an internal tool4977Although this tool can help a slave advance past errors, you should not
4978called fix_repl, described to me by a past Yahoo! employee and mentioned in4978rely on it to "fix" replication. If slave errors occur frequently or
4979the first edition of High Performance MySQL. Apparently this tool does the4979unexpectedly, you should identify and fix the root cause.
4980same thing. Make no mistake, though: this is not a way to "fix replication."
4981In fact I would not even encourage its use on a regular basis; I use it only
4982when I have an error I know I just need to skip past.
49834980
4984=head1 OUTPUT4981=head1 OUTPUT
49854982
49864983
=== modified file 't/pt-slave-restart/pt-slave-restart.t'
--- t/pt-slave-restart/pt-slave-restart.t 2012-06-07 01:29:30 +0000
+++ t/pt-slave-restart/pt-slave-restart.t 2012-12-12 00:41:26 +0000
@@ -26,23 +26,22 @@
26elsif ( !$slave_dbh ) {26elsif ( !$slave_dbh ) {
27 plan skip_all => 'Cannot connect to sandbox slave';27 plan skip_all => 'Cannot connect to sandbox slave';
28}28}
29else {
30 plan tests => 15;
31}
3229
33$sb->create_dbs($master_dbh, ['test']);30$master_dbh->do('DROP DATABASE IF EXISTS test');
31$master_dbh->do('CREATE DATABASE test');
34$master_dbh->do('CREATE TABLE test.t (a INT)');32$master_dbh->do('CREATE TABLE test.t (a INT)');
35my $i = 0;33$sb->wait_for_slaves;
36PerconaTest::wait_for_table($slave_dbh, 'test.t');
3734
38# Bust replication35# Bust replication
39$slave_dbh->do('DROP TABLE test.t');36$slave_dbh->do('DROP TABLE test.t');
40$master_dbh->do('INSERT INTO test.t SELECT 1');37$master_dbh->do('INSERT INTO test.t SELECT 1');
41wait_until(38wait_until(
42 sub {39 sub {
43 ! $slave_dbh->selectrow_hashref('show slave status')->{slave_sql_running};40 my $row = $slave_dbh->selectrow_hashref('show slave status');
41 return $row->{last_sql_errno};
44 }42 }
45);43);
44
46my $r = $slave_dbh->selectrow_hashref('show slave status');45my $r = $slave_dbh->selectrow_hashref('show slave status');
47like($r->{last_error}, qr/Table 'test.t' doesn't exist'/, 'It is busted');46like($r->{last_error}, qr/Table 'test.t' doesn't exist'/, 'It is busted');
4847
@@ -140,4 +139,4 @@
140$sb->wipe_clean($master_dbh);139$sb->wipe_clean($master_dbh);
141$sb->wipe_clean($slave_dbh);140$sb->wipe_clean($slave_dbh);
142ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");141ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
143exit;142done_testing;

Subscribers

People subscribed via source and target branches