Commit 87a93a31 authored by unknown's avatar unknown
Browse files

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"


sql/mysqld.cc:
  new option --replicate-same-server-id
sql/slave.cc:
  new option replicate_same_server_id, to force a slave to execute its own queries.
  Small fix for BUG#3568 "MySQL server crashes when built --with-debug and CHANGE MASTER +MASTER_POS_WAIT"
sql/slave.h:
  new option --replicate-same-server-id
parent b825d9b0
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
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 −0
Original line number Diff line number Diff line
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 −0
Original line number Diff line number Diff line
# 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 −0
Original line number Diff line number Diff line
--disable-log-slave-updates --replicate-same-server-id
+20 −0
Original line number Diff line number Diff line
# 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;
Loading