|
| 1 | +--echo # |
| 2 | +--echo # PS-9306 : MySQL 8.0.38, 8.4.1 and 9.0.0 crashes on restart if database has 10K tables or more |
| 3 | +--echo # |
| 4 | + |
| 5 | +CREATE DATABASE test_8k; |
| 6 | +--source include/count_sessions.inc |
| 7 | +--source include/big_test.inc |
| 8 | + |
| 9 | +DELIMITER |; |
| 10 | +CREATE PROCEDURE create_tables(start_index INT, end_index INT) |
| 11 | +BEGIN |
| 12 | + DECLARE i INT; |
| 13 | + SET i = start_index; |
| 14 | + WHILE i < end_index DO |
| 15 | + SET @table_name = CONCAT('table_', i); |
| 16 | + SET @create_stmt = CONCAT('CREATE TABLE IF NOT EXISTS test_8k.', @table_name, ' (id INT PRIMARY KEY AUTO_INCREMENT, data VARCHAR(255));'); |
| 17 | + PREPARE stmt FROM @create_stmt; |
| 18 | + EXECUTE stmt; |
| 19 | + DEALLOCATE PREPARE stmt; |
| 20 | + SET i = i + 1; |
| 21 | + END WHILE; |
| 22 | +END| |
| 23 | +DELIMITER ;| |
| 24 | + |
| 25 | +let $connections=8; |
| 26 | +let $i=0; |
| 27 | +while ($i < $connections) { |
| 28 | + --connect(C$i,localhost,root,,test) |
| 29 | + --send_eval CALL create_tables($i*1024,($i+1)*1024) |
| 30 | + inc $i; |
| 31 | +} |
| 32 | + |
| 33 | +let $i=0; |
| 34 | +while ($i < $connections) { |
| 35 | + --connection C$i |
| 36 | + reap; |
| 37 | + --disconnect C$i |
| 38 | + --source include/wait_until_disconnected.inc |
| 39 | + inc $i; |
| 40 | +} |
| 41 | +--connection default |
| 42 | +--source include/wait_until_count_sessions.inc |
| 43 | + |
| 44 | +--source include/restart_mysqld.inc |
| 45 | + |
| 46 | +--assert(`SELECT COUNT(*)=8192 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'test_8k'`) |
| 47 | + |
| 48 | +--source include/count_sessions.inc |
| 49 | + |
| 50 | +DELIMITER |; |
| 51 | +CREATE PROCEDURE drop_tables(start_index INT, end_index INT) |
| 52 | +BEGIN |
| 53 | + DECLARE i INT; |
| 54 | + SET i = start_index; |
| 55 | + WHILE i < end_index DO |
| 56 | + SET @table_name = CONCAT('table_', i); |
| 57 | + SET @create_stmt = CONCAT('DROP TABLE test_8k.', @table_name, ';'); |
| 58 | + PREPARE stmt FROM @create_stmt; |
| 59 | + EXECUTE stmt; |
| 60 | + DEALLOCATE PREPARE stmt; |
| 61 | + SET i = i + 1; |
| 62 | + END WHILE; |
| 63 | +END| |
| 64 | +DELIMITER ;| |
| 65 | + |
| 66 | +let $connections=8; |
| 67 | +let $i=0; |
| 68 | +while ($i < $connections) { |
| 69 | + --connect(C$i,localhost,root,,test) |
| 70 | + --send_eval CALL drop_tables($i*1024,($i+1)*1024) |
| 71 | + inc $i; |
| 72 | +} |
| 73 | + |
| 74 | +let $i=0; |
| 75 | +while ($i < $connections) { |
| 76 | + --connection C$i |
| 77 | + reap; |
| 78 | + --disconnect C$i |
| 79 | + --source include/wait_until_disconnected.inc |
| 80 | + inc $i; |
| 81 | +} |
| 82 | +--connection default |
| 83 | +--source include/wait_until_count_sessions.inc |
| 84 | + |
| 85 | +--assert(`SELECT COUNT(*)=0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'test_8k'`) |
| 86 | + |
| 87 | +DROP DATABASE test_8k; |
| 88 | +DROP PROCEDURE create_tables; |
| 89 | +DROP PROCEDURE drop_tables; |
0 commit comments