Debian Codegraph @

mysql-test/suite/group_replication/t/gr_reset_master_before_provisioning.test

raw
1 ################################################################################
2 # This test intends to prove that members can survive reset master commands.
3 # These commands end up causing the members to purge their relay logs even when
4 # the member has some provisioned data.
5 # This test has 3 phases:
6 # 1) Insert some data and sync both members
7 # 2) Reset both members, insert some data on member one
8 # Provision member two and start replication
9 # Check that all data from phase 1 disappeared and the members are in sync.
10 # 3) Restart group replication on member 2, testing that no data remains
11 # from phase 1
12 #
13 # Test:
14 # 0. The test requires two servers: M1 and M2.
15 #
16 # Phase 1: Insert some data and sync both members.
17 # 1. Bootstrap start a group on M1 and insert some data. Start GR on M2.
18 # Validate both members have the same GTID set.
19 #
20 # Phase 2: Reset the group and provision a server.
21 # 2. Stop GR and reset master on both members.
22 # 3. On M1, add some data and bootstrap start group replication.
23 # 4. On M2, fake the member being provisioned. Start group replication.
24 # 5. Test that the group works by adding some data.
25 # 6. Validate both members have the same data.
26 #
27 # Phase 3: Restart group replication on M3.
28 # 7. Stop and start GR on M2.
29 # 8. Add some data on M2.
30 # 9. Validate both members have the same data.
31 #
32 # 10. Clean up.
33 ################################################################################
34
35 --source include/big_test.inc
36 --source include/have_group_replication_gtid_assignment_block_size_1.inc
37 --let $group_replication_group_name= c7ce5980-0851-11e4-9191-0800200c9a66
38 --source include/have_group_replication_plugin.inc
39 --let $rpl_skip_group_replication_start= 1
40 --source include/group_replication.inc
41
42 #
43 # Phase 1: Start the group and insert data
44 #
45
46 --connection server1
47 --source include/start_and_bootstrap_group_replication.inc
48
49 #Create a table and insert some data
50 --connection server1
51 CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
52
53 --connection server2
54 --source include/start_group_replication.inc
55
56 --connection server1
57 INSERT INTO t1 VALUES (1);
58 INSERT INTO t1 VALUES (2);
59 INSERT INTO t1 VALUES (3);
60 INSERT INTO t1 VALUES (4);
61
62 --let $sync_slave_connection= server2
63 --source include/sync_slave_sql_with_master.inc
64
65 #Both members must have the same GTID set
66 --let $server_count=2
67 while ($server_count)
68 {
69 --connection server$server_count
70 --let $assert_text= On member $server_count, all executed GTID should belong to the group
71 --let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "c7ce5980-0851-11e4-9191-0800200c9a66:1-7";
72 --source include/assert.inc
73 --dec $server_count
74 }
75
76 DROP TABLE t1;
77
78 --let $sync_slave_connection= server2
79 --source include/sync_slave_sql_with_master.inc
80
81 #
82 # Phase 2: Reset the group and provision a server
83 #
84
85 #Stop and reset both members
86
87 --connection server1
88 --source include/stop_group_replication.inc
89 RESET MASTER;
90
91 --connection server2
92 --source include/stop_group_replication.inc
93 RESET MASTER;
94
95 --connection server1
96
97 CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
98 INSERT INTO t1 VALUES (1);
99
100 --let $server_uuid= `SELECT @@GLOBAL.SERVER_UUID`
101
102 --source include/start_and_bootstrap_group_replication.inc
103
104 --connection server2
105
106 #Fake the member being provisioned.
107
108 --disable_result_log
109 --disable_query_log
110 eval SET @@SESSION.GTID_NEXT= '$server_uuid:1';
111 CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
112 eval SET @@SESSION.GTID_NEXT= '$server_uuid:2';
113 INSERT INTO t1 VALUES (1);
114 --enable_result_log
115 --enable_query_log
116
117 SET GTID_NEXT = 'AUTOMATIC';
118
119 #Start the member
120 --source include/start_group_replication.inc
121
122 #Test that the group works
123
124 --connection server1
125
126 INSERT INTO t1 VALUES (2);
127
128 --connection server2
129
130 INSERT INTO t1 VALUES (3);
131
132 --source include/rpl_sync.inc
133
134 #Both members should possess the same data
135
136 --let $server_count=2
137 while ($server_count)
138 {
139 --connection server$server_count
140 --let $assert_text= On member $server_count, the table should exist and have 3 elements
141 --let $assert_cond= [select count(*) from t1] = 3;
142 --source include/assert.inc
143 --dec $server_count
144 }
145
146 if(`SELECT "$server_uuid" < "$group_replication_group_name"`)
147 {
148 --let $wait_condition= SELECT transactions_committed_all_members like "$server_uuid:1-2,%$group_replication_group_name:1-4" from performance_schema.replication_group_member_stats where member_id in (SELECT @@server_uuid);
149 }
150 if(`SELECT "$server_uuid" > "$group_replication_group_name"`)
151 {
152 --let $wait_condition= SELECT transactions_committed_all_members like "$group_replication_group_name:1-4,%$server_uuid:1-2" from performance_schema.replication_group_member_stats where member_id in (SELECT @@server_uuid);
153 }
154 --let $wait_timeout= 150
155 --source include/wait_condition.inc
156 --echo [ The value of stable_set should contain both provisioned and group GIIDs ]
157
158
159 #
160 # Phase 3: Restart group replication on member 2
161 #
162
163 --connection server2
164
165 --source include/stop_group_replication.inc
166 --source include/start_group_replication.inc
167
168 INSERT INTO t1 VALUES (4);
169 --source include/rpl_sync.inc
170
171 #Both members should possess the same data
172
173 --let $server_count=2
174 while ($server_count)
175 {
176 --connection server$server_count
177 --let $assert_text= On member $server_count, the table should exist and have 4 elements
178 --let $assert_cond= [select count(*) from t1] = 4;
179 --source include/assert.inc
180 --dec $server_count
181 }
182
183 #
184 #Cleanup
185 #
186
187 DROP TABLE t1;
188
189 --source include/group_replication_end.inc