File: galera_gtid_consistency.test

package info (click to toggle)
mariadb 1%3A11.8.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 765,428 kB
  • sloc: ansic: 2,382,827; cpp: 1,803,532; asm: 378,315; perl: 63,176; sh: 46,496; pascal: 40,776; java: 39,363; yacc: 20,428; python: 19,506; sql: 17,864; xml: 12,463; ruby: 8,544; makefile: 6,059; cs: 5,855; ada: 1,700; lex: 1,193; javascript: 1,039; objc: 80; tcl: 73; awk: 46; php: 22
file content (379 lines) | stat: -rw-r--r-- 11,520 bytes parent folder | download | duplicates (4)
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
--source include/galera_cluster.inc
--source include/big_test.inc
--source include/force_restart.inc

#
# Testing gtid consistency in 3 node cluster when nodes drop
# and join back to cluster.
# The tests verify that wsrep_gtid_domain_id and gtid_binlog_pos
# remains same across the cluster
# In the configuration, nodes have different wsrep_gtid_domain_id
# but all nodes are supposed to receive effective domain id
# from the bootstrap node (node_1), and use it
#
--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3

# Save original auto_increment_offset values.
--let $node_1=node_1
--let $node_2=node_2
--let $node_3=node_3
--source ../galera/include/auto_increment_offset_save.inc

--connect node_2b, 127.0.0.1, root, , test, $NODE_MYPORT_2
set wsrep_sync_wait=0;
--connect node_1b, 127.0.0.1, root, , test, $NODE_MYPORT_1
set wsrep_sync_wait=0;

--connection node_1
DELIMITER |;
CREATE PROCEDURE insert_row (IN node varchar(10), IN repeat_count int)
BEGIN
  DECLARE current_num int;
  SET current_num = 0;
  WHILE current_num < repeat_count do
    INSERT INTO t1(node, name) VALUES (node, UUID());
    SET current_num = current_num + 1;
  END WHILE;
END|
DELIMITER ;|

CREATE TABLE t1 (id bigint not null primary key auto_increment, node VARCHAR(10), name VARCHAR(64)) ENGINE=innodb;

#
# report initial gtid positions after table t1 is created
#
--echo # node_1
show variables like '%gtid_binlog_pos%';

--connection node_2
--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'
--source include/wait_condition.inc

--echo # node_2
show variables like '%gtid_binlog_pos%';

--connection node_3
--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'
--source include/wait_condition.inc

--echo # node_3
show variables like '%gtid_binlog_pos%';

###########################################
#  scenario: join node 2 by SST
##########################################

#
# start concurrent insert load and stop node2 while the load is on
#
--connection node_1
--send CALL insert_row('node1', 500);

--connection node_2
--send CALL insert_row('node2', 500);

--connection node_3
--send CALL insert_row('node3', 500);

#
# stop load to node 2 and shutdown the node, force SST
#
--connection node_2
--reap

--echo # Shutdown node_2, force SST
--connection node_2b
--source include/shutdown_mysqld.inc
--remove_file $MYSQLTEST_VARDIR/mysqld.2/data/grastate.dat

--echo # Wait until node_2 leaves cluster
--connection node_1b
--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
--source include/wait_condition.inc

#
# stop the remaining load to node 1 and 3
#
--connection node_1
--reap
--connection node_3
--reap

#
# some more inserts and DDL to nodes 1 and 3
# while node 2 is absent
#
--connection node_1
CALL insert_row('node1', 100);

--connection node_3
CALL insert_row('node3', 100);

CREATE TABLE t2(i int primary key) engine=innodb;

#
# restart node 2, should join by SST
#
--connection node_2
--echo # Restart node_2
--source include/start_mysqld.inc

--connection node_1b
--echo # Wait until node_2 is back in cluster
--let $wait_condition = SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
--source include/wait_condition.inc

--echo # node2 has joined

#
# check gtid positions in all nodes
#
--echo # GTID in node1
show variables like 'wsrep_gtid_domain_id';
show variables like '%gtid_binlog_pos%';

--connection node_2
--echo # GTID in node2
show variables like 'wsrep_gtid_domain_id';
show variables like '%gtid_binlog_pos%';

--connection node_3
--echo # GTID in node3
show variables like 'wsrep_gtid_domain_id';
show variables like '%gtid_binlog_pos%';


###########################################
#  scenario: join node 3 by IST
##########################################

--echo # Shutdown node_3
--connection node_3
SET GLOBAL wsrep_provider_options = 'gmcast.isolate = 1';

--echo # Wait until node_3 leaves cluster
--connection node_1b
--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
--source include/wait_condition.inc

#
# do some inserts and DDL to node 1
# while node 3 is absent
#
--connection node_1
CALL insert_row('node1', 50);

CREATE TABLE t3(i int primary key) engine=innodb;

#
# remove isolation in node 3, should join by IST
#
--connection node_3
--echo # Rejoin node_3
SET GLOBAL wsrep_provider_options = 'gmcast.isolate = 0';

--connection node_1b
--echo # Wait until node_3 is back in cluster
--let $wait_condition = SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
--source include/wait_condition.inc

--echo # node3 has joined

#
# check gtid positions in all nodes
#
--connection node_1
--echo # GTID in node1
show variables like 'wsrep_gtid_domain_id';
show variables like '%gtid_binlog_pos%';

--connection node_2
--echo # GTID in node2
show variables like 'wsrep_gtid_domain_id';
show variables like '%gtid_binlog_pos%';

--connection node_3
--echo # GTID in node3
show variables like 'wsrep_gtid_domain_id';
show variables like '%gtid_binlog_pos%';


###########################################
#  scenario: restart full custer
##########################################


#
# stop all nodes, one by one
#
--echo # One by one shutdown all nodes
--connection node_3
--echo # shutdown node_3
--source include/shutdown_mysqld.inc
--remove_file $MYSQLTEST_VARDIR/mysqld.3/data/grastate.dat

--connection node_2
--echo # wait until node_3 is out of cluster
--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
--source include/wait_condition.inc
--echo # shutdown node_2
--source include/shutdown_mysqld.inc
--remove_file $MYSQLTEST_VARDIR/mysqld.2/data/grastate.dat

--connection node_1
--echo # wait until node_2 is out of cluster
--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
--source include/wait_condition.inc
--echo # shutdown node_1
--source include/shutdown_mysqld.inc

#
# bootstap cluster in order node1 - node2 - node3
# send some inserts and DDL after each node started
#

--echo # Bootstrap from node_1
--connection node_1
--let $restart_parameters = --wsrep_new_cluster
--source include/start_mysqld.inc

--let $wait_condition = SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready';
--source include/wait_condition.inc
--let $wait_condition = SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status';
--source include/wait_condition.inc
--let $wait_condition = SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'
--source include/wait_condition.inc

show variables like 'wsrep_gtid_domain_id';
show variables like '%gtid_binlog_pos%';

ANALYZE TABLE t2;
--send CALL insert_row('node1', 100);

--echo # Restart node_2
--connection node_2
--let $restart_parameters =
--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
--source include/start_mysqld.inc

--let $wait_condition = SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready';
--source include/wait_condition.inc
--let $wait_condition = SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status';
--source include/wait_condition.inc
--let $wait_condition = SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'
--source include/wait_condition.inc

#
# connection node_1b may not be functional anymore, after node was
# shutdown, open node_1c for controlling node 1 state
#
--connect node_1c, 127.0.0.1, root, , test, $NODE_MYPORT_1
set wsrep_sync_wait=0;
--connection node_1c
--echo # wait until node_1 and node_2 are in cluster
--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
--source include/wait_condition.inc

--connection node_2
ALTER TABLE t2 ADD COLUMN (k int);
--send CALL insert_row('node2', 100);


--echo # Restart node_3
--connection node_3
--let $restart_parameters =
--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.3.expect
--source include/start_mysqld.inc

--let $wait_condition = SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready';
--source include/wait_condition.inc
--let $wait_condition = SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status';
--source include/wait_condition.inc
--let $wait_condition = SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'
--source include/wait_condition.inc


--connection node_1c
--echo # wait until all nodes are back in cluster
--let $wait_condition = SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
--source include/wait_condition.inc
--echo after cluster restart

# stop load for nodes 1 and 2
--connection node_2
--reap

--connection node_1
--reap

#
# check gtid positions in all nodes
#
--connection node_1
--echo node1 GTID
show variables like 'wsrep_gtid_domain_id';
show variables like '%gtid_binlog_pos%';

--connection node_2
--echo node2 GTID
show variables like 'wsrep_gtid_domain_id';
show variables like '%gtid_binlog_pos%';

--connection node_3
--echo node3 GTID
show variables like 'wsrep_gtid_domain_id';
show variables like '%gtid_binlog_pos%';

#
# check table size in all nodes
#
--connection node_1
--echo table size in node1
SELECT COUNT(*) FROM t1;

--connection node_2
--echo table size in node2
SELECT COUNT(*) FROM t1;

--connection node_3
--echo table size in node3
SELECT COUNT(*) FROM t1;

#
# cleanups
#
--connection node_2
call mtr.add_suppression("WSREP: Ignoring server id .* for non bootstrap node");
call mtr.add_suppression("Sending JOIN failed: ");
call mtr.add_suppression("WSREP: Failed to JOIN the cluster after SST");
call mtr.add_suppression("WSREP: FLOW message from member .* in non-primary configuration");
--connection node_3
call mtr.add_suppression("WSREP: Ignoring server id .* for non bootstrap node");
call mtr.add_suppression("Sending JOIN failed: ");
call mtr.add_suppression("WSREP: Failed to JOIN the cluster after SST");
call mtr.add_suppression("WSREP: FLOW message from member .* in non-primary configuration");

--echo # cleanup
--connection node_1
call mtr.add_suppression("WSREP: FLOW message from member .* in non-primary configuration");

DROP PROCEDURE insert_row;
DROP TABLE t1;
DROP TABLE t2;
DROP TABLE t3;

--connection node_3
--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't3'
--source include/wait_condition.inc
--connection node_2
--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't3'
--source include/wait_condition.inc

# Restore original auto_increment_offset values.
--let $galera_cluster_size=3
--source ../galera/include/auto_increment_offset_restore.inc

--disconnect node_3
--disconnect node_2b
--disconnect node_1b
--disconnect node_1c