summaryrefslogtreecommitdiff
path: root/mysql-test/suite/rpl/t/rpl_gtid_basic.test
blob: 070e0daa403a90aafd306473bd010e30ad7409ee (plain)
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
--source include/have_innodb.inc
--let $rpl_topology=1->2->3->4
--source include/rpl_init.inc

# Set up a 4-deep replication topology, then test various fail-overs
# using GTID.
#
#  A -> B -> C -> D

connection server_1;
CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(10)) ENGINE=MyISAM;
CREATE TABLE t2 (a INT PRIMARY KEY, b VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1, "m1");
INSERT INTO t1 VALUES (2, "m2"), (3, "m3"), (4, "m4");
INSERT INTO t2 VALUES (1, "i1");
BEGIN;
INSERT INTO t2 VALUES (2, "i2"), (3, "i3");
INSERT INTO t2 VALUES (4, "i4");
COMMIT;
save_master_pos;

connection server_2;
sync_with_master;
SELECT * FROM t1 ORDER BY a;
SELECT * FROM t2 ORDER BY a;
save_master_pos;

connection server_3;
sync_with_master;
SELECT * FROM t1 ORDER BY a;
SELECT * FROM t2 ORDER BY a;
save_master_pos;

connection server_4;
sync_with_master;
SELECT * FROM t1 ORDER BY a;
SELECT * FROM t2 ORDER BY a;


--echo *** Now take out D, let it fall behind a bit, and then test re-attaching it to A ***
connection server_4;
--source include/stop_slave.inc

connection server_1;
INSERT INTO t1 VALUES (5, "m1a");
INSERT INTO t2 VALUES (5, "i1a");
save_master_pos;

connection server_4;
--replace_result $MASTER_MYPORT MASTER_PORT
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $MASTER_MYPORT,
     MASTER_USE_GTID=CURRENT_POS;
--source include/start_slave.inc
sync_with_master;
SELECT * FROM t1 ORDER BY a;
SELECT * FROM t2 ORDER BY a;

--echo *** Now move B to D (C is still replicating from B) ***
connection server_2;
--source include/stop_slave.inc
--replace_result $SERVER_MYPORT_4 SERVER_MYPORT_4
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $SERVER_MYPORT_4,
     MASTER_USE_GTID=CURRENT_POS;
--source include/start_slave.inc

connection server_4;
UPDATE t2 SET b="j1a" WHERE a=5;
save_master_pos;

connection server_2;
sync_with_master;
SELECT * FROM t1 ORDER BY a;
SELECT * FROM t2 ORDER BY a;

--echo *** Now move C to D, after letting it fall a little behind ***
connection server_3;
--source include/stop_slave.inc

connection server_1;
BEGIN;
INSERT INTO t2 VALUES (6, "i6b");
INSERT INTO t2 VALUES (7, "i7b");
COMMIT;

connection server_3;
--replace_result $SERVER_MYPORT_4 SERVER_MYPORT_4
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $SERVER_MYPORT_4,
     MASTER_USE_GTID=CURRENT_POS;
--source include/start_slave.inc
# This time, let's sync up without reference to binlog on D.
--let $wait_condition= SELECT COUNT(*) = 7 FROM t2
--source include/wait_condition.inc
SELECT * FROM t2 ORDER BY a;

--echo *** Now change everything back to what it was, to make rpl_end.inc happy
# Also check that MASTER_USE_GTID=CURRENT_POS is still enabled.
connection server_2;
# We need to sync up server_2 before switching. If it happened to have reached
# the point 'UPDATE t2 SET b="j1a" WHERE a=5' it will fail to connect to
# server_1, which is (deliberately) missing that transaction.
--let $wait_condition= SELECT COUNT(*) = 7 FROM t2
--source include/wait_condition.inc
--source include/stop_slave.inc
--replace_result $MASTER_MYPORT MASTER_MYPORT
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $MASTER_MYPORT;
--source include/start_slave.inc
--source include/wait_for_slave_to_start.inc

connection server_3;
--source include/stop_slave.inc
--replace_result $SLAVE_MYPORT SLAVE_MYPORT
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $SLAVE_MYPORT;
--source include/start_slave.inc
--let $wait_condition= SELECT COUNT(*) = 7 FROM t2
--source include/wait_condition.inc

connection server_4;
--source include/stop_slave.inc
--replace_result $SERVER_MYPORT_3 SERVER_MYPORT_3
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $SERVER_MYPORT_3;
--source include/start_slave.inc

connection server_1;
DROP TABLE t1,t2;

--source include/rpl_end.inc