Use literal values instead of ? placeholders for CHANGE MASTER statement.

This commit is contained in:
Daniel Nichter
2012-12-11 17:23:06 -07:00
parent 37cbed29d9
commit 6c6ae95ea3
2 changed files with 15 additions and 13 deletions

View File

@@ -4693,9 +4693,6 @@ sub watch_server {
. $o->get('skip-count'));
my $start = $dbh->prepare($start_sql);
my $stop = $dbh->prepare('STOP SLAVE');
my $chmt = $dbh->prepare(
'CHANGE MASTER TO MASTER_LOG_FILE=?, MASTER_LOG_POS=?');
# ########################################################################
# Lookup tables of things to do when a problem is detected.
@@ -4717,8 +4714,14 @@ sub watch_server {
PTDEBUG && _d('Found relay log corruption');
# Can't do CHANGE MASTER TO with a running slave.
$stop->execute();
$chmt->execute(
@{$stat}{qw(relay_master_log_file exec_master_log_pos)});
# Cannot use ? placeholders for CHANGE MASTER values:
# https://bugs.launchpad.net/percona-toolkit/+bug/932614
my $sql = "CHANGE MASTER TO "
. "MASTER_LOG_FILE='$stat->{relay_master_log_file}', "
. "MASTER_LOG_POS=$stat->{exec_master_log_pos}";
PTDEBUG && _d($sql);
$dbh->do($sql);
},
skip => sub {
my ( $stat, $dbh ) = @_;

View File

@@ -26,23 +26,22 @@ if ( !$master_dbh ) {
elsif ( !$slave_dbh ) {
plan skip_all => 'Cannot connect to sandbox slave';
}
else {
plan tests => 15;
}
$sb->create_dbs($master_dbh, ['test']);
$master_dbh->do('DROP DATABASE IF EXISTS test');
$master_dbh->do('CREATE DATABASE test');
$master_dbh->do('CREATE TABLE test.t (a INT)');
my $i = 0;
PerconaTest::wait_for_table($slave_dbh, 'test.t');
$sb->wait_for_slaves;
# Bust replication
$slave_dbh->do('DROP TABLE test.t');
$master_dbh->do('INSERT INTO test.t SELECT 1');
wait_until(
sub {
! $slave_dbh->selectrow_hashref('show slave status')->{slave_sql_running};
my $row = $slave_dbh->selectrow_hashref('show slave status');
return $row->{last_sql_errno};
}
);
my $r = $slave_dbh->selectrow_hashref('show slave status');
like($r->{last_error}, qr/Table 'test.t' doesn't exist'/, 'It is busted');
@@ -140,4 +139,4 @@ diag(`rm -f /tmp/pt-slave-re*`);
$sb->wipe_clean($master_dbh);
$sb->wipe_clean($slave_dbh);
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
exit;
done_testing;