summaryrefslogtreecommitdiff
path: root/mysql-test/t/innodb_mysql_sync.test
blob: ec8fa55fc5c13e014bed3a6edb40500ed01dfadc (plain)
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
#
# Test file for InnoDB tests that require the debug sync facility
#
--source include/have_innodb.inc
--source include/have_debug.inc
--source include/have_debug_sync.inc
# Save the initial number of concurrent sessions.
--source include/count_sessions.inc


--echo #
--echo # Bug 42074 concurrent optimize table and 
--echo # alter table = Assertion failed: thd->is_error()
--echo #

--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings

--echo # Create InnoDB table
CREATE TABLE t1 (id INT) engine=innodb;
connect (con2, localhost, root);

--echo # Connection 1
--echo # Start optimizing table
connection default;
SET DEBUG_SYNC='ha_admin_try_alter SIGNAL optimize_started WAIT_FOR table_altered';
--send OPTIMIZE TABLE t1

--echo # Connection 2
--echo # Change table to engine=memory
connection con2;
SET DEBUG_SYNC='now WAIT_FOR optimize_started';
ALTER TABLE t1 engine=memory;
SET DEBUG_SYNC='now SIGNAL table_altered';

--echo # Connection 1
--echo # Complete optimization
connection default;
--reap

disconnect con2;
DROP TABLE t1;
SET DEBUG_SYNC='RESET';


--echo #
--echo # Bug#47459 Assertion in Diagnostics_area::set_eof_status on
--echo #           OPTIMIZE TABLE
--echo #

--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings

connect (con1, localhost, root);
connection default;

CREATE TABLE t1(a INT) ENGINE= InnoDB;

--echo # Connection con1
connection con1;
SET DEBUG_SYNC= "ha_admin_open_ltable SIGNAL opening WAIT_FOR dropped";
--echo # Sending:
--send OPTIMIZE TABLE t1

--echo # Connection default
connection default;
SET DEBUG_SYNC= "now WAIT_FOR opening";
DROP TABLE t1;
SET DEBUG_SYNC= "now SIGNAL dropped";

--echo # Connection con1
connection con1;
--echo # Reaping: OPTIMIZE TABLE t1
--reap

--echo # Connection default
connection default;
disconnect con1;
SET DEBUG_SYNC= "RESET";


--echo #
--echo # Bug#53757 assert in mysql_truncate_by_delete
--echo #

--disable_warnings
DROP TABLE IF EXISTS t1, t2;
--enable_warnings

CREATE TABLE t1(a INT) Engine=InnoDB;
CREATE TABLE t2(id INT);
INSERT INTO t1 VALUES (1), (2);

connect (con1, localhost, root);
INSERT INTO t2 VALUES(connection_id());
SET DEBUG_SYNC= "open_and_process_table SIGNAL opening WAIT_FOR killed";
--echo # Sending: (not reaped since connection is killed later)
--send TRUNCATE t1

connection default;
SET DEBUG_SYNC= "now WAIT_FOR opening";
SELECT ((@id := id) - id) FROM t2; 
KILL @id;
SET DEBUG_SYNC= "now SIGNAL killed";
DROP TABLE t1, t2;
disconnect con1;
--source include/wait_until_count_sessions.inc
SET DEBUG_SYNC= "RESET";


--echo #
--echo # Bug#58933 Assertion `thd- >is_error()' fails on shutdown with ongoing
--echo #           OPTIMIZE TABLE
--echo #

--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings

CREATE TABLE t1 (a INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1), (2);

--echo # Connection con1
connect (con1,localhost,root);
let $ID= `SELECT connection_id()`;
SET DEBUG_SYNC= 'ha_admin_open_ltable SIGNAL waiting WAIT_FOR killed';
--echo # Sending:
--send OPTIMIZE TABLE t1

--echo # Connection default
connection default;
SET DEBUG_SYNC= 'now WAIT_FOR waiting';
--replace_result $ID ID
eval KILL QUERY $ID;
SET DEBUG_SYNC= 'now SIGNAL killed';

--echo # Connection con1
connection con1;
--echo # Reaping: OPTIMIZE TABLE t1
--reap

--echo # Connection default
connection default;
DROP TABLE t1;
SET DEBUG_SYNC= 'RESET';
disconnect con1;


--echo #
--echo # Bug#42230 during add index, cannot do queries on storage engines
--echo #           that implement add_index
--echo #

--disable_warnings
DROP DATABASE IF EXISTS db1;
DROP TABLE IF EXISTS t1;
--enable_warnings

connect(con1,localhost,root);
connect(con2,localhost,root);

--echo # Test 1: Secondary index, should not block reads (original test case).

--echo # Connection default
connection default;
CREATE DATABASE db1;
CREATE TABLE db1.t1(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, value INT) engine=innodb;
INSERT INTO db1.t1(value) VALUES (1), (2);
SET DEBUG_SYNC= "alter_table_manage_keys SIGNAL manage WAIT_FOR query";
--echo # Sending:
--send ALTER TABLE db1.t1 ADD INDEX(value)

--echo # Connection con1
connection con1;
SET DEBUG_SYNC= "now WAIT_FOR manage";
# Neither of these two statements should be blocked
USE db1;
SELECT * FROM t1;
SET DEBUG_SYNC= "now SIGNAL query";

--echo # Connection default
connection default;
--echo # Reaping: ALTER TABLE db1.t1 ADD INDEX(value)
--reap
DROP DATABASE db1;

--echo # Test 2: Primary index (implicit), should block reads.

CREATE TABLE t1(a INT NOT NULL, b INT NOT NULL) engine=innodb;
SET DEBUG_SYNC= "alter_table_manage_keys SIGNAL manage WAIT_FOR query";
--echo # Sending:
--send ALTER TABLE t1 ADD UNIQUE INDEX(a)

--echo # Connection con1
connection con1;
SET DEBUG_SYNC= "now WAIT_FOR manage";
USE test;
--echo # Sending:
--send SELECT * FROM t1

--echo # Connection con2
connection con2;
--echo # Waiting for SELECT to be blocked by the metadata lock on t1
let $wait_condition= SELECT COUNT(*)= 1 FROM information_schema.processlist
  WHERE state= 'Waiting for table metadata lock'
  AND info='SELECT * FROM t1';
--source include/wait_condition.inc
SET DEBUG_SYNC= "now SIGNAL query";

--echo # Connection default
connection default;
--echo # Reaping: ALTER TABLE t1 ADD UNIQUE INDEX(a)
--reap

--echo # Connection con1
connection con1;
--echo # Reaping: SELECT * FROM t1
--reap

--echo # Test 3: Primary index (explicit), should block reads.

--echo # Connection default
connection default;
ALTER TABLE t1 DROP INDEX a;
SET DEBUG_SYNC= "alter_table_manage_keys SIGNAL manage WAIT_FOR query";
--echo # Sending:
--send ALTER TABLE t1 ADD PRIMARY KEY (a)

--echo # Connection con1
connection con1;
SET DEBUG_SYNC= "now WAIT_FOR manage";
--echo # Sending:
--send SELECT * FROM t1

--echo # Connection con2
connection con2;
--echo # Waiting for SELECT to be blocked by the metadata lock on t1
let $wait_condition= SELECT COUNT(*)= 1 FROM information_schema.processlist
  WHERE state= 'Waiting for table metadata lock'
  AND info='SELECT * FROM t1';
--source include/wait_condition.inc
SET DEBUG_SYNC= "now SIGNAL query";

--echo # Connection default
connection default;
--echo # Reaping: ALTER TABLE t1 ADD PRIMARY KEY (a)
--reap

--echo # Connection con1
connection con1;
--echo # Reaping: SELECT * FROM t1
--reap

--echo # Test 4: Secondary unique index, should not block reads.

--echo # Connection default
connection default;
SET DEBUG_SYNC= "alter_table_manage_keys SIGNAL manage WAIT_FOR query";
--echo # Sending:
--send ALTER TABLE t1 ADD UNIQUE (b)

--echo # Connection con1
connection con1;
SET DEBUG_SYNC= "now WAIT_FOR manage";
SELECT * FROM t1;
SET DEBUG_SYNC= "now SIGNAL query";

--echo # Connection default
connection default;
--echo # Reaping: ALTER TABLE t1 ADD UNIQUE (b)
--reap

disconnect con1;
disconnect con2;
SET DEBUG_SYNC= "RESET";
DROP TABLE t1;


--echo #
--echo # Bug#11853126 RE-ENABLE CONCURRENT READS WHILE CREATING SECONDARY INDEX
--echo #              IN INNODB
--echo #

--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings

CREATE TABLE t1(a INT NOT NULL, b INT NOT NULL) engine=innodb;
INSERT INTO t1 VALUES (1, 12345), (2, 23456);

--echo # Connection con1
--connect (con1,localhost,root)
SET SESSION debug= "+d,alter_table_rollback_new_index";
--error ER_UNKNOWN_ERROR
ALTER TABLE t1 ADD PRIMARY KEY(a);
SELECT * FROM t1;

--echo # Connection default
--connection default
SELECT * FROM t1;
DROP TABLE t1;
disconnect con1;


# Check that all connections opened by test cases in this file are really
# gone so execution of other tests won't be affected by their presence.
--source include/wait_until_count_sessions.inc