File: binlog_xa_commit_failure.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (96 lines) | stat: -rw-r--r-- 3,663 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
################################################################################
# BUG#25978684: GR+XA: ASSERT `! IS_SET() AT SQL_ERROR.CC:406 WHEN MEMBER IS IN ERROR/RECOVERING
# Validate that XA COMMIT does handle a local failure properly.
#
# Test:
# 1. Prepare the data for the test.
# 2. Execute a XA PREPARE with id '1'.
# 3. Force a local failure in before_commit listener on the
#    XA COMMIT.
# 4. Clean up.
################################################################################
--source include/have_debug.inc
--source include/have_binlog_format_row.inc


--echo
--echo ############################################################
--echo # 1. Prepare the data for the test.
CREATE TABLE t1 (c1 INT PRIMARY KEY);


--echo
--echo ############################################################
--echo # 2. Execute a XA PREPARE with id '1'.
--connect (server1_conn2, 127.0.0.1, root, , test, $MASTER_MYPORT,)
XA START 'xid1';
INSERT INTO t1 VALUES (1);
XA END 'xid1';
XA PREPARE 'xid1';

let $connection_id= `SELECT CONNECTION_ID()`;

--disconnect server1_conn2

--echo # Waiting for the connection server1_conn2 disappeared on the server side
--connection default
let $wait_condition =
 SELECT COUNT(*) = 0
 FROM information_schema.processlist
 WHERE  id = '$connection_id';
--source include/wait_condition.inc

--echo
--echo ############################################################
--echo # 3. Force a local failure in before_commit listener on the
--echo #    XA COMMIT.
--connection default

--echo # Wait until a record about a prepared XA transaction be found in output of XA RECOVER.
--echo # Having two conditions satisfied (first one for disappeared connection server1_conn2
--echo # and the second one for presence of the prepared XA transaction with xid value equaled xid1)
--echo # guarantees that the connection server1_conn2 was really closed and a prepared XA transaction
--echo # with xid1 was really placed into an internal server cache of prepared XA transactions.
--let $wait_timeout= 5
--let $show_statement = XA RECOVER
--let $field = 'data'
--let $condition = ='xid1'
--source include/wait_show_condition.inc

--echo # Output result of XA RECOVER into result file for sanity check.
XA RECOVER;

SET @debug_save= @@GLOBAL.DEBUG;
SET @@GLOBAL.DEBUG= '+d,simulate_failure_in_before_commit_hook';

--error ER_RUN_HOOK_ERROR
XA COMMIT 'xid1';
SHOW ERRORS;
SET @@GLOBAL.DEBUG= @debug_save;


--echo
--echo ############################################################
--echo # 4. Clean up.
DROP TABLE t1;

--source include/restart_mysqld.inc

# This is a temporal workaround for the bug#26962434 (XA INCONSISTENCIES AFTER
# XA COMMIT ERROR). The workaround suppresses a warning about presence of a
# prepared XA transaction after server restart and rolls back a prepared XA
# transaction that  possibly left on Windows platform after XA COMMIT
# had failed.

# XA ROLLBACK is run in order to finalise XA transaction so that information
# about this XA transaction wouldn't appear in subsequent test cases where
# server is restared. Since the test fails on windows and runs successfully
# on Unix the directive --error added that expects both success and error code
# ER_XAER_NOTA from invocation of XA ROLLBACK. Added XA ROLLBACK fails on Unix
# since there isn't any prepared XA transaction with specified xid (and this is
# expected and correct behaviour) and successes on Windows where prepared XA
# transaction with xid value 'xid1' exists after server restart
# (this is incorrect behaviour that must be fixed later).
CALL mtr.add_suppression("Found 1 prepared XA transactions");
--error 0,ER_XAER_NOTA
XA ROLLBACK 'xid1';