Debian Codegraph @

mysql-test/suite/innodb/t/trx_sys_t_find_lf_hash_error.test

raw
1 --source include/have_innodb.inc
2 --source include/have_debug.inc
3 --source include/have_debug_sync.inc
4 --source include/count_sessions.inc
5
6 create table t1 (a int) engine=innodb STATS_PERSISTENT=0;
7 create table t2 (a int) engine=innodb STATS_PERSISTENT=0;
8
9 BEGIN; # trx1
10 # register rw-transaction in trx_sys.rw_trx_hash
11 insert into t1 values(1);
12
13 --connect (con_1, localhost, root,,)
14 SET DEBUG_SYNC="before_trx_hash_find_element_mutex_enter SIGNAL before_mutex_enter WAIT_FOR cont1";
15 SET DEBUG_SYNC="after_trx_hash_find_element_mutex_enter SIGNAL after_mutex_enter WAIT_FOR cont2";
16
17 # trx2 is converting implicit lock of trx1 to explicit one, it's invoking
18 # ▾ l_search
19 # ▾ lf_hash_search_using_hash_value
20 # ▾ lf_hash_search
21 # ▾ rw_trx_hash_t::find
22 # ▾ trx_sys_t::find
23 # ▾ lock_rec_convert_impl_to_expl
24 # rw_trx_hash_t::find returns lf_hash element, pin 2 is pinned,
25 # but element->mutex has not been acquired yet, what allows trx1 element to be
26 # removed from trx_sys.rw_trx_hash at one hand, and at the other hand, the
27 # content of the element is still valid as it's pinned.
28 #
29 # trx2
30 --send SELECT * FROM t1 WHERE a = 1 FOR UPDATE
31 --connection default
32 SET DEBUG_SYNC="now WAIT_FOR before_mutex_enter";
33 --disable_query_log
34 SET @saved_dbug = @@debug_dbug;
35
36 # Usually pinbox purgatory is purged either when the number of elements in
37 # purgatory is greater then some limit(see lf_pinbox_free()), or when thread
38 # invokes rw_trx_hash_t::put_pins() explicitly. For this test the first
39 # variant was choosen. The following option makes lf_pinbox_free() to purge
40 # pinbox purgatory on each call, ignoring pins->purgatory_count.
41 SET DEBUG_DBUG='+d,unconditional_pinbox_free';
42 --enable_query_log
43
44 # trx1 is committed and removed from trx_sys.rw_trx_hash. It can be done as
45 # trx2 has not been acquired element->mutex yet.
46 COMMIT;
47 --disable_query_log
48 SET DEBUG_DBUG = @saved_dbug;
49 --enable_query_log
50
51 # Let trx2 to acquire element->mutex and unpin pin 2
52 SET DEBUG_SYNC="now SIGNAL cont1";
53 SET DEBUG_SYNC="now WAIT_FOR after_mutex_enter";
54
55 --disable_query_log
56 SET @saved_dbug = @@debug_dbug;
57 SET DEBUG_DBUG='+d,unconditional_pinbox_free';
58 --enable_query_log
59 # trx3 commits and invokes lf_pinbox_free(), which purges pin 2 of trx2 and
60 # places its pointer on trx_sys.rw_trx_hash.hash.alloc.top.
61 insert into t2 values(1);
62 --disable_query_log
63 SET DEBUG_DBUG = @saved_dbug;
64 --enable_query_log
65
66 BEGIN; # trx4
67 # trx_sys.rw_trx_hash.hash.alloc.top points to "freed" trx2 lf_hash element,
68 # lf_alloc_new() gets the pointer from trx_sys.rw_trx_hash.hash.alloc.top,
69 # so the memory for lf_hash element will be reused for trx4 if MDEV-31185 is
70 # not fixed
71 INSERT INTO t2 VALUES(2);
72
73 # let trx2 to invoke DBUG_ASSERT(trx_id == trx->id) and crash if MDEV-31185
74 # is not fixed
75 SET DEBUG_SYNC="now SIGNAL cont2";
76
77 --connection con_1
78 # trx 2 assertion failure if MDEV-31185 is not fixed
79 --reap
80 --disconnect con_1
81 --connection default
82 DROP TABLE t1;
83 DROP TABLE t2;
84
85 SET DEBUG_SYNC="reset";
86
87 --source include/wait_until_count_sessions.inc