| 1 |
--echo # Test for bug #12400341: INNODB CAN LEAVE ORPHAN IBD FILES AROUND |
| 2 |
|
| 3 |
--source include/have_debug.inc |
| 4 |
--source include/have_innodb_default_undo_tablespaces.inc |
| 5 |
|
| 6 |
# Don't test under valgrind, undo slots of the previous test might exist still |
| 7 |
# and cause unstable result. |
| 8 |
--source include/not_valgrind.inc |
| 9 |
|
| 10 |
--disable_query_log |
| 11 |
call mtr.add_suppression("\\[ERROR\\] .*MY-\\d+.* Cannot find a free slot for an undo log"); |
| 12 |
|
| 13 |
set @old_innodb_trx_rseg_n_slots_debug = @@innodb_trx_rseg_n_slots_debug; |
| 14 |
set global innodb_trx_rseg_n_slots_debug = 5; |
| 15 |
--enable_query_log |
| 16 |
|
| 17 |
set @old_innodb_rollback_segments = @@innodb_rollback_segments; |
| 18 |
set global innodb_rollback_segments=1; |
| 19 |
|
| 20 |
show variables like "max_connections"; |
| 21 |
show variables like "innodb_thread_concurrency"; |
| 22 |
show variables like "innodb_file_per_table"; |
| 23 |
show variables like "innodb_rollback_segments"; |
| 24 |
show variables like "innodb_trx_rseg_n_slots_debug"; |
| 25 |
|
| 26 |
--disable_warnings |
| 27 |
drop database if exists mysqltest; |
| 28 |
--enable_warnings |
| 29 |
|
| 30 |
create database mysqltest; |
| 31 |
CREATE TABLE mysqltest.transtable (id int unsigned NOT NULL PRIMARY KEY, val int DEFAULT 0) ENGINE=InnoDB; |
| 32 |
|
| 33 |
--disable_query_log |
| 34 |
# |
| 35 |
# Add some rows so UPDATE below has something to work on. |
| 36 |
# |
| 37 |
let $c = 5; |
| 38 |
while ($c) |
| 39 |
{ |
| 40 |
eval INSERT INTO mysqltest.transtable (id) VALUES ($c); |
| 41 |
dec $c; |
| 42 |
} |
| 43 |
|
| 44 |
let $c = 10; |
| 45 |
while ($c) |
| 46 |
{ |
| 47 |
# if failed at here, it might be shortage of file descriptors limit. |
| 48 |
connect (con$c,localhost,root,,); |
| 49 |
dec $c; |
| 50 |
} |
| 51 |
--enable_query_log |
| 52 |
|
| 53 |
select count(*) from information_schema.processlist; |
| 54 |
|
| 55 |
# |
| 56 |
# Fill all the undo slots. |
| 57 |
# |
| 58 |
# CREATE TABLE above creates both cached insert and update slots, with exact |
| 59 |
# number of slots of each type depending on implementation. Since type of the |
| 60 |
# slot can't be changed we have to use transactions of both insert and update |
| 61 |
# types to to fill all undo slots. |
| 62 |
# |
| 63 |
--disable_query_log |
| 64 |
let $c = 10; |
| 65 |
while ($c > 5) |
| 66 |
{ |
| 67 |
connection con$c; |
| 68 |
START TRANSACTION; |
| 69 |
eval INSERT INTO mysqltest.transtable (id) VALUES ($c); |
| 70 |
dec $c; |
| 71 |
} |
| 72 |
|
| 73 |
while ($c) |
| 74 |
{ |
| 75 |
connection con$c; |
| 76 |
START TRANSACTION; |
| 77 |
eval UPDATE mysqltest.transtable SET val = 1 WHERE id = 6 - $c; |
| 78 |
dec $c; |
| 79 |
} |
| 80 |
--enable_query_log |
| 81 |
|
| 82 |
connection default; |
| 83 |
|
| 84 |
--error ER_TOO_MANY_CONCURRENT_TRXS |
| 85 |
CREATE TABLE mysqltest.testtable (id int unsigned not null primary key) ENGINE=InnoDB; |
| 86 |
|
| 87 |
select count(*) from information_schema.processlist; |
| 88 |
|
| 89 |
--disable_query_log |
| 90 |
let $c = 10; |
| 91 |
while ($c) |
| 92 |
{ |
| 93 |
connection con$c; |
| 94 |
ROLLBACK; |
| 95 |
dec $c; |
| 96 |
} |
| 97 |
--enable_query_log |
| 98 |
|
| 99 |
connection default; |
| 100 |
select count(*) from information_schema.processlist; |
| 101 |
|
| 102 |
--disable_query_log |
| 103 |
let $c = 10; |
| 104 |
while ($c) |
| 105 |
{ |
| 106 |
disconnect con$c; |
| 107 |
dec $c; |
| 108 |
} |
| 109 |
--enable_query_log |
| 110 |
|
| 111 |
# |
| 112 |
# If the isolated .ibd file remained, the drop database should fail. |
| 113 |
# |
| 114 |
drop database mysqltest; |
| 115 |
|
| 116 |
set global innodb_rollback_segments = @old_innodb_rollback_segments; |
| 117 |
|
| 118 |
--disable_query_log |
| 119 |
set global innodb_trx_rseg_n_slots_debug = @old_innodb_trx_rseg_n_slots_debug; |
| 120 |
--enable_query_log |