File: rpl_replicate_same_server_id.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (110 lines) | stat: -rw-r--r-- 3,250 bytes parent folder | download
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# ==== Purpose ====
#
# Test that replicate-same-server-id works correctly in two cases:
#
#  1. If a server replicates to itself (and log-replica-updates is off)
#     then every transaction should be executed twice.
#
#  2. START SLAVE UNTIL should work correctly if replicate-same-server-id
#     is enabled and master and slave have different server_ids. This is
#     to test BUG#38934.
#
# ==== Note ====
#
# This test file was named rpl_server_id2.test prior to MySQL 5.7.5.

# Replicating in a loop like this won't work with GTIDs.
--source include/not_group_replication_plugin.inc
--source include/master-slave.inc

--echo ==== If server with replicate-same-server-id is slave of itself, it executes transactions twice ====

--echo ---- Initialize ----

--source include/rpl_connection_slave.inc
CREATE TABLE t1 (n INT);
RESET MASTER;

# replicate slave -> slave
--source include/stop_slave.inc
--replace_result $SLAVE_MYPORT SLAVE_PORT
eval CHANGE REPLICATION SOURCE TO SOURCE_PORT = $SLAVE_MYPORT;
--source include/start_slave.inc

--echo ---- Test ----

INSERT INTO t1 VALUES (1);
--save_master_pos
--sync_with_master

SELECT * FROM t1; # check that indeed 2 were inserted

--echo ---- Clean up ----

# We stop the slave before cleaning up otherwise we'll get
# 'DROP TABLE t1' executed twice, so an error in the slave.err
# (not critical).
--source include/stop_slave.inc

DROP TABLE t1;

--replace_result $MASTER_MYPORT MASTER_PORT
eval CHANGE REPLICATION SOURCE TO SOURCE_PORT = $MASTER_MYPORT;


#
# Bug#38934 slave slave until does not work with --replicate-same-server-id
#
# Verifying that slave performs all events until the master_log_pos
# in presense of --replicate-same-server-id the slave is started with.

--echo ==== START SLAVE UNTIL works with replicate-same-server-id ====

--echo ---- Initialize ----

--source include/rpl_connection_master.inc

# setting the until position to correspond to the first following create table
# which will make the event executed and the slave sql thread stopped
# right after that.

CREATE TABLE t1(n int);
--let $until_pos= query_get_value(SHOW MASTER STATUS, Position, 1)

CREATE TABLE t2(n int);

--echo ---- Test ----

--source include/rpl_connection_slave.inc

--replace_result $until_pos UNTIL_POS
--disable_warnings
eval START SLAVE UNTIL SOURCE_LOG_FILE = 'master-bin.000001', SOURCE_LOG_POS = $until_pos;
--enable_warnings
--source include/wait_for_slave_io_to_start.inc

# It is theoretically possible that the SQL thread starts after the IO
# thread, so wait_for_io_to_start returns after the IO thread has
# started and before the SQL thread has started.  So we have to wait
# for the actual change to appear on the slave, so that we know that
# the SQL thread has started before we wait for it to stop.

--let $query= SELECT * FROM t1
--source include/wait_for_query_to_succeed.inc

--source include/wait_for_slave_sql_to_stop.inc

--let $assert_cond= "[SHOW TABLES]" = "t1"
--let $assert_text= t1 should be replicated, t2 should not
--source include/assert.inc

--echo ---- Clean up ----

--source include/rpl_connection_slave.inc
--source include/start_slave_sql.inc

--source include/rpl_connection_master.inc
DROP TABLE t1;
DROP TABLE t2;

--source include/rpl_end.inc