File: gr_auto_increment_increment.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 (304 lines) | stat: -rw-r--r-- 14,182 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
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
################################################################################
# Verify following auto_increment behaviours:
#
# Test:
# 0. This test starts with 4 non-started members.
# 1. Check the defaults of group_replication_auto_increment_increment,
#    auto_increment_increment and auto_increment_offset.
# 2. Check that the value of group_replication_auto_increment_increment
#    can be set before GR start, but its effects on
#    auto_increment_increment and auto_increment_offset do not happen.
# 3. Check that the effects of group_replication_auto_increment_increment
#    on auto_increment_increment and auto_increment_offset happen on
#    starting GR.
# 4. When the number of members is bigger than the auto_increment_increment
#    value, an error is logged.
# 5. When auto_increment_increment and auto_increment_offset are not equal to 1,
#    group_replication should not update their value on START and STOP.
# 6. When auto_increment_increment and auto_increment_offset are equal to 1,
#    then verify if plugin on start set auto_increment_increment variable
#    equal to group_replication_auto_increment_increment value.
# 7. When group_replication is stopped verify that plugin reset
#    auto_increment_increment and auto_increment_offset values to 1.
# 8. Verify start/stop group_replication plugin doesn't affect setting
#    auto_increment_increment from group_replication_auto_increment_increment
#    value.
# 9. Verify server restart doesn't affect setting auto_increment_increment from
#    group_replication_auto_increment_increment value.
# 10. Verify group_replication_auto_increment_increment can't be set when
#    group_replication plugin is running.
# 11. Validate that when user tries to set invalid values a
#     error is thrown.
# 12. Clean up.
################################################################################
--source include/big_test.inc
--source include/have_group_replication_plugin.inc
--source include/force_restart.inc

--let $rpl_skip_group_replication_start= 1
--let $rpl_server_count= 4
--source include/group_replication.inc

--connection server1
--source include/start_and_bootstrap_group_replication.inc

--connection server3
--source include/start_group_replication.inc

--connection server4
--source include/start_group_replication.inc

# Use server2 so that we can set
# group_replication_auto_increment_increment-slave.opt
--connection server2

# changing GROUP_REPLICATION_AUTO_INCREMENT_INCREMENT for server2
# and so storing it only for server2
--let $_init_auto_increment= `SELECT @@GLOBAL.GROUP_REPLICATION_AUTO_INCREMENT_INCREMENT`

--echo #######################################################################
--echo # 1. Check the defaults of group_replication_auto_increment_increment,
--echo #    auto_increment_increment and auto_increment_offset.
--echo #######################################################################
--let $assert_text= The default value of group_replication_auto_increment_increment for server2 should be 7
--let $assert_cond= [SELECT @@GLOBAL.group_replication_auto_increment_increment] = 7
--source include/assert.inc
--let $assert_text= The default value of auto_increment_increment for server2 should be 1
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_increment] = 1
--source include/assert.inc
--let $assert_text= The default value of auto_increment_offset for server2 should be 1
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_offset] = 1
--source include/assert.inc

--echo #######################################################################
--echo # 2. Check that the value of group_replication_auto_increment_increment
--echo #    can be set before GR start, but its effects on
--echo #    auto_increment_increment and auto_increment_offset do not happen.
--echo #######################################################################
SET GLOBAL GROUP_REPLICATION_AUTO_INCREMENT_INCREMENT= 3;
--let $assert_text= The value of group_replication_auto_increment_increment is set to 3
--let $assert_cond= [SELECT @@GLOBAL.group_replication_auto_increment_increment] = 3
--source include/assert.inc
--let $assert_text= The value of auto_increment_increment is not affected
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_increment] = 1
--source include/assert.inc
--let $assert_text= The value of auto_increment_offset is not affected
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_offset] = 1
--source include/assert.inc

--source include/start_group_replication.inc

--echo #########################################################################
--echo # 3. Check that the effects of group_replication_auto_increment_increment
--echo #    on auto_increment_increment and auto_increment_offset happen on
--echo #    starting GR.
--echo #########################################################################
--let $assert_text= The value of group_replication_auto_increment_increment is still 3
--let $assert_cond= [SELECT @@GLOBAL.group_replication_auto_increment_increment] = 3
--source include/assert.inc
--let $assert_text= The value of auto_increment_increment is set to 3
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_increment] = 3
--source include/assert.inc
--let $assert_text= The value of auto_increment_offset is set to 2
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_offset] = 2
--source include/assert.inc


--echo ############################################################
--echo # 4. When the number of members is bigger than
--echo #    the auto_increment_increment value, an error is logged.
--echo ############################################################

--replace_regex /[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9]\.[0-9][0-9][0-9][0-9][0-9][0-9][-+Z][0-9:]* *[0-9]* \[ERROR\] \[[^\]]*\] */DATE_TIME [ERROR] /
--let $grep_file=$MYSQLTEST_VARDIR/tmp/group_replication_auto_increment_increment_log.err
--let $grep_pattern=Group contains 4 members which is greater than group_replication_auto_increment_increment value of 3. This can lead to a higher transactional abort rate.
--source include/grep_pattern.inc

--echo ############################################################
--echo # 5. When auto_increment_increment and auto_increment_offset
--echo #    not set to default value
--echo #    i.e. auto_increment_increment= 1
--echo #         auto_increment_offset= 1
--echo #    group_replication should not update their value.
--echo ############################################################

--source include/stop_group_replication.inc

SET GLOBAL AUTO_INCREMENT_INCREMENT= 5;
SET GLOBAL AUTO_INCREMENT_OFFSET= 5;

--source include/start_group_replication.inc

--let $assert_text= The value of auto_increment_increment for server2 should be 5
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_increment] = 5
--source include/assert.inc

--let $assert_text= The value of auto_increment_offset for server2 should be 5
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_offset] = 5
--source include/assert.inc

--source include/stop_group_replication.inc

--let $assert_text= The value of auto_increment_increment for server2 should be 5
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_increment] = 5
--source include/assert.inc

--let $assert_text= The value of auto_increment_offset for server2 should be 5
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_offset] = 5
--source include/assert.inc

--echo ############################################################
--echo # 6. When auto_increment_increment and auto_increment_offset are equal
--echo #    to 1, then verify if plugin on start set auto_increment_increment
--echo #    variable equal to group_replication_auto_increment_increment value.
--echo ############################################################

SET GLOBAL AUTO_INCREMENT_INCREMENT= 1;
SET GLOBAL AUTO_INCREMENT_OFFSET= 1;
SET GLOBAL GROUP_REPLICATION_AUTO_INCREMENT_INCREMENT= 4;

--source include/start_group_replication.inc

--let $assert_text= The value of auto_increment_increment for server2 should be 4
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_increment] = 4
--source include/assert.inc

--let $assert_text= The value of auto_increment_offset for server2 should be 2
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_offset] = 2
--source include/assert.inc

--echo ############################################################
--echo # 7. When group_replication is stopped verify that plugin reset
--echo #    auto_increment_increment and auto_increment_offset values to 1.
--echo ############################################################

--source include/stop_group_replication.inc

--let $assert_text= The value of auto_increment_increment for server2 should be 1
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_increment] = 1
--source include/assert.inc

--let $assert_text= The value of auto_increment_offset for server2 should be 1
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_offset] = 1
--source include/assert.inc

# Set GROUP_REPLICATION_AUTO_INCREMENT_INCREMENT to 1, so that it doesn't
# affect when starting group_replication again.
SET GLOBAL GROUP_REPLICATION_AUTO_INCREMENT_INCREMENT= 1;

--echo ############################################################
--echo # 8. Verify start/stop group_replication plugin doesn't affect
--echo #    setting auto_increment_increment from
--echo #    group_replication_auto_increment_increment value.
--echo ############################################################

--source include/start_group_replication.inc

--let $assert_text= The value of auto_increment_increment for server2 should be 1
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_increment] = 1
--source include/assert.inc

--let $assert_text= The value of auto_increment_offset for server2 should be 2
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_offset] = 2
--source include/assert.inc

--source include/stop_group_replication.inc

SET GLOBAL GROUP_REPLICATION_AUTO_INCREMENT_INCREMENT= 9;

--source include/start_group_replication.inc

--let $assert_text= The value of auto_increment_increment for server2 should be 9
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_increment] = 9
--source include/assert.inc

--let $assert_text= The value of auto_increment_offset for server2 should be 2
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_offset] = 2
--source include/assert.inc

--echo ############################################################
--echo # 9. Verify server restart doesn't affect setting
--echo #    auto_increment_increment from
--echo #    group_replication_auto_increment_increment value.
--echo ############################################################

--source include/stop_group_replication.inc

--let $assert_text= The value of auto_increment_increment for server2 should be 1
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_increment] = 1
--source include/assert.inc

--let $assert_text= The value of auto_increment_offset for server2 should be 1
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_offset] = 1
--source include/assert.inc

# Set GROUP_REPLICATION_AUTO_INCREMENT_INCREMENT to 1, so that it doesn't
# affect when starting group_replication again.
SET GLOBAL GROUP_REPLICATION_AUTO_INCREMENT_INCREMENT= 1;

--source include/start_group_replication.inc

--let $assert_text= The value of auto_increment_increment for server2 should be 1
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_increment] = 1
--source include/assert.inc

--let $assert_text= The value of auto_increment_offset for server2 should be 2
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_offset] = 2
--source include/assert.inc

# restart server
--let $allow_rpl_inited= 1
--let $_group_replication_local_address= `SELECT @@GLOBAL.group_replication_local_address`
--let $_group_replication_group_seeds= `SELECT @@GLOBAL.group_replication_group_seeds`
--let $restart_parameters=restart:--group_replication_local_address=$_group_replication_local_address --group_replication_group_seeds=$_group_replication_group_seeds
--replace_result $_group_replication_local_address GROUP_REPLICATION_LOCAL_ADDRESS $_group_replication_group_seeds GROUP_REPLICATION_GROUP_SEEDS
--source include/restart_mysqld.inc

# Needed as we are not using rpl_restart_server.inc
--let $rpl_server_number= 2
--source include/rpl_reconnect.inc

SET GLOBAL GROUP_REPLICATION_AUTO_INCREMENT_INCREMENT= 9;

--source include/start_group_replication.inc

--let $assert_text= The value of auto_increment_increment for server2 should be 9
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_increment] = 9
--source include/assert.inc

--let $assert_text= The value of auto_increment_offset for server2 should be 2
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_offset] = 2
--source include/assert.inc

--echo ############################################################
--echo # 10. Verify group_replication_auto_increment_increment can't be set
--echo #     when group_replication plugin is running.
--echo ############################################################

--error ER_GROUP_REPLICATION_RUNNING
SET GLOBAL GROUP_REPLICATION_AUTO_INCREMENT_INCREMENT= 9;

--echo ############################################################
--echo # 11. Validate that when user tries to set invalid values a
--echo #     error is thrown.
--echo ############################################################
--connection server2
--source include/stop_group_replication.inc

--error ER_WRONG_VALUE_FOR_VAR
SET GLOBAL GROUP_REPLICATION_AUTO_INCREMENT_INCREMENT= -1;

--error ER_WRONG_VALUE_FOR_VAR
SET GLOBAL GROUP_REPLICATION_AUTO_INCREMENT_INCREMENT= 65536;

--error ER_WRONG_VALUE_FOR_VAR
SET GLOBAL GROUP_REPLICATION_AUTO_INCREMENT_INCREMENT= 0;

--error ER_WRONG_TYPE_FOR_VAR
SET GLOBAL GROUP_REPLICATION_AUTO_INCREMENT_INCREMENT= 'a';

--echo ############################################################
--echo # 12. clean up and reset auto_increment variables value
--echo ############################################################
--eval SET GLOBAL GROUP_REPLICATION_AUTO_INCREMENT_INCREMENT= $_init_auto_increment
--source include/group_replication_end.inc