File: innodb_bug12400341.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (120 lines) | stat: -rw-r--r-- 2,890 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
--echo # Test for bug #12400341: INNODB CAN LEAVE ORPHAN IBD FILES AROUND

--source include/have_debug.inc
--source include/have_innodb_default_undo_tablespaces.inc

# Don't test under valgrind, undo slots of the previous test might exist still
# and cause unstable result.
--source include/not_valgrind.inc

--disable_query_log
call mtr.add_suppression("\\[ERROR\\] .*MY-\\d+.* Cannot find a free slot for an undo log");

set @old_innodb_trx_rseg_n_slots_debug = @@innodb_trx_rseg_n_slots_debug;
set global innodb_trx_rseg_n_slots_debug = 5;
--enable_query_log

set @old_innodb_rollback_segments = @@innodb_rollback_segments;
set global innodb_rollback_segments=1;

show variables like "max_connections";
show variables like "innodb_thread_concurrency";
show variables like "innodb_file_per_table";
show variables like "innodb_rollback_segments";
show variables like "innodb_trx_rseg_n_slots_debug";

--disable_warnings
drop database if exists mysqltest;
--enable_warnings

create database mysqltest;
CREATE TABLE mysqltest.transtable (id int unsigned NOT NULL PRIMARY KEY, val int DEFAULT 0) ENGINE=InnoDB;

--disable_query_log
#
# Add some rows so UPDATE below has something to work on.
#
let $c = 5;
while ($c)
{
  eval INSERT INTO mysqltest.transtable (id) VALUES ($c);
  dec $c;
}

let $c = 10;
while ($c)
{
  # if failed at here, it might be shortage of file descriptors limit.
  connect (con$c,localhost,root,,);
  dec $c;
}
--enable_query_log

select count(*) from information_schema.processlist;

#
# Fill all the undo slots.
#
# CREATE TABLE above creates both cached insert and update slots, with exact
# number of slots of each type depending on implementation. Since type of the
# slot can't be changed we have to use transactions of both insert and update
# types to to fill all undo slots.
#
--disable_query_log
let $c = 10;
while ($c > 5)
{
  connection con$c;
  START TRANSACTION;
  eval INSERT INTO mysqltest.transtable (id) VALUES ($c);
  dec $c;
}

while ($c)
{
  connection con$c;
  START TRANSACTION;
  eval UPDATE mysqltest.transtable SET val = 1 WHERE id = 6 - $c;
  dec $c;
}
--enable_query_log

connection default;

--error ER_TOO_MANY_CONCURRENT_TRXS
CREATE TABLE mysqltest.testtable (id int unsigned not null primary key) ENGINE=InnoDB;

select count(*) from information_schema.processlist;

--disable_query_log
let $c = 10;
while ($c)
{
  connection con$c;
  ROLLBACK;
  dec $c;
}
--enable_query_log

connection default;
select count(*) from information_schema.processlist;

--disable_query_log
let $c = 10;
while ($c)
{
  disconnect con$c;
  dec $c;
}
--enable_query_log

#
# If the isolated .ibd file remained, the drop database should fail.
#
drop database mysqltest;

set global innodb_rollback_segments = @old_innodb_rollback_segments;

--disable_query_log
set global innodb_trx_rseg_n_slots_debug = @old_innodb_trx_rseg_n_slots_debug;
--enable_query_log