File: no_binlog_gtid_next_partially_failed_stmts.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 (444 lines) | stat: -rw-r--r-- 17,803 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
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
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
########################################

# ==== Purpose ====
#
# Verify that a partially failed statement can consume
# its gtid and save the gtid into @@GLOBAL.GTID_EXECUTED
# and mysql.gtid_executed table when binlog is disabled
# if it did the same when binlog is enabled.
#
# Also provides coverage for changes to GTID handling for failed
# DROP TABLES, which were implemented as part of WL#7743 "New data
# dictionary: changes to DDL-related parts of SE API".
#
# ==== Implementation ====
#
# 1) SET SESSION GTID_NEXT='UUID:GNO'.
# 2) Execute a partially failed statement.
# 3) Verify that the partially failed statement can consume
#    its gtid and save the gtid into @@GLOBAL.GTID_EXECUTED
#    and mysql.gtid_executed table when binlog is disabled
#    if it did the same when binlog is enabled.
# 4) Execute above three steps for all different types of statements
#
# ==== References ====
#
# Bug#21686749  PARTIALLY FAILED DROP OR ACL STMT FAILS TO CONSUME GTID ON BINLOGLESS SLAVE
# See mysql-test/suite/binlog/t/binlog_gtid_next_partially_failed_stmts.test
# See mysql-test/suite/binlog/t/binlog_gtid_next_partially_failed_grant.test
# See mysql-test/t/no_binlog_gtid_next_partially_failed_stmts_error.test
#

# The test involves MyISAM sorage engine
--source include/force_myisam_default.inc
--source include/have_myisam.inc

# Should be tested against "binlog disabled" server
--source include/not_log_bin.inc
# Requires debug server to simulate failure to drop table in SE
--source include/have_debug.inc

# Make sure the test is repeatable
RESET MASTER;

--let $master_uuid= `SELECT @@GLOBAL.SERVER_UUID`

--replace_result $master_uuid MASTER_UUID
--eval SET SESSION GTID_NEXT='$master_uuid:1'
CREATE TABLE t1 (a int) ENGINE=MyISAM;
--replace_result $master_uuid MASTER_UUID
--eval SET SESSION GTID_NEXT='$master_uuid:2'
CREATE TABLE t5 (a int) ENGINE=InnoDB;

# Check-1: DROP TABLE

--replace_result $master_uuid MASTER_UUID
--eval SET SESSION GTID_NEXT='$master_uuid:3'
--echo #
--echo # Original test case.
--echo #
--echo # The below DROP TABLE has partially failed before WL#7743.
--echo # Now if fails without side-effects and thus should not consume gitd.
--echo #
--error ER_BAD_TABLE_ERROR
DROP TABLE t1, t3;

--echo #
--echo # The table t1 was not dropped.
--echo #
SHOW CREATE TABLE t1;

--echo #
--echo # Verify that the above DROP TABLE statement has not consumed gtid.
--echo #
--let $assert_text= Committed gtid MASTER_UUID:2 into @@GLOBAL.GTID_EXECUTED
--let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$master_uuid:1-2"
--source include/assert.inc
--eval SET SESSION GTID_NEXT='AUTOMATIC'
FLUSH LOGS;
--let $assert_text= Saved gtid MASTER_UUID:2 into mysql.gtid_executed table
--let $assert_cond= "[SELECT COUNT(*) FROM mysql.gtid_executed WHERE interval_end = 2]" = 1
--source include/assert.inc

--echo #
--echo # Now we simulate error after dropping MyISAM table. In this case
--echo # DROP TABLE is partially executed/failed and should consume gtid.
--echo #
SET @@debug="+d,rm_table_no_locks_abort_before_atomic_tables";
--replace_result $master_uuid MASTER_UUID
--eval SET SESSION GTID_NEXT='$master_uuid:3'
--error ER_UNKNOWN_ERROR
DROP TABLE t1, t5;
SET @@debug="-d,rm_table_no_locks_abort_before_atomic_tables";

--echo #
--echo # The above DROP TABLE should have deleted t1.
--echo #
--error ER_NO_SUCH_TABLE
SHOW CREATE TABLE t1;

--echo #
--echo # Verify that the partially failed DROP TABLE statement can consume
--echo # its gtid and save the gtid into @@GLOBAL.GTID_EXECUTED and
--echo # mysql.gtid_executed table when binlog is disabled as it did when
--echo # binlog is enabled.
--echo #
--let $assert_text= Committed gtid MASTER_UUID:2 into @@GLOBAL.GTID_EXECUTED
--let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$master_uuid:1-3"
--source include/assert.inc
--eval SET SESSION GTID_NEXT='AUTOMATIC'
FLUSH LOGS;
--let $assert_text= Saved gtid MASTER_UUID:2 into mysql.gtid_executed table
--let $assert_cond= "[SELECT COUNT(*) FROM mysql.gtid_executed WHERE interval_end = 3]" = 1
--source include/assert.inc

--replace_result $master_uuid MASTER_UUID
--eval SET SESSION GTID_NEXT='$master_uuid:4'
CREATE TEMPORARY TABLE tmp1 (a int);

# Check-2: DROP TEMPORARY TABLE
--replace_result $master_uuid MASTER_UUID
--eval SET SESSION GTID_NEXT='$master_uuid:5'
--echo #
--echo # The below DROP TEMPORARY TABLE has partially failed before WL#7743.
--echo # Now if fails without side-effects and thus should not consume gitd.
--echo #
--echo # There is no way for DROP TEMPORARY TABLE to partially fail now,
--echo # so unlike for DROP TABLE, there is no way to test scenario with
--echo # partial failure for it.
--error ER_BAD_TABLE_ERROR
DROP TEMPORARY TABLE tmp1, t2;

--echo #
--echo # Verify that failed DROP TEMPORARY TABLE statement has not
--echo # consumed its gtid.
--echo #
--let $assert_text= Committed gtid MASTER_UUID:4 into @@GLOBAL.GTID_EXECUTED
--let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$master_uuid:1-4"
--source include/assert.inc
--eval SET SESSION GTID_NEXT='AUTOMATIC'
FLUSH LOGS;
--let $assert_text= Saved gtid MASTER_UUID:4 into mysql.gtid_executed table
--let $assert_cond= "[SELECT COUNT(*) FROM mysql.gtid_executed WHERE interval_end = 4]" = 1
--source include/assert.inc

--replace_result $master_uuid MASTER_UUID
--eval SET SESSION GTID_NEXT='$master_uuid:5'
CREATE TABLE t1(a INT, b INT);
--replace_result $master_uuid MASTER_UUID
--eval SET SESSION GTID_NEXT='$master_uuid:6'
CREATE USER u1@h;
--echo #
--echo # Verify that u1 is added into mysql.user.
--echo #
SELECT user FROM mysql.user where user='u1';

# Check-3: GRANT a non-available privilege
--replace_result $master_uuid MASTER_UUID
--eval SET SESSION GTID_NEXT='$master_uuid:7'
--error ER_BAD_FIELD_ERROR
GRANT SELECT(a), SELECT(c) ON t1 TO u1@h;
--echo #
--echo # The SELECT privilege on column a is not granted to u1@h,
--echo # which means that GRANT can not be failed partially when
--echo # granting an available privilege and a non-available
--echo # privilege to an existent user.
--echo #
SELECT user, column_name, column_priv FROM mysql.columns_priv;
--echo #
--echo # Verify that the failed GRANT statement does not save
--echo # the specified gtid into @@GLOBAL.GTID_EXECUTED and
--echo # mysql.gtid_executed table.
--echo #
--replace_result $master_uuid MASTER_UUID
--let $assert_text= Did not commit gtid MASTER_UUID:7 into @@GLOBAL.GTID_EXECUTED
--let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$master_uuid:1-6"
--source include/assert.inc
--eval SET SESSION GTID_NEXT='AUTOMATIC'
FLUSH LOGS;
--let $assert_text= Did not save gtid MASTER_UUID:7 into mysql.gtid_executed table
--let $assert_cond= "[SELECT COUNT(*) FROM mysql.gtid_executed WHERE interval_end = 7]" = 0
--source include/assert.inc

# Check-4: GRANT a privilege to a non-existent user
--replace_result $master_uuid MASTER_UUID
--eval SET SESSION GTID_NEXT='$master_uuid:7'
--error ER_CANT_CREATE_USER_WITH_GRANT
GRANT SELECT(a) ON t1 TO u1@h, u2@h;
--echo #
--echo # The SELECT privilege on column a is not granted to u1@h,
--echo # which means that GRANT can not fail partially when
--echo # granting an available privilege to both an existent
--echo # user and a non-existent user.
--echo #
SELECT user, column_name, column_priv FROM mysql.columns_priv;
--echo #
--echo # Verify that the failed GRANT statement does not save
--echo # the specified gtid into @@GLOBAL.GTID_EXECUTED and
--echo # mysql.gtid_executed table.
--echo #
--replace_result $master_uuid MASTER_UUID
--let $assert_text= Did not commit gtid MASTER_UUID:7 into @@GLOBAL.GTID_EXECUTED
--let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$master_uuid:1-6"
--source include/assert.inc
--eval SET SESSION GTID_NEXT='AUTOMATIC'
FLUSH LOGS;
--let $assert_text= Did not save gtid MASTER_UUID:7 into mysql.gtid_executed table
--let $assert_cond= "[SELECT COUNT(*) FROM mysql.gtid_executed WHERE interval_end = 7]" = 0
--source include/assert.inc

# Check-5: REVOKE
--replace_result $master_uuid MASTER_UUID
--eval SET SESSION GTID_NEXT='$master_uuid:7'
--error ER_NONEXISTING_TABLE_GRANT
REVOKE SELECT(a), SELECT(b) ON t1 FROM u1@h;
--echo #
--echo # The SELECT privilege is not removed on column a from user u1,
--echo # which means that REVOKE statement can not fail partially
--echo # when revoking multiple privileges from a user.
--echo #
SELECT user, column_name, column_priv FROM mysql.columns_priv;
--echo #
--echo # Verify that the failed REVOKE statement does not save
--echo # the specified gtid into @@GLOBAL.GTID_EXECUTED and
--echo # and mysql.gtid_executed table.
--echo #
--replace_result $master_uuid MASTER_UUID
--let $assert_text= Did not commit gtid MASTER_UUID:7 into @@GLOBAL.GTID_EXECUTED
--let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$master_uuid:1-6"
--source include/assert.inc
--eval SET SESSION GTID_NEXT='AUTOMATIC'
FLUSH LOGS;
--let $assert_text= Did not save gtid MASTER_UUID:7 into mysql.gtid_executed table
--let $assert_cond= "[SELECT COUNT(*) FROM mysql.gtid_executed WHERE interval_end = 7]" = 0
--source include/assert.inc

# Check-6: DROP USER
--replace_result $master_uuid MASTER_UUID
--eval SET SESSION GTID_NEXT='$master_uuid:7'
--error ER_CANNOT_USER
DROP USER u1@h, u2@h;
--echo #
--echo # The u1 is not removed from mysql.user which means that DROP USER
--echo # can not fail partially.
--echo #
SELECT user FROM mysql.user where user='u1';
--echo #
--echo # Verify that the failed DROP USER statement does not consume
--echo # its gtid and save the gtid into @@GLOBAL.GTID_EXECUTED and
--echo # mysql.gtid_executed table.
--echo #
--replace_result $master_uuid MASTER_UUID
--let $assert_text= Did not commit gtid MASTER_UUID:7 into @@GLOBAL.GTID_EXECUTED
--let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$master_uuid:1-6"
--source include/assert.inc
--eval SET SESSION GTID_NEXT='AUTOMATIC'
FLUSH LOGS;
--let $assert_text= Did not save gtid MASTER_UUID:7 into mysql.gtid_executed table
--let $assert_cond= "[SELECT COUNT(*) FROM mysql.gtid_executed WHERE interval_end = 7]" = 0
--source include/assert.inc

# Check-7: RENAME TABLE
--replace_result $master_uuid MASTER_UUID
--eval SET SESSION GTID_NEXT='$master_uuid:7'
--error ER_NO_SUCH_TABLE
RENAME TABLE t1 TO t2, t3 TO t4;
--echo #
--echo # The table t1 was not renamed, which means RENAME TABLE
--echo # can not be failed partially.
--echo #
SHOW CREATE TABLE t1;
--echo #
--echo # Verify that the failed RENAME TABLE statement does not save
--echo # the specified gtid into @@GLOBAL.GTID_EXECUTED and
--echo # mysql.gtid_executed table when binlog is disabled as it did
--echo # when binlog is enabled.
--echo #
--replace_result $master_uuid MASTER_UUID
--let $assert_text= Did not commit gtid MASTER_UUID:7 into @@GLOBAL.GTID_EXECUTED
--let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$master_uuid:1-6"
--source include/assert.inc
--eval SET SESSION GTID_NEXT='AUTOMATIC'
FLUSH LOGS;
--let $assert_text= Did not save gtid MASTER_UUID:7 into mysql.gtid_executed table
--let $assert_cond= "[SELECT COUNT(*) FROM mysql.gtid_executed WHERE interval_end = 7]" = 0
--source include/assert.inc

# Check-8: OPTIMIZE TABLE
--echo #
--echo # The OPTIMIZE TABLE statement can be failed partially when optimizing
--echo # multiple tables, which contain a non-existent table.
--echo #
--replace_result $master_uuid MASTER_UUID
--eval SET SESSION GTID_NEXT='$master_uuid:7'
OPTIMIZE TABLE t1, t_non_existent;
--echo #
--echo # When optimizing a non-existent table, verify that the OPTIMIZE TABLE
--echo # statement saves its specified gtid into @@GLOBAL.GTID_EXECUTED and
--echo # mysql.gtid_executed table when binlog is disabled as it did
--echo # when binlog is enabled.
--echo #
--replace_result $master_uuid MASTER_UUID
--let $assert_text= Committed gtid MASTER_UUID:7 into @@GLOBAL.GTID_EXECUTED
--let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$master_uuid:1-7"
--source include/assert.inc
--eval SET SESSION GTID_NEXT='AUTOMATIC'
FLUSH LOGS;
--let $assert_text= Saved gtid MASTER_UUID:7 into mysql.gtid_executed table
--let $assert_cond= "[SELECT COUNT(*) FROM mysql.gtid_executed WHERE interval_end = 7]" = 1
--source include/assert.inc

# Check-9: ANALYZE TABLE
--echo #
--echo # The ANALYZE TABLE statement can be failed partially when analyzingu
--echo # multiple tables, which contain a non-existent table.
--echo #
--replace_result $master_uuid MASTER_UUID
--eval SET SESSION GTID_NEXT='$master_uuid:8'
ANALYZE TABLE t1, t_non_existent;
--echo #
--echo # When analyzing a non-existent table, verify that the ANALYZE TABLE
--echo # statement saves its specified gtid into @@GLOBAL.GTID_EXECUTED and
--echo # mysql.gtid_executed table when binlog is disabled as it did
--echo # when binlog is enabled.
--echo #
--replace_result $master_uuid MASTER_UUID
--let $assert_text= Committed gtid MASTER_UUID:8 into @@GLOBAL.GTID_EXECUTED
--let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$master_uuid:1-8"
--source include/assert.inc
--eval SET SESSION GTID_NEXT='AUTOMATIC'
FLUSH LOGS;
--let $assert_text= Saved gtid MASTER_UUID:8 into mysql.gtid_executed table
--let $assert_cond= "[SELECT COUNT(*) FROM mysql.gtid_executed WHERE interval_end = 8]" = 1
--source include/assert.inc

# Check-10: REPAIR TABLE
--echo #
--echo # The REPAIR TABLE statement can be failed partially when repairing
--echo # multiple tables, which contain a non-existent table.
--echo #
--replace_result $master_uuid MASTER_UUID
--eval SET SESSION GTID_NEXT='$master_uuid:9'
REPAIR TABLE t1, t_non_existent;
--echo #
--echo # When repairing a non-existent table, verify that the REPAIR TABLE
--echo # statement saves its specified gtid into @@GLOBAL.GTID_EXECUTED and
--echo # mysql.gtid_executed table when binlog is disabled as it did
--echo # when binlog is enabled.
--echo #
--replace_result $master_uuid MASTER_UUID
--let $assert_text= Committed gtid MASTER_UUID:9 into @@GLOBAL.GTID_EXECUTED
--let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$master_uuid:1-9"
--source include/assert.inc
--eval SET SESSION GTID_NEXT='AUTOMATIC'
FLUSH LOGS;
--let $assert_text= Saved gtid MASTER_UUID:9 into mysql.gtid_executed table
--let $assert_cond= "[SELECT COUNT(*) FROM mysql.gtid_executed WHERE interval_end = 9]" = 1
--source include/assert.inc

# Check-11: CHECKSUM TABLE
--echo #
--echo # The CHECKSUM TABLE statement can be failed partially when checksuming
--echo # multiple tables, which contain a non-existent table.
--echo #
--replace_result $master_uuid MASTER_UUID
--eval SET SESSION GTID_NEXT='$master_uuid:10'
CHECKSUM TABLE t1, t_non_existent;
--echo #
--echo # When checksuming a non-existent table, verify that the CHECKSUM TABLE
--echo # statement does not save its specified gtid into @@GLOBAL.GTID_EXECUTED
--echo # and mysql.gtid_executed table when binlog is disabled as it did
--echo # when binlog is enabled.
--echo #
--replace_result $master_uuid MASTER_UUID
--let $assert_text= Did not commit gtid MASTER_UUID:10 into @@GLOBAL.GTID_EXECUTED
--let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$master_uuid:1-9"
--source include/assert.inc
--eval SET SESSION GTID_NEXT='AUTOMATIC'
FLUSH LOGS;
--let $assert_text= Did not save gtid MASTER_UUID:10 into mysql.gtid_executed table
--let $assert_cond= "[SELECT COUNT(*) FROM mysql.gtid_executed WHERE interval_end = 10]" = 0
--source include/assert.inc

# Check-12: RENAME USER
--replace_result $master_uuid MASTER_UUID
--eval SET SESSION GTID_NEXT='$master_uuid:11'
--error ER_CANNOT_USER
RENAME USER u1@h TO u11@h, u3@h TO u33@h;
--echo #
--echo # The u1 is not renamed on mysql.user which means that RENAME USER
--echo # cannot be failed partially.
--echo #
SELECT user FROM mysql.user where user='u1';
--echo #
--echo # Verify that the failed RENAME USER statement does not save
--echo # the specified gtid into @@GLOBAL.GTID_EXECUTED and
--echo # mysql.gtid_executed table.
--echo #
--replace_result $master_uuid MASTER_UUID
--let $assert_text= Did not commit gtid MASTER_UUID:11 into @@GLOBAL.GTID_EXECUTED
--let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$master_uuid:1-9"
--source include/assert.inc
--eval SET SESSION GTID_NEXT='AUTOMATIC'
FLUSH LOGS;
--let $assert_text= Did not save gtid MASTER_UUID:11 and :12 into mysql.gtid_executed table
--let $assert_cond= "[SELECT COUNT(*) FROM mysql.gtid_executed WHERE interval_end = 11]" = 0
--source include/assert.inc

# Check-14: ALTER USER
SELECT password_expired FROM mysql.user where user='u1';
--replace_result $master_uuid MASTER_UUID
--eval SET SESSION GTID_NEXT='$master_uuid:13'
--error ER_CANNOT_USER
ALTER USER u1@h, u3@h PASSWORD EXPIRE;
--echo #
--echo # The u1 is not altered on mysql.user which means that ALTER USER
--echo # cannot be failed partially.
--echo #
SELECT password_expired FROM mysql.user where user='u1';
--echo #
--echo # Verify that the failed ALTER USER statement does not save
--echo # the specified gtid into @@GLOBAL.GTID_EXECUTED and
--echo # mysql.gtid_executed table.
--echo #
--replace_result $master_uuid MASTER_UUID
--let $assert_text= Did not commit gtid MASTER_UUID:13 into @@GLOBAL.GTID_EXECUTED
--let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$master_uuid:1-9"
--source include/assert.inc
--eval SET SESSION GTID_NEXT='AUTOMATIC'
FLUSH LOGS;
--let $assert_text= Did not save gtid MASTER_UUID:13 into mysql.gtid_executed table
--let $assert_cond= "[SELECT COUNT(*) FROM mysql.gtid_executed WHERE interval_end = 13]" = 0
--source include/assert.inc

# Clean up
--replace_result $master_uuid MASTER_UUID
--eval SET SESSION GTID_NEXT='$master_uuid:14'
DROP TABLE t1;
--replace_result $master_uuid MASTER_UUID
--eval SET SESSION GTID_NEXT='$master_uuid:15'
DROP TABLE t5;

--replace_result $master_uuid MASTER_UUID
--eval SET SESSION GTID_NEXT='$master_uuid:16'
DROP USER u1@h;