Skip to content

Commit 4331ea8

Browse files
committed
MDEV-36800 Assertion `thd_arg->in_multi_stmt_transaction_mode() at rolling back..
XA in XA_ROLLBACK_ONLY state. The assert was too strict having not anticipated to face a XA-PREPARE ending in rolling back. That's a correct behaviour of read-only disconnecting XA. Fixed to relax the assert.
1 parent 8d4abfe commit 4331ea8

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

mysql-test/suite/binlog/r/mdev-32830_qa_tests.result

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
set @@session.binlog_format=row;
12
CREATE TABLE t (c INT) ENGINE=InnoDB;
23
XA START 'a';
34
SAVEPOINT s;
@@ -20,4 +21,17 @@ master-bin.000001 # Query # # ROLLBACK
2021
Cleanup
2122
DROP TEMPORARY TABLE t;
2223
DROP TABLE t;
24+
set @@session.binlog_format=statement;
25+
CREATE TABLE t1 (c CHAR(1),c2 CHAR(1)) ENGINE=MyISAM;
26+
CREATE TEMPORARY TABLE t (a INT) ENGINE=InnoDB SELECT+1 a;
27+
XA START 'a';
28+
INSERT t SELECT+1 seq_1_to_1;
29+
SET pseudo_slave_mode=1;
30+
INSERT INTO t1 (c) VALUES (1);
31+
XA END 'a';
32+
XA PREPARE 'a';
33+
# cleanup
34+
XA ROLLBACK 'a';
35+
DROP TABLE t;
36+
DROP TABLE t1;
2337
End of tests

mysql-test/suite/binlog/t/mdev-32830_qa_tests.test

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
--source include/have_binlog_format_row.inc
1+
--source include/have_log_bin.inc
22
--source include/have_innodb.inc
33

4+
# MDEV-36804
5+
set @@session.binlog_format=row;
6+
47
CREATE TABLE t (c INT) ENGINE=InnoDB;
58
XA START 'a';
69
SAVEPOINT s;
@@ -21,4 +24,24 @@ source include/show_binlog_events.inc;
2124
DROP TEMPORARY TABLE t;
2225
DROP TABLE t;
2326

27+
# MDEV-36800
28+
set @@session.binlog_format=statement;
29+
30+
CREATE TABLE t1 (c CHAR(1),c2 CHAR(1)) ENGINE=MyISAM;
31+
CREATE TEMPORARY TABLE t (a INT) ENGINE=InnoDB SELECT+1 a;
32+
XA START 'a';
33+
INSERT t SELECT+1 seq_1_to_1;
34+
SET pseudo_slave_mode=1;
35+
INSERT INTO t1 (c) VALUES (1);
36+
XA END 'a';
37+
XA PREPARE 'a';
38+
39+
--echo # cleanup
40+
--error ER_XAER_NOTA
41+
XA ROLLBACK 'a';
42+
--error ER_BAD_TABLE_ERROR
43+
DROP TABLE t;
44+
DROP TABLE t1;
45+
46+
2447
--echo End of tests

sql/log_event_server.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2907,7 +2907,9 @@ Gtid_log_event::Gtid_log_event(THD *thd_arg, uint64 seq_no_arg,
29072907
}
29082908
else if (thd->lex->sql_command == SQLCOM_XA_PREPARE)
29092909
{
2910-
DBUG_ASSERT(thd_arg->in_multi_stmt_transaction_mode());
2910+
/* destined to rollback xa has already reset the multi-stmt feature */
2911+
DBUG_ASSERT(thd->in_multi_stmt_transaction_mode() ||
2912+
xid_state.get_state_code() == XA_ROLLBACK_ONLY);
29112913

29122914
uint8 count= ha_count_rw_2pc(thd_arg, true);
29132915
extra_engines= count > 1 ? 0 : UCHAR_MAX;

0 commit comments

Comments
 (0)