Debian Codegraph @

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

raw
1 ###############################################################################
2 # Bug#22915670 'XA ROLLBACK' ASSERTS AFTER FAILED XA PREPARE
3 # Problem: A 'XA PREPARE' that is failed in intermediate steps is leaving the
4 # 'xa' transaction state in a bad way (ID = -1 but binlogged flag is 'true').
5 # This is causing problems (hitting asserts) while executing
6 # 'XA COMMIT/ROLLBACK' queries.
7 # Steps to reproduce:
8 # 1) Start a XA transaction
9 # 2) Inject a failure point for 'XA PREPARE'
10 # 3) Execute 'XA PREPARE'. Check that 'XA PREPARE' failed as expected.
11 # 4) After failure, execute XA ROLLBACK or XA COMMIT.
12 # It should fail with UNKNOWN XID error instead of ASSERT.
13 # 5) Repeat step 2 and 4 with different failure points.
14 ###############################################################################
15 --source include/have_debug.inc
16 --source include/have_log_bin.inc
17 CALL mtr.add_suppression("Statement is unsafe because it is being used inside a XA transaction");
18
19 # Initial setup
20 SET @save_session_debug= @@SESSION.debug;
21 CREATE TABLE t1 (a INT PRIMARY KEY);
22
23 # Loop through three failure points
24 --let $iter=1
25 while ($iter <= 3)
26 {
27 # Step-1: Start A XA transaction.
28 XA START 'xa1';
29 --disable_warnings
30 INSERT INTO t1 VALUES (1);
31 --enable_warnings
32 XA END 'xa1';
33
34 # Step-2: Inject a failure point for 'XA PREPARE'
35 if ( $iter == 1)
36 {
37 SET @@SESSION.debug = "+d,simulate_xa_prepare_failure_in_cache_finalize";
38 }
39 if ( $iter == 2)
40 {
41 SET @@SESSION.debug = "+d,simulate_failure_in_before_commit_hook";
42 }
43 if ( $iter == 3)
44 {
45 SET @@SESSION.debug = "+d,simulate_transaction_rollback_request";
46 }
47
48 # Step-3: Execute 'XA PREPARE' and check that 'XA PREPARE' failed as expected.
49 --error ER_XA_RBROLLBACK,ER_TRANSACTION_ROLLBACK_DURING_COMMIT
50 XA PREPARE 'xa1';
51
52 # Step-4: Execute 'XA COMMIT/ XA ROLLBACK'. Check that it fails with error.
53 --error ER_XAER_NOTA
54 XA ROLLBACK 'xa1';
55 --error ER_XAER_NOTA
56 XA COMMIT 'xa1';
57
58 # Step-5: Repeat for other failure points.
59 --inc $iter
60 }
61
62 # Cleanup
63 SET @@SESSION.debug= @save_session_debug;
64 DROP TABLE t1;