Debian Codegraph @

mysql-test/suite/innodb/t/ibuf_sys_tablespace_extend.test

raw
1 # Bug#36511673 MLOG_FILE_EXTEND log record is not redo logged for System
2 # tablespace
3 # Change buffer persists in the system tablespace. System tablespace size
4 # may expand beyond the default size when then change buffer grows. This
5 # test verifies that System tablespace expansion is redo logged and,
6 # crash recovery works.
7
8 --source include/big_test.inc
9 --source include/linux.inc
10 --source include/have_debug.inc
11 --source include/have_innodb_16k.inc
12 --source include/count_sessions.inc
13
14 let $MYSQLD_DATADIR = $MYSQL_TMP_DIR/test_data_dir;
15 let $MYSQLD_ERROR_LOG = $MYSQL_TMP_DIR/mysqld_test.err;
16
17 # It is pre-requisite of this test to have system tablespace of default size.
18 # It is possible only if test explicitly creates the new datadir for the
19 # stability (e.g. runing with --repeat option) reasons.
20 --echo # Initialize new data directory...
21 let $MYSQLD_EXTRA_ARGS = --innodb_page_size=16384 --datadir=$MYSQLD_DATADIR --log-error=$MYSQLD_ERROR_LOG;
22 --source include/initialize_datadir.inc
23 let restart_parameters = restart: --datadir=$MYSQLD_DATADIR --log-error=$MYSQLD_ERROR_LOG --log_error_verbosity=2;
24
25 --echo # Restart on the new data directory...
26 --replace_result $MYSQLD_ERROR_LOG my_restart.err $MYSQLD_DATADIR tmp/test_data_dir
27 --source include/restart_mysqld.inc
28
29 SET GLOBAL innodb_redo_log_capacity=52428800;
30
31 SET GLOBAL innodb_change_buffering=all;
32 SET GLOBAL innodb_change_buffer_max_size=50;
33 # The flag that instructs InnoDB to try to evict pages from the
34 # buffer pool when change buffering is possible, so that the change
35 # buffer will be used whenever possible.
36 SET GLOBAL innodb_change_buffering_debug = 1;
37 # Disable merging the changes from change buffer to the indexes
38 SET GLOBAL innodb_disable_background_merge=ON;
39
40 SET GLOBAL DEBUG='+d,ib_redo_log_system_tablespace_expansion';
41
42 let $inital_file_size= `SELECT
43 ROUND(SUM(TOTAL_EXTENTS * EXTENT_SIZE)/1024/1024) AS tablespace_size_in_MB
44 FROM
45 information_schema.FILES
46 WHERE
47 TABLESPACE_NAME = 'innodb_system'
48 GROUP BY
49 TABLESPACE_NAME, FILE_NAME`;
50
51 CREATE DATABASE db1;
52
53 --disable_query_log
54
55 --DELIMITER //
56
57 CREATE PROCEDURE db1.CreateNTables(IN dbName VARCHAR(255),
58 IN tableNamePrefix VARCHAR(255), IN COUNT INT)
59 BEGIN
60 DECLARE i INT DEFAULT 1;
61 DECLARE fullTableName VARCHAR(255);
62
63 WHILE i <= COUNT DO
64 SET fullTableName := CONCAT(dbName, '.', tableNamePrefix, i);
65 -- Create table
66 SET @sql := CONCAT(
67 'CREATE TABLE ', fullTableName, ' (',
68 '`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,',
69 '`k` BIGINT UNSIGNED NOT NULL DEFAULT ''0'',',
70 '`nk` INT NOT NULL DEFAULT ''0'',',
71 '`c` VARCHAR(2048),',
72 '`pad` VARCHAR(2048),',
73 'PRIMARY KEY (`id`),',
74 'KEY `idx_k` (`k`),',
75 'KEY `idx_knk` (`nk`, `k`),',
76 'KEY `idx_nk` (`nk`),',
77 'KEY `idx_c` (`c`(512)),',
78 'KEY `idx_pad` (`pad`(512))',
79 ') ENGINE=InnoDB ',
80 'DEFAULT CHARSET=ascii COLLATE=ascii_bin;'
81 );
82 PREPARE stmt FROM @sql;
83 EXECUTE stmt;
84 DEALLOCATE PREPARE stmt;
85 SET i = i + 1;
86 END WHILE;
87 END //
88
89
90 CREATE PROCEDURE db1.InsertIntoRecords (IN schemaName VARCHAR(255),
91 IN tableName VARCHAR(255), IN two_to_power INT)
92 BEGIN
93 DECLARE fullTableName VARCHAR(255);
94 SET fullTableName := CONCAT(schemaName, '.', tableName);
95 SET @stm := CONCAT('INSERT INTO ', fullTableName , ' (k, nk, c, pad)',
96 ' SELECT 2000, nk, c, pad FROM db1.t1');
97 PREPARE stmt FROM @stm;
98 SET @idx := two_to_power;
99 WHILE (@idx > 0) DO
100 EXECUTE stmt;
101 SET @idx := @idx - 1;
102 END WHILE;
103 DEALLOCATE PREPARE stmt;
104 END //
105
106 --DELIMITER ;
107
108 --enable_query_log
109 let $max_connections=2;
110 --echo # Create $max_connections tables
111 eval CALL db1.CreateNTables('db1', 't', $max_connections);
112
113 --echo
114 --echo # Create Connection objects
115 let $counter = 1;
116 while($counter <= $max_connections){
117 connect (con_$counter, localhost, root,,);
118 inc $counter;
119 }
120
121 --echo
122 --echo # Insert record in each table
123 let $counter = 1;
124 while($counter <= $max_connections){
125 connection con_$counter;
126 send_eval INSERT INTO db1.t$counter
127 VALUES(0, 1000 , 1, REPEAT('a', 2048), REPEAT('b', 2048));
128 inc $counter;
129 }
130
131 --echo # Wait for inserts to finish
132 let $counter = 1;
133 while($counter <= $max_connections){
134 connection con_$counter;
135 reap;
136 inc $counter;
137 }
138
139 --echo
140 --echo # Insert total 2^8 records in each table
141 let $counter = 1;
142 while($counter <= $max_connections){
143 connection con_$counter;
144 send_eval CALL db1.InsertIntoRecords('db1', 't$counter', 8);
145 inc $counter;
146 }
147
148 --echo
149 --echo # Wait for insert into tables to finish
150 let $counter = 1;
151 while($counter <= $max_connections){
152 connection con_$counter;
153 reap;
154 inc $counter;
155 }
156
157 connection default;
158 --echo # Disable page cleaner to have redo logs for recovery later on
159 --source suite/innodb/include/log_disable_page_cleaners.inc
160
161 # Update the records with id divisible by 2
162 let $counter = 1;
163 while($counter <= $max_connections){
164 connection con_$counter;
165 send_eval UPDATE db1.t$counter
166 SET k = id + k , nk = k + id, c = REPEAT('a2', 512),
167 pad = REPEAT('b2', 512)
168 WHERE id % 2 = 0;
169 inc $counter;
170 }
171
172 --echo
173 --echo # Wait for Updates to finish
174 let $counter = 1;
175 while($counter <= $max_connections){
176 connection con_$counter;
177 reap;
178 inc $counter;
179 }
180
181 # Update the records with id divisible by 3
182 let $counter = 1;
183 while($counter <= $max_connections){
184 connection con_$counter;
185 send_eval UPDATE db1.t$counter
186 SET k = id + k , nk = k + id, c = REPEAT('a3', 512),
187 pad = REPEAT('b3', 512)
188 WHERE id % 3 = 0;
189 inc $counter;
190 }
191
192 --echo
193 --echo # Wait for Updates to finish
194 let $counter = 1;
195 while($counter <= $max_connections){
196 connection con_$counter;
197 reap;
198 inc $counter;
199 }
200
201 # Update the records with id divisible by 5
202 let $counter = 1;
203 while($counter <= $max_connections){
204 connection con_$counter;
205 send_eval UPDATE db1.t$counter
206 SET k = id + k , nk = k + id, c = REPEAT('a5', 512),
207 pad = REPEAT('b5', 512)
208 WHERE id % 5 = 0;
209 inc $counter;
210 }
211
212 --echo
213 --echo # Wait for Updates to finish
214 let $counter = 1;
215 while($counter <= $max_connections){
216 connection con_$counter;
217 reap;
218 inc $counter;
219 }
220
221 --echo
222 --echo # Delete records
223 let $counter = 1;
224 while($counter <= $max_connections){
225 connection con_$counter;
226 send_eval DELETE FROM db1.t$counter WHERE id % 4 = 1 ORDER BY id;
227 inc $counter;
228 }
229
230 --echo
231 --echo # Wait for Deletes to finish #1
232 let $counter = 1;
233 while($counter <= $max_connections){
234 connection con_$counter;
235 reap;
236 inc $counter;
237 }
238
239 connection default;
240
241 --file_exists $MYSQLD_ERROR_LOG
242 --let SEARCH_FILE=$MYSQLD_ERROR_LOG
243 --let SEARCH_PATTERN=System tablespace expansion is redo logged
244 --source include/search_pattern.inc
245
246 let $file_size_now = `SELECT
247 ROUND(SUM(TOTAL_EXTENTS * EXTENT_SIZE)/1024/1024) AS tablespace_size_in_MB
248 FROM
249 information_schema.FILES
250 WHERE
251 TABLESPACE_NAME = 'innodb_system'
252 GROUP BY
253 TABLESPACE_NAME, FILE_NAME`;
254
255 if($file_size_now == $inital_file_size ) {
256 --echo # Current file size=$file_size_now is same as initial file size=$inital_file_size.
257 --die "Test failed because system tablespace is not expanded"
258 }
259 SET GLOBAL DEBUG='-d,ib_redo_log_system_tablespace_expansion';
260
261 --echo # Verify no issues observed during crash recovery
262 --replace_result $MYSQLD_ERROR_LOG my_restart.err $MYSQLD_DATADIR tmp/test_data_dir
263 --source include/kill_and_restart_mysqld.inc
264 SELECT id, k FROM db1.t1 ORDER BY id LIMIT 1;
265
266 --echo
267 --echo # Cleanup
268 --echo
269 let restart_parameters = restart:;
270 --source include/kill_and_restart_mysqld.inc
271 --remove_file $MYSQLD_ERROR_LOG
272 --force-rmdir $MYSQLD_DATADIR
273
274 let $counter = 1;
275 while($counter <= $max_connections){
276 disconnect con_$counter;
277 inc $counter;
278 }
279 --source include/wait_until_count_sessions.inc