Debian Codegraph @

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

raw
1 ################################################################################
2 #
3 # This test checks that recompute of GTIDS intervals work even when
4 # view_change_uuid is configured.
5 #
6 # Test:
7 # 0. This test works with 2 servers in multi primary mode
8 # 1. Setup Group Replication on server 1 and 2 with view
9 # change uuid configured with an valid uuid
10 # 2. Create a table on server 1 that will add one
11 # transaction to the group
12 # 3. Insert data into table on server 2 that will add one
13 # transaction to the group
14 # 4. Remove and rejoin server 2, that will generate a new
15 # view and will recompute intervals
16 # 5. Insert data into table on server 2 that will add one
17 # transaction to the group
18 # 6. Transactions are added to the correct intervals and
19 # views are logged with view uuid
20 # 7. Stop server 2 and on server 1 set GTID_NEXT to next
21 # expected view uuid and execute a transaction.
22 # Start server 2
23 # 8. Assert the intervals were not used, the new view
24 # change is correctly logged and the transaction using
25 # the view uuid is also executed.
26 # 9. Cleanup
27 #
28 ################################################################################
29
30 --source include/have_group_replication_plugin.inc
31 --let $rpl_skip_group_replication_start= 1
32 --source include/group_replication.inc
33
34
35 --echo
36 --echo ############################################################
37 --echo # 1. Setup Group Replication on server 1 and 2 with view
38 --echo # change uuid configured with an valid uuid
39
40 SET @group_replication_view_change_uuid_save= @@GLOBAL.group_replication_view_change_uuid;
41 --let $view_change_uuid = aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa
42
43 --eval SET GLOBAL group_replication_view_change_uuid = "$view_change_uuid"
44
45 --source include/start_and_bootstrap_group_replication.inc
46
47 --let $rpl_connection_name= server2
48 --source include/rpl_connection.inc
49
50 SET @group_replication_view_change_uuid_save= @@GLOBAL.group_replication_view_change_uuid;
51 --eval SET GLOBAL group_replication_view_change_uuid = "$view_change_uuid"
52
53 --source include/start_group_replication.inc
54
55
56 --echo
57 --echo ############################################################
58 --echo # 2. Create a table on server 1 that will add one
59 --echo # transaction to the group
60
61 --let $rpl_connection_name= server1
62 --source include/rpl_connection.inc
63
64 CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
65 --source include/rpl_sync.inc
66
67
68 --echo
69 --echo ############################################################
70 --echo # 3. Insert data into table on server 2 that will add one
71 --echo # transaction to the group
72
73 --let $rpl_connection_name= server2
74 --source include/rpl_connection.inc
75
76 INSERT INTO t1 VALUES (0);
77 --source include/rpl_sync.inc
78
79
80 --echo
81 --echo ############################################################
82 --echo # 4. Remove and rejoin server 2, that will generate a new
83 --echo # view and will recompute intervals
84
85 --source include/stop_group_replication.inc
86
87 --let $gtid_assignment_block_size= `SELECT @@GLOBAL.group_replication_gtid_assignment_block_size;`
88 --let $expected_gtid_set= $group_replication_group_name:1:1000001
89 if ($gtid_assignment_block_size == 1)
90 {
91 --let $expected_gtid_set= $group_replication_group_name:1-2
92 }
93
94 --let $assert_text= GTID_EXECUTED must contain GTID_EXECUTED 2 transactions
95 --let $assert_cond= [SELECT GTID_SUBSET("$expected_gtid_set", @@GLOBAL.GTID_EXECUTED)] = 1
96 --source include/assert.inc
97
98 --let $assert_text= GTID_EXECUTED must contain GTID_EXECUTED 2 view changes
99 --let $assert_cond= [SELECT GTID_SUBSET("$view_change_uuid:1-2", @@GLOBAL.GTID_EXECUTED)] = 1
100 --source include/assert.inc
101
102 --source include/start_group_replication.inc
103
104 --echo
105 --echo ############################################################
106 --echo # 5. Insert data into table on server 2 that will add one
107 --echo # transaction to the group
108
109 INSERT INTO t1 VALUES (1);
110 --source include/rpl_sync.inc
111
112 --echo
113 --echo ############################################################
114 --echo # 6. Transactions are added to the correct intervals and
115 --echo # views are logged with view uuid
116
117 --let $gtid_assignment_block_size= `SELECT @@GLOBAL.group_replication_gtid_assignment_block_size;`
118 --let $expected_gtid_set= $group_replication_group_name:1-2:1000001
119 if ($gtid_assignment_block_size == 1)
120 {
121 --let $expected_gtid_set= $group_replication_group_name:1-3
122 }
123
124 --let $assert_text= GTID_EXECUTED must contain GTID_EXECUTED 3 transactions, two on first interval
125 --let $assert_cond= [SELECT GTID_SUBSET("$expected_gtid_set", @@GLOBAL.GTID_EXECUTED)] = 1
126 --source include/assert.inc
127
128 --let $assert_text= GTID_EXECUTED must contain GTID_EXECUTED 3 view changes
129 --let $assert_cond= [SELECT GTID_SUBSET("$view_change_uuid:1-3", @@GLOBAL.GTID_EXECUTED)] = 1
130 --source include/assert.inc
131
132 --let $rpl_connection_name= server1
133 --source include/rpl_connection.inc
134
135 --let $assert_text= GTID_EXECUTED must contain GTID_EXECUTED 3 transactions, two on first interval
136 --let $assert_cond= [SELECT GTID_SUBSET("$expected_gtid_set", @@GLOBAL.GTID_EXECUTED)] = 1
137 --source include/assert.inc
138
139 --let $assert_text= GTID_EXECUTED must contain GTID_EXECUTED 3 view changes
140 --let $assert_cond= [SELECT GTID_SUBSET("$view_change_uuid:1-3", @@GLOBAL.GTID_EXECUTED)] = 1
141 --source include/assert.inc
142
143
144 --echo
145 --echo ############################################################
146 --echo # 7. Stop server 2 and on server 1 set GTID_NEXT to next
147 --echo # expected view uuid and execute a transaction.
148 --echo # Start server 2
149
150 --let $rpl_connection_name= server2
151 --source include/rpl_connection.inc
152
153 --source include/stop_group_replication.inc
154
155 --let $rpl_connection_name= server1
156 --source include/rpl_connection.inc
157
158 --eval SET GTID_NEXT= '$view_change_uuid:4';
159
160 INSERT INTO t1 VALUES (2);
161
162 --let $rpl_connection_name= server2
163 --source include/rpl_connection.inc
164
165 --source include/start_group_replication.inc
166
167
168 --echo
169 --echo ############################################################
170 --echo # 8. Assert the intervals were not used, the new view
171 --echo # change is correctly logged and the transaction using
172 --echo # the view uuid is also executed.
173
174 --let $assert_text= GTID_EXECUTED must contain GTID_EXECUTED 3 transactions, two on first interval
175 --let $assert_cond= [SELECT GTID_SUBSET("$expected_gtid_set", @@GLOBAL.GTID_EXECUTED)] = 1
176 --source include/assert.inc
177
178 --let $assert_text= GTID_EXECUTED must contain GTID_EXECUTED 4 view changes plus 1 transaction
179 --let $assert_cond= [SELECT GTID_SUBSET("$view_change_uuid:1-5", @@GLOBAL.GTID_EXECUTED)] = 1
180 --source include/assert.inc
181
182 --let $rpl_connection_name= server1
183 --source include/rpl_connection.inc
184
185 --let $assert_text= GTID_EXECUTED must contain GTID_EXECUTED 3 transactions, two on first interval
186 --let $assert_cond= [SELECT GTID_SUBSET("$expected_gtid_set", @@GLOBAL.GTID_EXECUTED)] = 1
187 --source include/assert.inc
188
189 --let $assert_text= GTID_EXECUTED must contain GTID_EXECUTED 4 view changes plus 1 transaction
190 --let $assert_cond= [SELECT GTID_SUBSET("$view_change_uuid:1-5", @@GLOBAL.GTID_EXECUTED)] = 1
191 --source include/assert.inc
192
193
194 --echo
195 --echo ############################################################
196 --echo # 9. Cleanup
197
198 SET GTID_NEXT= 'AUTOMATIC';
199 DROP TABLE t1;
200
201 --source include/stop_group_replication.inc
202 SET @@GLOBAL.group_replication_view_change_uuid= @group_replication_view_change_uuid_save;
203
204 --let $rpl_connection_name= server2
205 --source include/rpl_connection.inc
206
207 --source include/stop_group_replication.inc
208 SET @@GLOBAL.group_replication_view_change_uuid= @group_replication_view_change_uuid_save;
209
210 --source include/group_replication_end.inc
211