File: innodb_autoextend_dml_1.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-- 8,360 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
# Disable in valgrind because of timeout
--source include/big_test.inc
--source include/not_valgrind.inc
--source include/have_innodb_16k.inc
--source include/have_debug.inc
--source include/not_crashrep.inc

--echo #
--echo # This test tests various DML operations and their effect on the tablespaces
--echo #

--echo # Test tables with file_per_table tablespace

--echo #
--echo # Scenario-1: Create a table without autoextend_size and validate that the allocation
--echo # happens as per the old logic
--echo #

CREATE TABLE t1 (c1 INT, c2 TEXT);

--echo # Verify the initial size of the file
SELECT NAME, FILE_SIZE, AUTOEXTEND_SIZE FROM information_schema.innodb_tablespaces
    WHERE NAME LIKE '%t1%';

--echo # This is a smaller tablespace. The tablespace should extend by adding smaller number
--echo # of pages initially

--echo # Add few rows to the table and check the size of the file
let $row_count = 1;
let $table_name = t1;
--source suite/innodb/include/innodb_autoextend_dml.inc

select count(*) from t1;

SELECT NAME, FILE_SIZE, AUTOEXTEND_SIZE FROM information_schema.innodb_tablespaces
    WHERE NAME LIKE '%t1%';

let $row_count = 1;
let $table_name = t1;
--source suite/innodb/include/innodb_autoextend_dml.inc

select count(*) from t1;
SELECT NAME, FILE_SIZE, AUTOEXTEND_SIZE FROM information_schema.innodb_tablespaces
    WHERE NAME LIKE '%t1%';

let $row_count = 1;
let $table_name = t1;
--source suite/innodb/include/innodb_autoextend_dml.inc

select count(*) from t1;
SELECT NAME, FILE_SIZE, AUTOEXTEND_SIZE FROM information_schema.innodb_tablespaces
    WHERE NAME LIKE '%t1%';

--echo # Once the tablespace size is more than half of the extent size, tablespace is extended with
--echo # 4 extents at a time
let $row_count = 7;
let $table_name = t1;
--source suite/innodb/include/innodb_autoextend_dml.inc

select count(*) from t1;
SELECT NAME, FILE_SIZE, AUTOEXTEND_SIZE FROM information_schema.innodb_tablespaces
    WHERE NAME LIKE '%t1%';

drop table t1;

--echo #
--echo # Scenario-2: Create table with autoextend_size clause and validate that the allocation happens as per the
--echo # new logic and the initial size of the tablespace file is the value of AUTOEXTEND_SIZE
--echo #
CREATE TABLE t2(c1 INT, c2 TEXT) AUTOEXTEND_SIZE 4M;
let $row_count = 10;
let $table_name = t2;
--source suite/innodb/include/innodb_autoextend_dml.inc
select count(*) from t2;
SELECT NAME, FILE_SIZE, AUTOEXTEND_SIZE FROM information_schema.innodb_tablespaces
    WHERE NAME LIKE '%t2%';

let $row_count = 10;
let $table_name = t2;
--source suite/innodb/include/innodb_autoextend_dml.inc
select count(*) from t2;
SELECT NAME, FILE_SIZE, AUTOEXTEND_SIZE FROM information_schema.innodb_tablespaces
    WHERE NAME LIKE '%t2%';

let $row_count = 1000;
let $table_name = t2;
--source suite/innodb/include/innodb_autoextend_dml.inc
select count(*) from t2;
SELECT NAME, FILE_SIZE, AUTOEXTEND_SIZE FROM information_schema.innodb_tablespaces
    WHERE NAME LIKE '%t2%';

let $row_count = 1000;
let $table_name = t2;
--source suite/innodb/include/innodb_autoextend_dml.inc
select count(*) from t2;
SELECT NAME, FILE_SIZE, AUTOEXTEND_SIZE FROM information_schema.innodb_tablespaces
    WHERE NAME LIKE '%t2%';

DROP TABLE t2;

--echo #
--echo # Scenario-3: Create a table without autoextend_size and alter it later on to add autoextend_size property
--echo # Validate that the allocation is done with the old logic until autoextend_size is introduced to the table
--echo #
CREATE TABLE t3(c1 INT, c2 TEXT);
SELECT NAME, FILE_SIZE, AUTOEXTEND_SIZE FROM information_schema.innodb_tablespaces
    WHERE NAME LIKE '%t3%';

let $row_count = 1;
let $table_name = t3;
--source suite/innodb/include/innodb_autoextend_dml.inc
SELECT COUNT(*) FROM t3;
SELECT NAME, FILE_SIZE, AUTOEXTEND_SIZE FROM information_schema.innodb_tablespaces
    WHERE NAME LIKE '%t3%';

ALTER TABLE t3 AUTOEXTEND_SIZE 4M;
let $row_count = 1;
let $table_name = t3;
--source suite/innodb/include/innodb_autoextend_dml.inc
SELECT COUNT(*) FROM t3;
SELECT NAME, FILE_SIZE, AUTOEXTEND_SIZE FROM information_schema.innodb_tablespaces
    WHERE NAME LIKE '%t3%';

DROP TABLE t3;

--echo #
--echo # Scenario-4: Test crash recovery and verify that the autoextend_size values are reinstated
--echo # after recovery
--echo #
CREATE TABLE t4(c1 INT, c2 longblob) AUTOEXTEND_SIZE 8m;

--echo # The initialize size of the table should be same as the autoextend_size
SELECT NAME, FILE_SIZE/AUTOEXTEND_SIZE, FILE_SIZE, AUTOEXTEND_SIZE FROM information_schema.innodb_tablespaces
    WHERE NAME LIKE '%t4%';

--echo # Crash the server while attempting to allocate more space
INSERT INTO t4 VALUES (1, repeat(1, 4 * 1024 * 1024));

--source include/expect_crash.inc
SET DEBUG="+d, fsp_crash_before_space_extend";
--error 2013
INSERT INTO t4 VALUES (1, repeat(1, 4 * 1024 * 1024));

--echo # Restart mysqld after the crash and reconnect
--source include/start_mysqld.inc

# Verify the current size of the tablespace
SELECT NAME, FILE_SIZE/AUTOEXTEND_SIZE, FILE_SIZE, AUTOEXTEND_SIZE FROM information_schema.innodb_tablespaces
   WHERE NAME LIKE '%t4%';

# Insert another row and verify that the space has been extended by the autoextend_size value
INSERT INTO t4 VALUES (1, repeat(1, 4 * 1024 * 1024));
SELECT COUNT(*) FROM t4;

--echo # Verify new file size is a multiple of autoextend_size
SELECT NAME, FILE_SIZE/AUTOEXTEND_SIZE, FILE_SIZE, AUTOEXTEND_SIZE FROM information_schema.innodb_tablespaces
   WHERE NAME LIKE '%t4%';

DROP TABLE t4;

--echo #
--echo # Scenario-5: Test crash recovery when server is started with --skip-innodb-validate-tablespace-paths
--echo # option and verify that the server respects the autoextend_size value
--echo #
CREATE TABLE t5(c1 INT, c2 longblob) AUTOEXTEND_SIZE 8m;

--echo # The initialize size of the table should be same as the autoextend_size
SELECT NAME, FILE_SIZE/AUTOEXTEND_SIZE, FILE_SIZE, AUTOEXTEND_SIZE FROM information_schema.innodb_tablespaces
    WHERE NAME LIKE '%t5%';

--echo # Crash the server while attempting to allocate more space
INSERT INTO t5 VALUES (1, repeat(1, 4 * 1024 * 1024));

SET DEBUG="+d, fsp_crash_before_space_extend";

--source include/expect_crash.inc

--error 2013
INSERT INTO t5 VALUES (1, repeat(1, 4 * 1024 * 1024));

--echo # Restart mysqld with --skip-innodb-validate-tablespace-paths option after
--echo # the crash and reconnect
--let $restart_parameters = restart: --skip-innodb-validate-tablespace-paths
--source include/start_mysqld.inc

# Verify the current size of the tablespace
SELECT NAME, FILE_SIZE/AUTOEXTEND_SIZE, FILE_SIZE, AUTOEXTEND_SIZE FROM information_schema.innodb_tablespaces
   WHERE NAME LIKE '%t5%';

# Insert another row and verify that the space has been extended by the autoextend_size value
INSERT INTO t5 VALUES (1, repeat(1, 4 * 1024 * 1024));
SELECT COUNT(*) FROM t5;

--echo # Verify new file size is a multiple of autoextend_size
SELECT NAME, FILE_SIZE/AUTOEXTEND_SIZE, FILE_SIZE, AUTOEXTEND_SIZE FROM information_schema.innodb_tablespaces
   WHERE NAME LIKE '%t5%';

DROP TABLE t5;

# Restart the server without --skip-innodb-validate-tablespace-paths option
--let $restart_parameters =
--source include/restart_mysqld.inc

--echo #
--echo # Scenario-6: Test concurrent updates to autoextend_size while inserts are going on
--echo # on another connection
--echo #

CREATE TABLE t6(id int, l longblob, v varchar(100)) AUTOEXTEND_SIZE 4m;

delimiter |;
CREATE PROCEDURE update_aes()
BEGIN
  DECLARE i INT DEFAULT 0;
  WHILE i < 1000 DO
    ALTER TABLE t6 AUTOEXTEND_SIZE=4m;
    ALTER TABLE t6 AUTOEXTEND_SIZE=64m;
    ALTER TABLE t6 AUTOEXTEND_SIZE=16m;
    ALTER TABLE t6 AUTOEXTEND_SIZE=8m;
    ALTER TABLE t6 AUTOEXTEND_SIZE=32m;
    SET i = i + 1;
  END WHILE;
END |

CREATE PROCEDURE insert_data()
BEGIN
  DECLARE i INT DEFAULT 0;
  WHILE i < 10000 DO
    INSERT INTO t6 (l) VALUES (repeat(2, 1024 * 16));
    SET i = i + 1;
  END WHILE;
END |
delimiter ;|

# Create concurrent connections
connect (conn1, localhost, root,,);
connect (conn2, localhost, root,,);

# Connect to connection 1
--connection conn1

--send CALL insert_data();

# Connect to connection 2
--connection conn2
CALL update_aes();

--connection conn1
--reap

--connection default
--disconnect conn1
--disconnect conn2

SELECT COUNT(*) FROM t6;

DROP TABLE t6;

DROP PROCEDURE insert_data;
DROP PROCEDURE update_aes;