Debian Codegraph @

mysql-test/suite/rpl_nogtid/t/rpl_replicate_same_server_id.test

raw
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-replica-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/master-slave.inc
19
20 --echo ==== If server with replicate-same-server-id is slave of itself, it executes transactions twice ====
21
22 --echo ---- Initialize ----
23
24 --source include/rpl_connection_slave.inc
25 CREATE TABLE t1 (n INT);
26 RESET MASTER;
27
28 # replicate slave -> slave
29 --source include/stop_slave.inc
30 --replace_result $SLAVE_MYPORT SLAVE_PORT
31 eval CHANGE REPLICATION SOURCE TO SOURCE_PORT = $SLAVE_MYPORT;
32 --source include/start_slave.inc
33
34 --echo ---- Test ----
35
36 INSERT INTO t1 VALUES (1);
37 --save_master_pos
38 --sync_with_master
39
40 SELECT * FROM t1; # check that indeed 2 were inserted
41
42 --echo ---- Clean up ----
43
44 # We stop the slave before cleaning up otherwise we'll get
45 # 'DROP TABLE t1' executed twice, so an error in the slave.err
46 # (not critical).
47 --source include/stop_slave.inc
48
49 DROP TABLE t1;
50
51 --replace_result $MASTER_MYPORT MASTER_PORT
52 eval CHANGE REPLICATION SOURCE TO SOURCE_PORT = $MASTER_MYPORT;
53
54
55 #
56 # Bug#38934 slave slave until does not work with --replicate-same-server-id
57 #
58 # Verifying that slave performs all events until the master_log_pos
59 # in presense of --replicate-same-server-id the slave is started with.
60
61 --echo ==== START SLAVE UNTIL works with replicate-same-server-id ====
62
63 --echo ---- Initialize ----
64
65 --source include/rpl_connection_master.inc
66
67 # setting the until position to correspond to the first following create table
68 # which will make the event executed and the slave sql thread stopped
69 # right after that.
70
71 CREATE TABLE t1(n int);
72 --let $until_pos= query_get_value(SHOW MASTER STATUS, Position, 1)
73
74 CREATE TABLE t2(n int);
75
76 --echo ---- Test ----
77
78 --source include/rpl_connection_slave.inc
79
80 --replace_result $until_pos UNTIL_POS
81 --disable_warnings
82 eval START SLAVE UNTIL SOURCE_LOG_FILE = 'master-bin.000001', SOURCE_LOG_POS = $until_pos;
83 --enable_warnings
84 --source include/wait_for_slave_io_to_start.inc
85
86 # It is theoretically possible that the SQL thread starts after the IO
87 # thread, so wait_for_io_to_start returns after the IO thread has
88 # started and before the SQL thread has started. So we have to wait
89 # for the actual change to appear on the slave, so that we know that
90 # the SQL thread has started before we wait for it to stop.
91
92 --let $query= SELECT * FROM t1
93 --source include/wait_for_query_to_succeed.inc
94
95 --source include/wait_for_slave_sql_to_stop.inc
96
97 --let $assert_cond= "[SHOW TABLES]" = "t1"
98 --let $assert_text= t1 should be replicated, t2 should not
99 --source include/assert.inc
100
101 --echo ---- Clean up ----
102
103 --source include/rpl_connection_slave.inc
104 --source include/start_slave_sql.inc
105
106 --source include/rpl_connection_master.inc
107 DROP TABLE t1;
108 DROP TABLE t2;
109
110 --source include/rpl_end.inc