1# ==== Purpose ==== 2# 3# Test that replicate-same-server-id works correctly in two cases: 4# 5# 1. If a server replicates to itself (and log-slave-updates is off) 6# then every transaction should be executed twice. 7# 8# 2. START SLAVE UNTIL should work correctly if replicate-same-server-id 9# is enabled and master and slave have different server_ids. This is 10# to test BUG#38934. 11# 12# ==== Note ==== 13# 14# This test file was named rpl_server_id2.test prior to MySQL 5.7.5. 15 16# Replicating in a loop like this won't work with GTIDs. 17--source include/not_group_replication_plugin.inc 18--source include/not_gtid_enabled.inc 19--source include/master-slave.inc 20 21--echo ==== If server with replicate-same-server-id is slave of itself, it executes transactions twice ==== 22 23--echo ---- Initialize ---- 24 25--source include/rpl_connection_slave.inc 26CREATE TABLE t1 (n INT); 27RESET MASTER; 28 29# replicate slave -> slave 30--source include/stop_slave.inc 31--replace_result $SLAVE_MYPORT SLAVE_PORT 32eval CHANGE MASTER TO MASTER_PORT = $SLAVE_MYPORT; 33--source include/start_slave.inc 34 35--echo ---- Test ---- 36 37INSERT INTO t1 VALUES (1); 38--save_master_pos 39--sync_with_master 40 41SELECT * FROM t1; # check that indeed 2 were inserted 42 43--echo ---- Clean up ---- 44 45# We stop the slave before cleaning up otherwise we'll get 46# 'DROP TABLE t1' executed twice, so an error in the slave.err 47# (not critical). 48--source include/stop_slave.inc 49 50DROP TABLE t1; 51 52--replace_result $MASTER_MYPORT MASTER_PORT 53eval CHANGE MASTER TO MASTER_PORT = $MASTER_MYPORT; 54 55 56# 57# Bug#38934 slave slave until does not work with --replicate-same-server-id 58# 59# Verifying that slave performs all events until the master_log_pos 60# in presense of --replicate-same-server-id the slave is started with. 61 62--echo ==== START SLAVE UNTIL works with replicate-same-server-id ==== 63 64--echo ---- Initialize ---- 65 66--source include/rpl_connection_master.inc 67 68# setting the until position to correspond to the first following create table 69# which will make the event executed and the slave sql thread stopped 70# right after that. 71 72CREATE TABLE t1(n int); 73--let $until_pos= query_get_value(SHOW MASTER STATUS, Position, 1) 74 75CREATE TABLE t2(n int); 76 77--echo ---- Test ---- 78 79--source include/rpl_connection_slave.inc 80 81--replace_result $until_pos UNTIL_POS 82--disable_warnings 83eval START SLAVE UNTIL MASTER_LOG_FILE = 'master-bin.000001', MASTER_LOG_POS = $until_pos; 84--enable_warnings 85--source include/wait_for_slave_io_to_start.inc 86 87# It is theoretically possible that the SQL thread starts after the IO 88# thread, so wait_for_io_to_start returns after the IO thread has 89# started and before the SQL thread has started. So we have to wait 90# for the actual change to appear on the slave, so that we know that 91# the SQL thread has started before we wait for it to stop. 92 93--let $query= SELECT * FROM t1 94--source include/wait_for_query_to_succeed.inc 95 96--source include/wait_for_slave_sql_to_stop.inc 97 98--let $assert_cond= "[SHOW TABLES]" = "t1" 99--let $assert_text= t1 should be replicated, t2 should not 100--source include/assert.inc 101 102--echo ---- Clean up ---- 103 104--source include/rpl_connection_slave.inc 105--source include/start_slave_sql.inc 106 107--source include/rpl_connection_master.inc 108DROP TABLE t1; 109DROP TABLE t2; 110 111--source include/rpl_end.inc 112