File: binlog_xa_handling.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 (126 lines) | stat: -rw-r--r-- 3,936 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
###############################################################################
# Bug#19928622: ASSERTION `! IS_SET()' FAILED. | ABORT IN
# DIAGNOSTICS_AREA::SET_OK_STATUS
#
# Test:
# =====
# Begin an XA transaction and execte a DML statement so that XA state becomes
# XA_ACTIVE. Execute the BINLOG command it should not cause any assert.
# Execution should fail and a `ER_VARIABLE_NOT_SETTABLE_IN_TRANSACTION` should
# be expected.
###############################################################################
--source include/have_log_bin.inc
CALL mtr.add_suppression("Statement is unsafe because it is being used inside a XA transaction");

--connection default
CREATE TABLE t1(f1 int);

XA START'','';
--disable_warnings
INSERT INTO t1 VALUES(10);
--enable_warnings
--error ER_VARIABLE_NOT_SETTABLE_IN_TRANSACTION
BINLOG '
SOgWTg8BAAAAbgAAAHIAAAAAAAQANS42LjMtbTUtZGVidWctbG9nAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAABI6BZOEzgNAAgAEgAEBAQEEgAAVgAEGggAAAAICAgCAAAAAAVAYI8=';
XA END'';
XA PREPARE'';
XA COMMIT'';

#
# Bug#21942487 ASSERTION
# `STATIC_CAST<SQL_CMD_XA_COMMIT*>(THD->LEX->M_SQL_CMDQL_CMD)->
# GET_XA_OPT()
# Bug #24764800 REPLICATION FAILING ON SLAVE WITH XAER_RMFAIL ERROR
#
# The following block checks safety of processing of load masquaraded
# as if it's out of mysqlbinlog. The XA transaction must complete in
# either rollback or commit mode.
# Rollback is done two ways: explicit and implicit through connection close.
#
SET @sav.pseudo_replica_mode= @@session.pseudo_replica_mode;
SELECT  @@session.pseudo_replica_mode;
# A warning out of the following query is improper and caused by a combination
# of the above BINLOG processing and side effect of BUG#15891524.
SET @@session.pseudo_replica_mode=1;

# In order to simulate dressing up as the binlog applier the current connection needs
# to process at least one BINLOG carrying Format-Descriptor log-event.
BINLOG '
SOgWTg8BAAAAbgAAAHIAAAAAAAQANS42LjMtbTUtZGVidWctbG9nAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAABI6BZOEzgNAAgAEgAEBAQEEgAAVgAEGggAAAAICAgCAAAAAAVAYI8=';

SET @@gtid_next = "AUTOMATIC";
XA START 'xa_rollback';
--disable_warnings
INSERT INTO t1 VALUES(10);
--enable_warnings
XA END 'xa_rollback';
XA ROLLBACK 'xa_rollback';

#
# The same but XA END as above in a new connection which is closed to rollback xa
#
--connect(con1,localhost,root,,)
SET @@session.pseudo_replica_mode=1;
BINLOG '
SOgWTg8BAAAAbgAAAHIAAAAAAAQANS42LjMtbTUtZGVidWctbG9nAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAABI6BZOEzgNAAgAEgAEBAQEEgAAVgAEGggAAAAICAgCAAAAAAVAYI8=';

SET @@gtid_next = "AUTOMATIC";
XA START 'xa_disconnect';
--disable_warnings
INSERT INTO t1 VALUES(10);
--enable_warnings
--disconnect con1

--connection default
XA START 'xa_commit';
--disable_warnings
INSERT INTO t1 VALUES(10);
--enable_warnings
XA END 'xa_commit';
XA PREPARE 'xa_commit';
XA COMMIT 'xa_commit';
SET @@session.pseudo_replica_mode= @sav.pseudo_replica_mode;

DROP TABLE t1;

#
#  BUG#21053526 XA:'XA COMMIT..ONE PHASE' IS BINLOGGED INCORRECTLY AS 'XA PREPARE'
#

#
# This is actually the following test:
# SEQUENCE: XA BEGIN, XA END, XA COMMIT ONE PHASE
#
# The test validates that SHOW BINLOG EVENTS shows
# the correct info for the ONE PHASE statement
#
# This test does not test applying the output of
# mysqlbinlog, since that is already tested in
# mysql-test/extra/binlog_tests/binlog_xa_prepared.test
#

# clean up binary log so that the following operation
# does not have to scan through a long history of
# events in the log (potentially causing a failure).
RESET MASTER;

CREATE TABLE t1 (c1 INT);
XA BEGIN 'xa1';
--disable_warnings
INSERT INTO t1 VALUES (1);
--enable_warnings
XA END 'xa1';
XA COMMIT 'xa1' ONE PHASE;

--echo [Validate that SHOW BINLOG EVENTS shows the ONE PHASE statement.]
--let $wait_binlog_event= ONE PHASE
--source include/wait_for_binlog_event.inc

DROP TABLE t1;

# clean up the binary log at in the end of the test
# case as well.
RESET MASTER;