Debian Codegraph @

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

raw
1 ################################################################################
2 # BUG#25978684: GR+XA: ASSERT `! IS_SET() AT SQL_ERROR.CC:406 WHEN MEMBER IS IN ERROR/RECOVERING
3 # Validate that XA COMMIT does handle a local failure properly.
4 #
5 # Test:
6 # 1. Prepare the data for the test.
7 # 2. Execute a XA PREPARE with id '1'.
8 # 3. Force a local failure in before_commit listener on the
9 # XA COMMIT.
10 # 4. Clean up.
11 ################################################################################
12 --source include/have_debug.inc
13 --source include/have_binlog_format_row.inc
14
15
16 --echo
17 --echo ############################################################
18 --echo # 1. Prepare the data for the test.
19 CREATE TABLE t1 (c1 INT PRIMARY KEY);
20
21
22 --echo
23 --echo ############################################################
24 --echo # 2. Execute a XA PREPARE with id '1'.
25 --connect (server1_conn2, 127.0.0.1, root, , test, $MASTER_MYPORT,)
26 XA START 'xid1';
27 INSERT INTO t1 VALUES (1);
28 XA END 'xid1';
29 XA PREPARE 'xid1';
30
31 let $connection_id= `SELECT CONNECTION_ID()`;
32
33 --disconnect server1_conn2
34
35 --echo # Waiting for the connection server1_conn2 disappeared on the server side
36 --connection default
37 let $wait_condition =
38 SELECT COUNT(*) = 0
39 FROM information_schema.processlist
40 WHERE id = '$connection_id';
41 --source include/wait_condition.inc
42
43 --echo
44 --echo ############################################################
45 --echo # 3. Force a local failure in before_commit listener on the
46 --echo # XA COMMIT.
47 --connection default
48
49 --echo # Wait until a record about a prepared XA transaction be found in output of XA RECOVER.
50 --echo # Having two conditions satisfied (first one for disappeared connection server1_conn2
51 --echo # and the second one for presence of the prepared XA transaction with xid value equaled xid1)
52 --echo # guarantees that the connection server1_conn2 was really closed and a prepared XA transaction
53 --echo # with xid1 was really placed into an internal server cache of prepared XA transactions.
54 --let $wait_timeout= 5
55 --let $show_statement = XA RECOVER
56 --let $field = 'data'
57 --let $condition = ='xid1'
58 --source include/wait_show_condition.inc
59
60 --echo # Output result of XA RECOVER into result file for sanity check.
61 XA RECOVER;
62
63 SET @debug_save= @@GLOBAL.DEBUG;
64 SET @@GLOBAL.DEBUG= '+d,simulate_failure_in_before_commit_hook';
65
66 --error ER_RUN_HOOK_ERROR
67 XA COMMIT 'xid1';
68 SHOW ERRORS;
69 SET @@GLOBAL.DEBUG= @debug_save;
70
71
72 --echo
73 --echo ############################################################
74 --echo # 4. Clean up.
75 DROP TABLE t1;
76
77 --source include/restart_mysqld.inc
78
79 # This is a temporal workaround for the bug#26962434 (XA INCONSISTENCIES AFTER
80 # XA COMMIT ERROR). The workaround suppresses a warning about presence of a
81 # prepared XA transaction after server restart and rolls back a prepared XA
82 # transaction that possibly left on Windows platform after XA COMMIT
83 # had failed.
84
85 # XA ROLLBACK is run in order to finalise XA transaction so that information
86 # about this XA transaction wouldn't appear in subsequent test cases where
87 # server is restared. Since the test fails on windows and runs successfully
88 # on Unix the directive --error added that expects both success and error code
89 # ER_XAER_NOTA from invocation of XA ROLLBACK. Added XA ROLLBACK fails on Unix
90 # since there isn't any prepared XA transaction with specified xid (and this is
91 # expected and correct behaviour) and successes on Windows where prepared XA
92 # transaction with xid value 'xid1' exists after server restart
93 # (this is incorrect behaviour that must be fixed later).
94 CALL mtr.add_suppression("Found 1 prepared XA transactions");
95 --error 0,ER_XAER_NOTA
96 XA ROLLBACK 'xid1';