1#
2# Bug#14007109 RECURSIVE ACQ OF BLOCK LOCK IN S MODE, STATS UPDATE ASRT !RW_LOCK_OWN(LOCK, 352)
3#
4
5-- source include/have_innodb.inc
6# The assertion only fails in debug versions, so no need to test in non-debug
7-- source include/have_debug.inc
8
9CREATE TABLE bug14007109 (
10	a VARCHAR(512), PRIMARY KEY (a)
11) ENGINE=INNODB STATS_PERSISTENT=1;
12
13BEGIN;
14-- disable_query_log
15# As of the time this test is added, 854 pages do not trigger the assert,
16# while 855 do. We use a bigger number here just in case. What is needed
17# is to have a btree with 3 levels, where the level in the middle contains
18# two (or more) pages. The persistent stats code crawls that level twice
19# in the same mtr:
20# dict_stats_analyze_index()
21#   start mtr
22#   dict_stats_analyze_index_level(mtr)
23#     traverse the level (leaves the last page in the middle level S-latched)
24#   dict_stats_analyze_index_for_n_prefix(mtr)
25#     traverse the level (would try to S-latch the last page)
26#   commit mtr
27let $i=900;
28while ($i) {
29        eval INSERT INTO bug14007109 VALUES (REPEAT(1000+$i, 128));
30        dec $i;
31}
32-- enable_query_log
33COMMIT;
34
35# We get a (debug) assertion failure here if the bug exists
36ANALYZE TABLE bug14007109;
37
38DROP TABLE bug14007109;
39