File: rpl_gtid_drop_mem_table.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 (260 lines) | stat: -rw-r--r-- 9,866 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
#  ==== Purpose ====
#
# The purpose of this test is to verify that a TRUNCATE statement is binary
# logged with correct GTID when a replicated memory table is fisrt updated
# after a server crash or a server restart.
#
#  ==== Requirements ====
#
# R1. When there is a replicated memory table, and the slave crashes, the next
# transaction that updates the memory table shall generate a TRUNCATE statement
# in the binary log. This test verifies that this works in the below cases:

# R1.1. When the update is applied on a replication channel.
# R1.2. When the update is applied in a client session having
#       gtid_next=UUID:NUMBER.
#
# R2. The TRUNCATE statement shall have a new GTID generated by the slave.
#
# R3. There shall not be a crash.
#
# ==== Implementation ====
#
# 1. Try to update the memory table on master after restarting the master:
#
# 1.1. A DML on the memory table
# 1.2. A DDL on the memory table.
# 1.3. A statement that reads from the memory table.
# 1.4. A transaction containing update on the memory table along with other
#      table updates.
# 1.5. A statement containing update on the memory table along with other
#      table updates.
# 1.6. A DML on the memory table applied in a client session having
#      gtid_next=UUID:NUMBER.
#
# In each of the above cases:
# - Verify that TRUNCATE statement is binary logged on the master.
#
# 2. Try to update the memory table on master after restarting the slave:
#
# 2.1. A DML on the memory table
# 2.2. A DDL on the memory table.
# 2.3. A statement that reads from the memory table
# 2.4. A transaction containing update on the memory table along with other
#      table updates.
# 2.5. A statement containing update on the memory table along with other
#      table updates.
# 2.6. A DML on the memory table applied in a client session having
#      gtid_next=UUID:NUMBER.
#
# In each of the above cases:
# - Verify that TRUNCATE statement is binary logged on the slave.
#
# ==== References ====
#
# Bug#30527929 - RESTART CREATES ANONYMOUS TRANSACTION FOR MEMORY TABLE
#

--source include/not_rpl_gtid_only.inc
--source include/master-slave.inc

#Scenario 1
--source include/rpl_connection_master.inc
CREATE TABLE mem_t1 (c1 INT) ENGINE= MEMORY;
CREATE TABLE mem_t2 (c1 INT) ENGINE= MEMORY;
CREATE TABLE mem_t3 (c1 INT) ENGINE= MEMORY;
CREATE TABLE mem_t4 (c1 INT) ENGINE= MEMORY;
CREATE TABLE mem_t5 (c1 INT) ENGINE= MEMORY;
CREATE TABLE mem_t6 (c1 INT) ENGINE= MEMORY;
CREATE TABLE mem_t7 (c1 INT) ENGINE= MEMORY;
CREATE TABLE mem_t8 (c1 INT) ENGINE= MEMORY;
INSERT INTO mem_t1 VALUES (1), (2), (3), (4);
INSERT INTO mem_t2 VALUES (1), (2), (3), (4);
INSERT INTO mem_t3 VALUES (1), (2), (3), (4);
INSERT INTO mem_t4 VALUES (1), (2), (3), (4);
INSERT INTO mem_t5 VALUES (1), (2), (3), (4);
INSERT INTO mem_t6 VALUES (1), (2), (3), (4);
INSERT INTO mem_t7 VALUES (1), (2), (3), (4);
INSERT INTO mem_t8 VALUES (1), (2), (3), (4);
--source include/sync_slave_sql_with_master.inc

# Restart master
--source include/stop_slave.inc
--let $rpl_server_number=1
--source include/rpl_restart_server.inc
--source include/start_slave.inc
--source include/rpl_connection_master.inc
--source include/save_binlog_position.inc

# Scenario 1.1
INSERT INTO mem_t1 VALUES (1), (2), (3), (4);
--source include/sync_slave_sql_with_master.inc
--source include/rpl_connection_master.inc
--let $limit= 0,7
--let $event_sequence= #Gtid # !Q(TRUNCATE.*) #Gtid # !Begin # !Insert # !Commit
--source include/assert_binlog_events.inc
--source include/save_binlog_position.inc

# Scenario 1.2
ALTER TABLE mem_t2 ADD COLUMN (c2 INT);
--source include/sync_slave_sql_with_master.inc
--source include/rpl_connection_master.inc
--let $limit= 0,4
--let $event_sequence= #Gtid # !Q(TRUNCATE.*) #Gtid # !Q(ALTER.*)
--source include/assert_binlog_events.inc
--source include/save_binlog_position.inc

# Scenario 1.3
CREATE TABLE mem_t9 LIKE mem_t3;
--source include/sync_slave_sql_with_master.inc
--source include/rpl_connection_master.inc
--let $limit= 0,4
--let $event_sequence= #Gtid # !Q(TRUNCATE.*) #Gtid # !Q(CREATE.*)
--source include/assert_binlog_events.inc
--source include/save_binlog_position.inc

# Scenario 1.4:
BEGIN;
INSERT INTO mem_t4 VALUES (1), (2), (3), (4);
INSERT INTO mem_t5 VALUES (1), (2), (3), (4);
COMMIT;
--source include/sync_slave_sql_with_master.inc
--source include/rpl_connection_master.inc
--let $limit= 0,14
--let $event_sequence= #Gtid # !Q(TRUNCATE.*) #Gtid # !Begin # !Insert # !Commit #Gtid # !Q(TRUNCATE.*) #Gtid # !Begin # !Insert # !Commit
--source include/assert_binlog_events.inc
--source include/save_binlog_position.inc

# Scenario 1.5:
UPDATE mem_t6, mem_t7 SET mem_t6.c1 = mem_t6.c1 + 1, mem_t7.c1 = mem_t7.c1 + 1;
--source include/sync_slave_sql_with_master.inc
--source include/rpl_connection_master.inc
--let $limit= 0,4
--let $event_sequence= #Gtid # !Q(TRUNCATE.*) #Gtid # !Q(TRUNCATE.*)
--source include/assert_binlog_events.inc
--source include/save_binlog_position.inc

#Scenario 1.6:
--let $explicit_gtid=aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:1
--eval SET @@session.gtid_next = '$explicit_gtid'
INSERT INTO mem_t8 VALUES (1), (2), (3), (4);
SET @@session.gtid_next = 'AUTOMATIC';
--source include/sync_slave_sql_with_master.inc
--source include/rpl_connection_master.inc
--let $limit= 0,7
--let $event_sequence= #Gtid # !Q(TRUNCATE.*) #Gtid/(.*'$explicit_gtid')# !Begin # !Insert # !Commit
--source include/assert_binlog_events.inc

# Cleanup
DROP TABLE mem_t1, mem_t2, mem_t3, mem_t4, mem_t5, mem_t6, mem_t7, mem_t8, mem_t9;
--source include/rpl_reset.inc

# Scenario 2:
--source include/rpl_connection_master.inc
CREATE TABLE mem_t1 (c1 INT) ENGINE= MEMORY;
CREATE TABLE mem_t2 (c1 INT) ENGINE= MEMORY;
CREATE TABLE mem_t3 (c1 INT) ENGINE= MEMORY;
CREATE TABLE mem_t4 (c1 INT) ENGINE= MEMORY;
CREATE TABLE mem_t5 (c1 INT) ENGINE= MEMORY;
CREATE TABLE mem_t6 (c1 INT) ENGINE= MEMORY;
CREATE TABLE mem_t7 (c1 INT) ENGINE= MEMORY;
CREATE TABLE mem_t8 (c1 INT) ENGINE= MEMORY;
INSERT INTO mem_t1 VALUES (1), (2), (3), (4);
INSERT INTO mem_t2 VALUES (1), (2), (3), (4);
INSERT INTO mem_t3 VALUES (1), (2), (3), (4);
INSERT INTO mem_t4 VALUES (1), (2), (3), (4);
INSERT INTO mem_t5 VALUES (1), (2), (3), (4);
INSERT INTO mem_t6 VALUES (1), (2), (3), (4);
INSERT INTO mem_t7 VALUES (1), (2), (3), (4);
INSERT INTO mem_t8 VALUES (1), (2), (3), (4);
--source include/sync_slave_sql_with_master.inc

# Restart slave
--let $rpl_server_number=2
--source include/rpl_restart_server.inc
--source include/start_slave.inc
--source include/save_binlog_position.inc

# Save the UUID of master and slave
--source include/rpl_connection_master.inc
--let $master_uuid = `SELECT @@global.server_uuid`
--source include/rpl_connection_slave.inc
--let $replica_uuid = `SELECT @@global.server_uuid`
--let $dont_print_pattern = 1

# Scenario 2.1
--source include/rpl_connection_master.inc
INSERT INTO mem_t1 VALUES (1), (2), (3), (4);
--source include/sync_slave_sql_with_master.inc
--source include/rpl_connection_slave.inc
--let $limit= 0,7
--let $event_sequence= #Gtid/(.*'$replica_uuid:1') # !Q(TRUNCATE.*) #Gtid/(.*'$master_uuid:17') # !Begin # !Insert # !Commit
--source include/assert_binlog_events.inc
--source include/save_binlog_position.inc

# Scenario 2.2
--source include/rpl_connection_master.inc
ALTER TABLE mem_t2 ADD COLUMN (c2 INT);
--source include/sync_slave_sql_with_master.inc
--source include/rpl_connection_slave.inc
--let $limit= 0,4
--let $event_sequence= #Gtid/(.*'$replica_uuid:2') # !Q(TRUNCATE.*) #Gtid/(.*'$master_uuid:18') # !Q(ALTER.*)
--source include/assert_binlog_events.inc
--source include/save_binlog_position.inc

# Scenario 2.3
--source include/rpl_connection_master.inc
CREATE TABLE mem_t9 LIKE mem_t3;
--source include/sync_slave_sql_with_master.inc
--source include/rpl_connection_slave.inc
--let $limit= 0,4
--let $event_sequence= #Gtid/(.*'$replica_uuid:3') # !Q(TRUNCATE.*) #Gtid/(.*'$master_uuid:19') # !Q(CREATE.*)
--source include/assert_binlog_events.inc
--source include/save_binlog_position.inc

# Scenario 2.4:
--source include/rpl_connection_master.inc
BEGIN;
INSERT INTO mem_t4 VALUES (1), (2), (3), (4);
INSERT INTO mem_t5 VALUES (1), (2), (3), (4);
COMMIT;
--source include/sync_slave_sql_with_master.inc
--source include/rpl_connection_slave.inc
--let $limit= 0,14
--let $event_sequence= #Gtid/(.*'$replica_uuid:4') # !Q(TRUNCATE.*) #Gtid/(.*'$master_uuid:20') # !Begin # !Insert # !Commit #Gtid/(.*'$replica_uuid:5') # !Q(TRUNCATE.*) #Gtid/(.*'$master_uuid:21') # !Begin # !Insert # !Commit
--source include/assert_binlog_events.inc
--source include/save_binlog_position.inc

# Scenario 2.5:
--source include/rpl_connection_master.inc
DELIMITER |;
CREATE FUNCTION f () RETURNS INT BEGIN
INSERT INTO mem_t6 VALUES (1);
RETURN 2;
END|
DELIMITER ;|
INSERT INTO mem_t7 VALUES (f());
--source include/sync_slave_sql_with_master.inc
--source include/rpl_connection_slave.inc
--let $limit= 2,12
--let $event_sequence= #Gtid/(.*'$replica_uuid:6') # !Q(TRUNCATE.*) #Gtid/(.*'$replica_uuid:7') # !Q(TRUNCATE.*) #Gtid/(.*'$master_uuid:23') # !Begin # !Multi_DML # !Commit
--source include/assert_binlog_events.inc
--source include/save_binlog_position.inc

#Scenario 2.6:
--source include/rpl_connection_master.inc
--eval SET @@session.gtid_next = '$explicit_gtid'
INSERT INTO mem_t8 VALUES (1), (2), (3), (4);
SET @@session.gtid_next = 'AUTOMATIC';
--source include/sync_slave_sql_with_master.inc
--source include/rpl_connection_slave.inc
--let $limit= 0,7
--let $event_sequence= #Gtid/(.*'$replica_uuid:8') # !Q(TRUNCATE.*) #Gtid/(.*'$explicit_gtid')# !Begin # !Insert # !Commit
--source include/assert_binlog_events.inc

# Cleanup
--source include/rpl_connection_master.inc
DROP FUNCTION f;
DROP TABLE mem_t1, mem_t2, mem_t3, mem_t4, mem_t5, mem_t6, mem_t7, mem_t8, mem_t9;
--let $dont_print_pattern = 0
--source include/rpl_end.inc