mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
A new option --replicate-same-server-id to force a slave to execute queries originating from itself
(WL#794). This can be of interest in some recovery-from-backup scenarios, and also when you have two databases in one mysqld, having a certain similarity and you want one db to be updated when the other is (some sort of trigger). Plus small fix for BUG#3568 "MySQL server crashes when built --with-debug and CHANGE MASTER +MASTER_POS_WAIT"
This commit is contained in:
23
mysql-test/r/rpl_server_id1.result
Normal file
23
mysql-test/r/rpl_server_id1.result
Normal file
@ -0,0 +1,23 @@
|
||||
slave stop;
|
||||
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
|
||||
reset master;
|
||||
reset slave;
|
||||
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
|
||||
slave start;
|
||||
drop table if exists t1;
|
||||
create table t1 (n int);
|
||||
reset master;
|
||||
stop slave;
|
||||
change master to master_port=9307;
|
||||
show slave status;
|
||||
Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
|
||||
127.0.0.1 root SLAVE_PORT 1 4 slave-relay-bin.001 4 No No 0 0 0 #
|
||||
start slave;
|
||||
insert into t1 values (1);
|
||||
show status like "slave_running";
|
||||
Variable_name Value
|
||||
Slave_running ON
|
||||
select * from t1;
|
||||
n
|
||||
1
|
||||
drop table t1;
|
21
mysql-test/r/rpl_server_id2.result
Normal file
21
mysql-test/r/rpl_server_id2.result
Normal file
@ -0,0 +1,21 @@
|
||||
slave stop;
|
||||
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
|
||||
reset master;
|
||||
reset slave;
|
||||
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
|
||||
slave start;
|
||||
drop table if exists t1;
|
||||
create table t1 (n int);
|
||||
reset master;
|
||||
stop slave;
|
||||
change master to master_port=9307;
|
||||
show slave status;
|
||||
Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
|
||||
127.0.0.1 root SLAVE_PORT 1 4 slave-relay-bin.001 4 No No 0 0 0 #
|
||||
start slave;
|
||||
insert into t1 values (1);
|
||||
select * from t1;
|
||||
n
|
||||
1
|
||||
1
|
||||
drop table t1;
|
22
mysql-test/t/rpl_server_id1.test
Normal file
22
mysql-test/t/rpl_server_id1.test
Normal file
@ -0,0 +1,22 @@
|
||||
# This test checks that a slave does not execute queries originating
|
||||
# from itself, by default.
|
||||
|
||||
source include/master-slave.inc;
|
||||
connection slave;
|
||||
drop table if exists t1;
|
||||
create table t1 (n int);
|
||||
reset master;
|
||||
# replicate ourselves
|
||||
stop slave;
|
||||
eval change master to master_port=$SLAVE_MYPORT;
|
||||
--replace_result $SLAVE_MYPORT SLAVE_PORT
|
||||
--replace_column 18 #
|
||||
show slave status;
|
||||
start slave;
|
||||
insert into t1 values (1);
|
||||
# can't MASTER_POS_WAIT(), it does not work in this weird setup
|
||||
# (when slave is its own master without --replicate-same-server-id)
|
||||
sleep 2; # enough time for the event to be replicated (it should not)
|
||||
show status like "slave_running";
|
||||
select * from t1;
|
||||
drop table t1;
|
1
mysql-test/t/rpl_server_id2-slave.opt
Normal file
1
mysql-test/t/rpl_server_id2-slave.opt
Normal file
@ -0,0 +1 @@
|
||||
--disable-log-slave-updates --replicate-same-server-id
|
20
mysql-test/t/rpl_server_id2.test
Normal file
20
mysql-test/t/rpl_server_id2.test
Normal file
@ -0,0 +1,20 @@
|
||||
# This test checks that a slave DOES execute queries originating
|
||||
# from itself, if running with --replicate-same-server-id.
|
||||
|
||||
source include/master-slave.inc;
|
||||
connection slave;
|
||||
drop table if exists t1;
|
||||
create table t1 (n int);
|
||||
reset master;
|
||||
# replicate ourselves
|
||||
stop slave;
|
||||
eval change master to master_port=$SLAVE_MYPORT;
|
||||
--replace_result $SLAVE_MYPORT SLAVE_PORT
|
||||
--replace_column 18 #
|
||||
show slave status;
|
||||
start slave;
|
||||
insert into t1 values (1);
|
||||
save_master_pos;
|
||||
sync_with_master;
|
||||
select * from t1; # check that indeed 2 were inserted
|
||||
drop table t1;
|
Reference in New Issue
Block a user