mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Fix for BUG#1686
"If 2 master threads with same-name temp table, slave makes bad binlog" and (two birds with one stone) for BUG#1240 "slave of slave breaks when STOP SLAVE was issud on parent slave and temp tables". Here is the design change: in a slave running with --log-slave-updates, events are now logged with the thread id they had on the master. So no more id conflicts between master threads, but introduces id conflicts between one master thread and one normal client thread connected to the slave. This is solved by storing the server id in the temp table's name. New test which requires mysql-test-run to be run with --manager, otherwise it will be skipped. Undoing a Monty's change (hum, a chill runs down my spine ;) which was "Cleanup temporary tables when slave ends" in ChangeSet 1.1572.1.1.
This commit is contained in:
89
mysql-test/t/rpl_chain_temp_table.test
Normal file
89
mysql-test/t/rpl_chain_temp_table.test
Normal file
@ -0,0 +1,89 @@
|
||||
# This test makes some assumptions about values of thread ids, which should be
|
||||
# true if the servers have been restarted for this test. So we want to
|
||||
# stop/restart servers. Note that if assumptions are wrong, the test will not
|
||||
# fail; it will just fail to test the error-prone scenario.
|
||||
# Using the manager is the only way to have more than one slave server.
|
||||
|
||||
require_manager;
|
||||
server_stop master;
|
||||
server_start master;
|
||||
server_stop slave;
|
||||
server_start slave;
|
||||
# no need for slave_sec (no assumptions on thread ids for this server).
|
||||
|
||||
source include/master-slave.inc;
|
||||
connect (slave_sec,localhost,root,,test,0,slave.sock-1);
|
||||
connection master;
|
||||
save_master_pos;
|
||||
connection slave;
|
||||
sync_with_master;
|
||||
reset master;
|
||||
save_master_pos;
|
||||
connection slave_sec;
|
||||
eval change master to master_host='127.0.0.1',master_port=$SLAVE_MYPORT, master_user='root';
|
||||
start slave;
|
||||
sync_with_master;
|
||||
|
||||
# :P now we have a chain ready-to-test.
|
||||
|
||||
connection master;
|
||||
create temporary table t1 (a int);
|
||||
save_master_pos;
|
||||
connection slave;
|
||||
sync_with_master;
|
||||
connection master1;
|
||||
create temporary table t1 (a int);
|
||||
save_master_pos;
|
||||
connection slave;
|
||||
sync_with_master;
|
||||
save_master_pos;
|
||||
|
||||
# First test:
|
||||
|
||||
connection slave_sec;
|
||||
# Before BUG#1686 ("If 2 master threads with same-name temp table, slave makes
|
||||
# bad binlog") was fixed, sync_with_master failed
|
||||
sync_with_master;
|
||||
show status like 'slave_open_temp_tables';
|
||||
|
||||
# 'master' and 'master1' usually have thread id 2-3 or 3-4.
|
||||
# 'slave' and 'slave1' usually have thread id 2-3.
|
||||
connection slave;
|
||||
create temporary table t1 (a int);
|
||||
connection slave1;
|
||||
create temporary table t1 (a int);
|
||||
# So it's likely that in the binlog of slave we get
|
||||
# server_id=of_master thread_id=3 create temp...
|
||||
# server_id=of_slave thread_id=3 create temp...
|
||||
# which would confuse slave-sec unless slave-sec uses server id to distinguish
|
||||
# between temp tables (here thread id is obviously not enough to distinguish).
|
||||
|
||||
save_master_pos;
|
||||
|
||||
# Second test:
|
||||
|
||||
connection slave_sec;
|
||||
# If we did not use the server id to distinguish between temp tables,
|
||||
# sync_with_master would fail
|
||||
sync_with_master;
|
||||
show status like 'slave_open_temp_tables';
|
||||
|
||||
# Third test (BUG#1240 "slave of slave breaks when STOP SLAVE was issud on
|
||||
# parent slave and temp tables").
|
||||
stop slave;
|
||||
connection slave;
|
||||
insert into t1 values(1);
|
||||
create table t2 as select * from t1;
|
||||
save_master_pos;
|
||||
connection slave_sec;
|
||||
start slave;
|
||||
sync_with_master;
|
||||
show status like 'slave_open_temp_tables';
|
||||
select * from t2;
|
||||
|
||||
# clean up
|
||||
connection slave;
|
||||
drop table t2;
|
||||
save_master_pos;
|
||||
connection slave_sec;
|
||||
sync_with_master;
|
Reference in New Issue
Block a user