Skip to content

Commit 9bb16bb

Browse files
Merge pull request #5418 from satya-bodapati/PS-8.0-9306
PS-9306: MySQL 8.0.38, 8.4.1 and 9.0.0 crashes on restart if database…
2 parents 6e13886 + 7b4bee6 commit 9bb16bb

File tree

2 files changed

+139
-0
lines changed

2 files changed

+139
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#
2+
# PS-9306 : MySQL 8.0.38, 8.4.1 and 9.0.0 crashes on restart if database has 10K tables or more
3+
#
4+
CREATE DATABASE test_8k;
5+
CREATE PROCEDURE create_tables(start_index INT, end_index INT)
6+
BEGIN
7+
DECLARE i INT;
8+
SET i = start_index;
9+
WHILE i < end_index DO
10+
SET @table_name = CONCAT('table_', i);
11+
SET @create_stmt = CONCAT('CREATE TABLE IF NOT EXISTS test_8k.', @table_name, ' (id INT PRIMARY KEY AUTO_INCREMENT, data VARCHAR(255));');
12+
PREPARE stmt FROM @create_stmt;
13+
EXECUTE stmt;
14+
DEALLOCATE PREPARE stmt;
15+
SET i = i + 1;
16+
END WHILE;
17+
END|
18+
CALL create_tables(0*1024,(0+1)*1024);
19+
CALL create_tables(1*1024,(1+1)*1024);
20+
CALL create_tables(2*1024,(2+1)*1024);
21+
CALL create_tables(3*1024,(3+1)*1024);
22+
CALL create_tables(4*1024,(4+1)*1024);
23+
CALL create_tables(5*1024,(5+1)*1024);
24+
CALL create_tables(6*1024,(6+1)*1024);
25+
CALL create_tables(7*1024,(7+1)*1024);
26+
# restart
27+
CREATE PROCEDURE drop_tables(start_index INT, end_index INT)
28+
BEGIN
29+
DECLARE i INT;
30+
SET i = start_index;
31+
WHILE i < end_index DO
32+
SET @table_name = CONCAT('table_', i);
33+
SET @create_stmt = CONCAT('DROP TABLE test_8k.', @table_name, ';');
34+
PREPARE stmt FROM @create_stmt;
35+
EXECUTE stmt;
36+
DEALLOCATE PREPARE stmt;
37+
SET i = i + 1;
38+
END WHILE;
39+
END|
40+
CALL drop_tables(0*1024,(0+1)*1024);
41+
CALL drop_tables(1*1024,(1+1)*1024);
42+
CALL drop_tables(2*1024,(2+1)*1024);
43+
CALL drop_tables(3*1024,(3+1)*1024);
44+
CALL drop_tables(4*1024,(4+1)*1024);
45+
CALL drop_tables(5*1024,(5+1)*1024);
46+
CALL drop_tables(6*1024,(6+1)*1024);
47+
CALL drop_tables(7*1024,(7+1)*1024);
48+
DROP DATABASE test_8k;
49+
DROP PROCEDURE create_tables;
50+
DROP PROCEDURE drop_tables;
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
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

Comments
 (0)