Debian Codegraph @

mysql-test/suite/binlog/t/binlog_mdev37541.test

raw
1 --source include/have_debug_sync.inc
2 --source include/have_innodb.inc
3 --source include/have_binlog_format_mixed.inc
4
5 # MDEV-37541 Race of rolling back and committing transaction to binlog
6 # The tests reproduce a scenario of two conflicting transactions
7 # of which the dependency decides to rollback. In order to reproduce the bug
8 # the parent features side effects (produced by DROP TEMPORARY TABLE)
9 # and multiple engines.
10 # The tests prove that the child transaction can not win race to binlogging
11 # with its parent as it gets stuck at engine lock acquiring all time
12 # while the parent conducts binlogging on its own.
13
14 create table t1 (a int primary key, b text) engine=innodb;
15
16 connect(trx1_rollback,localhost,root,,);
17 CREATE TABLE t_x (a int) engine=MEMORY;
18
19 --let $master_file= query_get_value(SHOW MASTER STATUS, File, 1)
20 --let $binlog_start=query_get_value(SHOW MASTER STATUS, Position, 1)
21 SET binlog_format=row;
22 CREATE TEMPORARY TABLE tt_tmp ( id INT ) ENGINE = Memory;
23 BEGIN;
24 insert into t_x values (1);
25 drop temporary table tt_tmp;
26 insert into t1 values (99, "gotta log first");
27
28 SET DEBUG_SYNC= 'reset';
29 SET DEBUG_SYNC= "before_group_commit_queue SIGNAL trx1_at_log WAIT_FOR trx1_go";
30
31 --send ROLLBACK
32
33 connect(trx2_commit,localhost,root,,);
34 --send insert into t1 values (99, "second best in binlog")
35
36 connection default;
37
38 # Make sure ROLLBACK is in the binlogging phase ..
39 SET DEBUG_SYNC= "now WAIT_FOR trx1_at_log";
40 # .. and the contender trx2 in the locking phase ..
41 let $wait_condition=
42 select count(*) = 1 from information_schema.innodb_trx
43 where trx_state = "LOCK WAIT" and trx_query like "%insert into t1 values%";
44 source include/wait_condition.inc;
45 # .. when both provided unfreeze the trx:s ..
46 SET DEBUG_SYNC= "now SIGNAL trx1_go";
47
48 connection trx2_commit;
49 reap;
50 select * from t1;
51
52 # .. to observe proper binlogging.
53 --echo # Prove the logging order is Trx1, Trx2
54 --source include/show_binlog_events.inc
55
56 drop table t_x, t1;
57 disconnect trx1_rollback;
58 disconnect trx2_commit;
59 --echo # end of the tests