Do not 'REPLACE INTO percona_test.sentinel' in start-sandbox because it doesn't work with RBR. Fix pt-table-checksum/pxc.t re this, and make pt-osc/pxc.t better re this.

This commit is contained in:
vagrant
2013-03-07 13:17:01 -08:00
parent 8300c46c52
commit 664449b153
4 changed files with 43 additions and 22 deletions

View File

@@ -143,7 +143,6 @@ make_sandbox() {
/tmp/$port/use -e "CREATE DATABASE IF NOT EXISTS percona_test";
/tmp/$port/use -e "CREATE TABLE IF NOT EXISTS percona_test.sentinel (id INT PRIMARY KEY, ping VARCHAR(64) NOT NULL DEFAULT '')";
/tmp/$port/use -e "REPLACE INTO percona_test.sentinel (id, ping) VALUES (1, '')";
if [ -n "${MYSQL_UPGRADE:-""}" ]; then
mysql_upgrade_on /tmp/$port/my.sandbox.cnf

View File

@@ -334,10 +334,10 @@ case $opt in
../util/check-load-data
ping=$(/tmp/12345/use -ss -e "SELECT MD5(RAND())")
/tmp/12345/use -e "UPDATE percona_test.sentinel SET ping='$ping' WHERE id=1";
/tmp/12345/use -e "REPLACE INTO percona_test.sentinel (id, ping) VALUES (1, '$ping')";
echo -n "Waiting for replication to finish..."
for i in $(_seq 60); do
pong=$(/tmp/12347/use -ss -e 'SELECT ping FROM percona_test.sentinel WHERE id=1' 2>/dev/null)
pong=$(/tmp/12347/use -ss -e "SELECT ping FROM percona_test.sentinel WHERE id=1 AND ping='$ping'" 2>/dev/null)
[ "$ping" = "$pong" ] && break
echo -n '.'
sleep 1

View File

@@ -137,21 +137,25 @@ is_deeply(
# master -> cluster, run on master on table with foreign keys.
# #############################################################################
# CAREFUL: The master and the cluster are different, so don't do stuff
# on the master that will conflict with stuff already done on the cluster.
# And since we're using RBR, we have to do a lot of stuff on the master
# again, manually, because REPLACE and INSERT IGNORE don't work in RBR
# like they do SBR.
my ($master_dbh, $master_dsn) = $sb->start_sandbox(
server => 'cmaster',
type => 'master',
env => q/BINLOG_FORMAT="ROW"/,
);
# CAREFUL: The master and the cluster are different, so we must load dbs on
# the master then flush the logs, else node1 will apply the master's binlogs
# and blow up because it already had these dbs.
$master_dbh->do("FLUSH LOGS");
$master_dbh->do("RESET MASTER");
$sb->set_as_slave('node1', 'cmaster');
$sb->load_file('cmaster', "$sample/basic_with_fks.sql");
$sb->load_file('cmaster', "$sample/basic_with_fks.sql", undef, no_wait => 1);
$master_dbh->do("SET SESSION binlog_format=STATEMENT");
$master_dbh->do("REPLACE INTO percona_test.sentinel (id, ping) VALUES (1, '')");
$sb->wait_for_slaves(master => 'cmaster', slave => 'node1');
($output, $exit) = full_output(
sub { pt_online_schema_change::main(

View File

@@ -214,7 +214,7 @@ $output = output(
like(
$output,
qr/replica h=127.1,P=12348 has binlog_format ROW/,
qr/replica h=127.1,P=12348 has binlog_format ROW/i,
"--check-binlog-format warns about slave's binlog format"
);
@@ -291,28 +291,46 @@ $node1->do(qq/DELETE FROM dsns.dsns WHERE id=4/);
# master -> node1 in cluster, run on master
# #############################################################################
# CAREFUL: The master and the cluster are different, so don't do stuff
# on the master that will conflict with stuff already done on the cluster.
# And since we're using RBR, we have to do a lot of stuff on the master
# again, manually, because REPLACE and INSERT IGNORE don't work in RBR
# like they do SBR.
my ($master_dbh, $master_dsn) = $sb->start_sandbox(
server => 'cmaster',
type => 'master',
env => q/BINLOG_FORMAT="ROW"/,
);
# CAREFUL: The master and the cluster are different, so we must load dbs on
# the master then flush the logs, else node1 will apply the master's binlogs
# and blow up because it already had these dbs.
# Remember: this DSN table only has node2 and node3 (12346 and 12347) which is
# sufficient for this test.
$sb->load_file('cmaster', "$sample/dsn-table.sql");
# Since master is new, node1 shouldn't have binlog to replay.
$sb->set_as_slave('node1', 'cmaster');
# We have to load a-z-cluster.sql else the pk id won'ts match because nodes use
# auto-inc offsets but the master doesn't.
$sb->load_file('cmaster', "$sample/a-z-cluster.sql");
$sb->load_file('cmaster', "$sample/a-z-cluster.sql", undef, no_wait => 1);
$master_dbh->do("FLUSH LOGS");
$master_dbh->do("RESET MASTER");
# Do this stuff manually and only on the master because node1/the cluster
# already has it, and due to RBR, we can't do it other ways.
$master_dbh->do("SET sql_log_bin=0");
$sb->set_as_slave('node1', 'cmaster');
# This DSN table does not include 12345 (node1/slave) intentionally,
# so a later test can auto-find 12345 then warn "Diffs will only be
# detected if the cluster is consistent with h=127.1,P=12345...".
$master_dbh->do("CREATE DATABASE dsns");
$master_dbh->do("CREATE TABLE dsns.dsns (
id int auto_increment primary key,
parent_id int default null,
dsn varchar(255) not null
)");
$master_dbh->do("INSERT INTO dsns.dsns VALUES
(2, 1, 'h=127.1,P=12346,u=msandbox,p=msandbox'),
(3, 2, 'h=127.1,P=12347,u=msandbox,p=msandbox')");
$master_dbh->do("INSERT INTO percona_test.sentinel (id, ping) VALUES (1, '')");
$master_dbh->do("SET sql_log_bin=1");
$sb->wait_for_slaves(master => 'cmaster', slave => 'node1');
# Notice: no --recursion-method=dsn yet. Since node1 is a traditional slave
# of the master, ptc should auto-detect it, which we'll test later by making