| 1 |
# Bug#3254121: MANY THREADS IN OS_EVENT, SYSTEM SLOWDOWN/HANG |
| 2 |
# This test verifies that the server does not slowdown/hang |
| 3 |
# while loading a tablespace while a large number of other |
| 4 |
# connections have opened more temporary tablespaces than |
| 5 |
# the variable inodb_open_files. |
| 6 |
|
| 7 |
SELECT @@innodb_thread_concurrency, @@innodb_open_files; |
| 8 |
# MTR limits number of connections to 128 only. |
| 9 |
--let $tables_count=50 |
| 10 |
--let $count_mtr=110 |
| 11 |
--let $count_exec=500 |
| 12 |
--let $num_table=0 |
| 13 |
|
| 14 |
# All the tablespaces except the undo tablespaces and system tablespaces are |
| 15 |
# added to a LRU list of size innodb_open_files. When this list if full |
| 16 |
# and a new file needs to be added to it, the oldest file is removed and closed |
| 17 |
# to make room for a new file. |
| 18 |
# The temporary tables used to be not added in the LRU list which could cause |
| 19 |
# server to hang with big number of connections. |
| 20 |
|
| 21 |
--echo # Create more tables than open file limit (which is 40) to fill up the |
| 22 |
--echo # LRU list. |
| 23 |
while($num_table < $tables_count){ |
| 24 |
--eval CREATE TABLE g$num_table(id INT PRIMARY KEY) ENGINE=INNODB |
| 25 |
--inc $num_table |
| 26 |
} |
| 27 |
|
| 28 |
--echo # Open $count_mtr connections and create a temporary table |
| 29 |
--echo # for each connection. |
| 30 |
--let $conn_count=0 |
| 31 |
while($conn_count < $count_mtr){ |
| 32 |
--connect (con$conn_count, localhost, root,,) |
| 33 |
CREATE TEMPORARY TABLE t1(id INT PRIMARY KEY) ENGINE=INNODB; |
| 34 |
INSERT INTO t1 VALUES (1); |
| 35 |
--inc $conn_count |
| 36 |
} |
| 37 |
|
| 38 |
--echo # Insert rows in tables using multiple connections. |
| 39 |
--let $conn_count=0 |
| 40 |
while($conn_count < $count_mtr){ |
| 41 |
--connection con$conn_count |
| 42 |
--send_eval INSERT INTO g0 VALUE ($conn_count) |
| 43 |
--inc $conn_count |
| 44 |
} |
| 45 |
|
| 46 |
--echo # Wait for the connections to finish inserting rows. |
| 47 |
--let $conn_count=0 |
| 48 |
while($conn_count < $count_mtr){ |
| 49 |
--connection con$conn_count |
| 50 |
--reap |
| 51 |
--inc $conn_count |
| 52 |
} |
| 53 |
|
| 54 |
--echo # Cleanup. |
| 55 |
--echo # Disconnect the connections. |
| 56 |
--connection default |
| 57 |
--let $conn_count=0 |
| 58 |
while($conn_count<$count_mtr){ |
| 59 |
--disconnect con$conn_count |
| 60 |
--inc $conn_count |
| 61 |
} |
| 62 |
|
| 63 |
CREATE TABLE connections_done(id INT PRIMARY KEY); |
| 64 |
|
| 65 |
--let $conn_count=0 |
| 66 |
while($conn_count < $count_exec){ |
| 67 |
--exec_in_background $MYSQL -e "USE test; CREATE TEMPORARY TABLE t1(id INT PRIMARY KEY) ENGINE=INNODB; INSERT INTO t1 VALUES (1); SELECT SLEEP(5); INSERT INTO connections_done VALUES ($conn_count);" |
| 68 |
--inc $conn_count |
| 69 |
} |
| 70 |
|
| 71 |
--let $wait_condition=SELECT COUNT(*)=$count_exec from connections_done |
| 72 |
--source include/wait_condition_or_abort.inc |
| 73 |
|
| 74 |
--echo # Drop all the tables |
| 75 |
DROP TABLE connections_done; |
| 76 |
--let $num_table=0 |
| 77 |
while($num_table < $tables_count){ |
| 78 |
--eval DROP TABLE g$num_table |
| 79 |
--inc $num_table |
| 80 |
} |