We're updating the issue view to help you get more done. 

Multi-source: Slave allows multiple masters to have the same server id (might be bad for complicated replication setups)

Description

Currently multisource replication setup is possible even if masters have the same server_id: the slave doesn't complain either on configuration or on replication start. As a result, there might be problems with further replication, e.g. if we want to setup master1,master2 => slave => master2 configuration: updates from master1 won't be replicated on master2, because they will have the same server_id in the slave binary log.

The safer way would be not to allow to configure or start replication from several masters with the same server-id.

The test below shows it. It's not ready to be put into the test suite as is, because if the problem is fixed, the second slave startup won't happen, and the remaining part of the test will be redundant; that's why the test doesn't have a "cleanup" part. However, it can be used as a stub of the future test. Please note that the test requires its own cnf file (also provided here).

cat suite/multi_source/same_server_id.cnf

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 # cat t/multisource1.cnf !include include/default_mysqld.cnf !include include/default_client.cnf [mysqld.1] server-id=1 log-bin=master-bin [mysqld.2] server-id=1 log-bin=master-bin [mysqld.3] server-id=3 log-slave-updates log-bin=master-bin [ENV] SERVER_MYPORT_1= @mysqld.1.port SERVER_MYSOCK_1= @mysqld.1.socket SERVER_MYPORT_2= @mysqld.2.port SERVER_MYSOCK_2= @mysqld.2.socket SERVER_MYPORT_3= @mysqld.3.port SERVER_MYSOCK_3= @mysqld.3.socket

cat suite/multi_source/same_server_id.test

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 # In the cnf file for this test, mysqld.1 and mysqld.2 have # the same server-id=1, and mysqld.3 has server-id=3 --connect (slave,127.0.0.1,root,,,$SERVER_MYPORT_3) # Start replication from the first master --replace_result $SERVER_MYPORT_1 MYPORT_1 eval change master 'master1' to master_port=$SERVER_MYPORT_1, master_host='127.0.0.1', master_user='root'; start slave 'master1'; set default_master_connection = 'master1'; --source include/wait_for_slave_to_start.inc # Start replication from the second master --replace_result $SERVER_MYPORT_2 MYPORT_2 eval change master 'master2' to master_port=$SERVER_MYPORT_2, master_host='127.0.0.1', master_user='root'; start slave 'master2'; set default_master_connection = 'master2'; --source include/wait_for_slave_to_start.inc set default_master_connection = ''; --connect (master1,127.0.0.1,root,,,$SERVER_MYPORT_1) --disable_warnings drop table if exists t1; --enable_warnings create table t1 (i int) engine=MyISAM; --save_master_pos --connection slave --sync_with_master 0,'master1' --connect (master2,127.0.0.1,root,,,$SERVER_MYPORT_2) --disable_warnings drop table if exists t2; --enable_warnings create table t2 (j int) engine=MyISAM; --save_master_pos --connection slave --sync_with_master 0,'master2' --echo --echo # See that all entries are written with the same --echo # server_id = 1 show binlog events; --save_master_pos # Now set up replication from the slave to the second master # (the 'circular' part) --connection master2 --replace_result $SERVER_MYPORT_3 MYPORT_3 eval change master to master_port=$SERVER_MYPORT_3, master_host='127.0.0.1', master_user='root'; start slave; --sync_with_master 0 --echo --echo # See that t1 was not replicated --echo # (because the entry had the same server_id) show tables;

Environment

None

Status

Assignee

Michael Widenius

Reporter

Elena Stepanova

Labels

None

External issue ID

None

External issue ID

None

Priority

Minor