Debian Codegraph @

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

raw
1 # === Purpose ===
2 #
3 # Check binlog after commit queue and locks.
4 #
5 # ==== Requirements ====
6 #
7 # R1. Any two threads should execute their after_commit hooks in the same order as they commit.
8 #
9 # === Implementation ====
10 #
11 # Abstract:
12 # Block transaction 1 immediately after the commit stage, before the after_commit hook, by using
13 # a debug sync point. Execute transaction 2 and wait for it to complete the commit stage,
14 # by inspecting the table data. Verify that transaction 2 is waiting for transaction 1 to make progress,
15 # by inspecting its execution stage in performance_schema.
16 #
17 # Test steps:
18 # 1. Create table t1 so that we can insert rows
19 # 2. Start connection server_1_1, insert value to t1 and signal that after commit hook has been reached. wait until it is unblocked by server_1 connection.
20 # 3. Start connection server_1_2, insert value to t1. This connection will stop at commit phase until server_1_1 is ublocked.
21 # 4. Check that connection server_1_1 and server_1_2 have executed and t1 contains two rows using information_schema.processlist.
22 # 5. Check connection server_1_1 waits at bgc_after_after_commit_stage_change debug point.
23 # 6. Check connection server_1_2 waits for for handler commit.
24 # 7. Send signal from server_1 to server_1_1 so that stage is unblocked and transaction in connections server_1_1 and server_1_2 continue.
25 # 8. Finish transaction execution in server_1_1 and server_1_2.
26 # 9. Cleanup
27 #
28 # === References ===
29 #
30 # BUG#34703698 after_commit hook may be invoked out of order even when binlog_order_commit=1
31 #
32 --source include/have_binlog_format_row.inc
33 --source include/have_binlog_order_commits.test
34 --source include/have_debug_sync.inc
35 --let $rpl_extra_connections_per_server= 2
36 --let $rpl_topology= none
37 --let $rpl_server_count= 1
38 --source include/rpl_init.inc
39
40 CREATE TABLE t1 (a INT);
41
42 --let $rpl_connection_name= server_1_1
43 --source include/rpl_connection.inc
44
45 --let $conn1_id=`SELECT connection_id()`
46
47 # Tell the connection to wait on the after commit process and send a signal for us to know it is there
48 SET DEBUG_SYNC= 'bgc_after_enrolling_for_after_commit_stage SIGNAL signal.after_commit_reached WAIT_FOR signal.after_commit_unblocked';
49
50 --send INSERT INTO t1 VALUES (1)
51
52 --let $rpl_connection_name= server_1
53 --source include/rpl_connection.inc
54
55 # Wait for connection 1 to get there
56 SET DEBUG_SYNC= "now WAIT_FOR signal.after_commit_reached";
57
58 --let $rpl_connection_name= server_1_2
59 --source include/rpl_connection.inc
60
61 --let $conn2_id=`SELECT connection_id()`
62
63 --send INSERT INTO t1 VALUES (2)
64
65 --let $rpl_connection_name= server_1
66 --source include/rpl_connection.inc
67
68 # check commit phase has been executed
69 let $wait_condition=SELECT COUNT(*)=2 FROM t1;
70 --source include/wait_condition.inc
71
72 --let $assert_text= "The connection for the first insert is blocked in debug point"
73 --let $assert_cond= COUNT(*) = 1 FROM information_schema.processlist WHERE id = $conn1_id AND state = \'debug sync point: bgc_after_enrolling_for_after_commit_stage\'
74 --source include/assert.inc
75
76 # Check connection server_1_2 is blocked at commit stage
77 --let $assert_text= "The connection for the second insert is blocked waiting for the commit handler (insert 1)"
78 --let $assert_cond= COUNT(*) = 1 FROM information_schema.processlist WHERE id = $conn2_id AND state = \'waiting for handler commit\'
79 --source include/assert.inc
80
81 SET DEBUG_SYNC= "now SIGNAL signal.after_commit_unblocked";
82
83 --let $rpl_connection_name= server_1_1
84 --source include/rpl_connection.inc
85
86 --reap
87
88 --let $rpl_connection_name= server_1_2
89 --source include/rpl_connection.inc
90
91 --reap
92
93 --let $rpl_connection_name= server_1
94 --source include/rpl_connection.inc
95
96 DROP TABLE t1;
97
98 --source include/rpl_end.inc