MDEV-35019 Provide a way to enable "rollback XA on disconnect" behavior we had before 10.5.2
Implement variable legacy_xa_rollback_at_disconnect to support backwards compatibility for applications that rely on the pre-10.5 behavior for connection disconnect, which is to rollback the transaction (in violation of the XA specification). Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
This commit is contained in:
parent
e927e28ebe
commit
8ae462a220
@ -433,6 +433,13 @@ The following specify which files/extra groups are read (specified before remain
|
|||||||
--lc-time-names=name
|
--lc-time-names=name
|
||||||
Set the language used for the month names and the days of
|
Set the language used for the month names and the days of
|
||||||
the week.
|
the week.
|
||||||
|
--legacy-xa-rollback-at-disconnect
|
||||||
|
If a user session disconnects after putting a transaction
|
||||||
|
into the XA PREPAREd state, roll back the transaction.
|
||||||
|
Can be used for backwards compatibility to enable this
|
||||||
|
pre-10.5 behavior for applications that expect it. Note
|
||||||
|
that this violates the XA specification and should not be
|
||||||
|
used for new code
|
||||||
--local-infile Enable LOAD DATA LOCAL INFILE
|
--local-infile Enable LOAD DATA LOCAL INFILE
|
||||||
(Defaults to on; use --skip-local-infile to disable.)
|
(Defaults to on; use --skip-local-infile to disable.)
|
||||||
--lock-wait-timeout=#
|
--lock-wait-timeout=#
|
||||||
@ -1572,6 +1579,7 @@ large-pages FALSE
|
|||||||
lc-messages en_US
|
lc-messages en_US
|
||||||
lc-messages-dir MYSQL_SHAREDIR/
|
lc-messages-dir MYSQL_SHAREDIR/
|
||||||
lc-time-names en_US
|
lc-time-names en_US
|
||||||
|
legacy-xa-rollback-at-disconnect FALSE
|
||||||
local-infile TRUE
|
local-infile TRUE
|
||||||
lock-wait-timeout 86400
|
lock-wait-timeout 86400
|
||||||
log-bin foo
|
log-bin foo
|
||||||
|
@ -592,6 +592,22 @@ formatID gtrid_length bqual_length data
|
|||||||
xa rollback '4';
|
xa rollback '4';
|
||||||
ERROR XA100: XA_RBROLLBACK: Transaction branch was rolled back
|
ERROR XA100: XA_RBROLLBACK: Transaction branch was rolled back
|
||||||
set @@global.read_only=@sav_read_only;
|
set @@global.read_only=@sav_read_only;
|
||||||
|
# MDEV-35019: Provide a way to enable "rollback XA on disconnect" behavior we had before 10.5.2
|
||||||
|
# Test legacy_xa_rollback_at_disconnect option.
|
||||||
|
CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB;
|
||||||
|
INSERT INTO t1 VALUES (1, 0);
|
||||||
|
connect con1,localhost,root,,;
|
||||||
|
SET SESSION legacy_xa_rollback_at_disconnect= 1;
|
||||||
|
XA START '5';
|
||||||
|
INSERT INTO t1 VALUES (2, 0);
|
||||||
|
XA END '5';
|
||||||
|
XA PREPARE '5';
|
||||||
|
disconnect con1;
|
||||||
|
connection default;
|
||||||
|
INSERT INTO t1 VALUES (3, 0);
|
||||||
|
XA ROLLBACK '5';
|
||||||
|
ERROR XAE04: XAER_NOTA: Unknown XID
|
||||||
|
DROP TABLE t1;
|
||||||
#
|
#
|
||||||
# End of 10.5 tests
|
# End of 10.5 tests
|
||||||
#
|
#
|
||||||
|
@ -747,6 +747,25 @@ xa rollback '4';
|
|||||||
set @@global.read_only=@sav_read_only;
|
set @@global.read_only=@sav_read_only;
|
||||||
|
|
||||||
|
|
||||||
|
--echo # MDEV-35019: Provide a way to enable "rollback XA on disconnect" behavior we had before 10.5.2
|
||||||
|
--echo # Test legacy_xa_rollback_at_disconnect option.
|
||||||
|
CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB;
|
||||||
|
INSERT INTO t1 VALUES (1, 0);
|
||||||
|
connect (con1,localhost,root,,);
|
||||||
|
SET SESSION legacy_xa_rollback_at_disconnect= 1;
|
||||||
|
XA START '5';
|
||||||
|
INSERT INTO t1 VALUES (2, 0);
|
||||||
|
XA END '5';
|
||||||
|
XA PREPARE '5';
|
||||||
|
disconnect con1;
|
||||||
|
|
||||||
|
connection default;
|
||||||
|
--source include/wait_until_count_sessions.inc
|
||||||
|
INSERT INTO t1 VALUES (3, 0);
|
||||||
|
--error ER_XAER_NOTA
|
||||||
|
XA ROLLBACK '5';
|
||||||
|
DROP TABLE t1;
|
||||||
|
|
||||||
--echo #
|
--echo #
|
||||||
--echo # End of 10.5 tests
|
--echo # End of 10.5 tests
|
||||||
--echo #
|
--echo #
|
||||||
|
@ -280,4 +280,28 @@ disconnect con1;
|
|||||||
connection master;
|
connection master;
|
||||||
xa commit '1';
|
xa commit '1';
|
||||||
drop table t2, t1;
|
drop table t2, t1;
|
||||||
|
# MDEV-35019 Provide a way to enable "rollback XA on disconnect" behavior we had before 10.5.2
|
||||||
|
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
|
||||||
|
INSERT INTO t1 VALUES (1), (3);
|
||||||
|
connect con1, localhost,root;
|
||||||
|
SET SESSION legacy_xa_rollback_at_disconnect= 1;
|
||||||
|
XA START '3';
|
||||||
|
INSERT INTO t1 VALUES (2);
|
||||||
|
XA END '3';
|
||||||
|
XA PREPARE '3';
|
||||||
|
disconnect con1;
|
||||||
|
connection master;
|
||||||
|
include/save_master_gtid.inc
|
||||||
|
SELECT * FROM t1 ORDER BY a;
|
||||||
|
a
|
||||||
|
1
|
||||||
|
3
|
||||||
|
connection slave;
|
||||||
|
include/sync_with_master_gtid.inc
|
||||||
|
SELECT * FROM t1 ORDER BY a;
|
||||||
|
a
|
||||||
|
1
|
||||||
|
3
|
||||||
|
connection master;
|
||||||
|
DROP TABLE t1;
|
||||||
include/rpl_end.inc
|
include/rpl_end.inc
|
||||||
|
@ -289,6 +289,30 @@ disconnect con1;
|
|||||||
connection master;
|
connection master;
|
||||||
xa commit '1';
|
xa commit '1';
|
||||||
drop table t2, t1;
|
drop table t2, t1;
|
||||||
|
# MDEV-35019 Provide a way to enable "rollback XA on disconnect" behavior we had before 10.5.2
|
||||||
|
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
|
||||||
|
INSERT INTO t1 VALUES (1), (3);
|
||||||
|
connect con1, localhost,root;
|
||||||
|
SET SESSION legacy_xa_rollback_at_disconnect= 1;
|
||||||
|
XA START '3';
|
||||||
|
INSERT INTO t1 VALUES (2);
|
||||||
|
XA END '3';
|
||||||
|
XA PREPARE '3';
|
||||||
|
disconnect con1;
|
||||||
|
connection master;
|
||||||
|
include/save_master_gtid.inc
|
||||||
|
SELECT * FROM t1 ORDER BY a;
|
||||||
|
a
|
||||||
|
1
|
||||||
|
3
|
||||||
|
connection slave;
|
||||||
|
include/sync_with_master_gtid.inc
|
||||||
|
SELECT * FROM t1 ORDER BY a;
|
||||||
|
a
|
||||||
|
1
|
||||||
|
3
|
||||||
|
connection master;
|
||||||
|
DROP TABLE t1;
|
||||||
connection slave;
|
connection slave;
|
||||||
include/stop_slave.inc
|
include/stop_slave.inc
|
||||||
SET @@global.gtid_pos_auto_engines="";
|
SET @@global.gtid_pos_auto_engines="";
|
||||||
|
@ -434,3 +434,26 @@ disconnect con1;
|
|||||||
connection master;
|
connection master;
|
||||||
xa commit '1';
|
xa commit '1';
|
||||||
drop table t2, t1;
|
drop table t2, t1;
|
||||||
|
|
||||||
|
--echo # MDEV-35019 Provide a way to enable "rollback XA on disconnect" behavior we had before 10.5.2
|
||||||
|
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
|
||||||
|
INSERT INTO t1 VALUES (1), (3);
|
||||||
|
|
||||||
|
connect con1, localhost,root;
|
||||||
|
SET SESSION legacy_xa_rollback_at_disconnect= 1;
|
||||||
|
XA START '3';
|
||||||
|
INSERT INTO t1 VALUES (2);
|
||||||
|
XA END '3';
|
||||||
|
XA PREPARE '3';
|
||||||
|
--disconnect con1
|
||||||
|
|
||||||
|
--connection master
|
||||||
|
--source include/save_master_gtid.inc
|
||||||
|
SELECT * FROM t1 ORDER BY a;
|
||||||
|
|
||||||
|
--connection slave
|
||||||
|
--source include/sync_with_master_gtid.inc
|
||||||
|
SELECT * FROM t1 ORDER BY a;
|
||||||
|
|
||||||
|
--connection master
|
||||||
|
DROP TABLE t1;
|
||||||
|
@ -1532,6 +1532,16 @@ NUMERIC_BLOCK_SIZE NULL
|
|||||||
ENUM_VALUE_LIST NULL
|
ENUM_VALUE_LIST NULL
|
||||||
READ_ONLY NO
|
READ_ONLY NO
|
||||||
COMMAND_LINE_ARGUMENT NULL
|
COMMAND_LINE_ARGUMENT NULL
|
||||||
|
VARIABLE_NAME LEGACY_XA_ROLLBACK_AT_DISCONNECT
|
||||||
|
VARIABLE_SCOPE SESSION
|
||||||
|
VARIABLE_TYPE BOOLEAN
|
||||||
|
VARIABLE_COMMENT If a user session disconnects after putting a transaction into the XA PREPAREd state, roll back the transaction. Can be used for backwards compatibility to enable this pre-10.5 behavior for applications that expect it. Note that this violates the XA specification and should not be used for new code
|
||||||
|
NUMERIC_MIN_VALUE NULL
|
||||||
|
NUMERIC_MAX_VALUE NULL
|
||||||
|
NUMERIC_BLOCK_SIZE NULL
|
||||||
|
ENUM_VALUE_LIST OFF,ON
|
||||||
|
READ_ONLY NO
|
||||||
|
COMMAND_LINE_ARGUMENT OPTIONAL
|
||||||
VARIABLE_NAME LICENSE
|
VARIABLE_NAME LICENSE
|
||||||
VARIABLE_SCOPE GLOBAL
|
VARIABLE_SCOPE GLOBAL
|
||||||
VARIABLE_TYPE VARCHAR
|
VARIABLE_TYPE VARCHAR
|
||||||
|
@ -1642,6 +1642,16 @@ NUMERIC_BLOCK_SIZE NULL
|
|||||||
ENUM_VALUE_LIST NULL
|
ENUM_VALUE_LIST NULL
|
||||||
READ_ONLY NO
|
READ_ONLY NO
|
||||||
COMMAND_LINE_ARGUMENT NULL
|
COMMAND_LINE_ARGUMENT NULL
|
||||||
|
VARIABLE_NAME LEGACY_XA_ROLLBACK_AT_DISCONNECT
|
||||||
|
VARIABLE_SCOPE SESSION
|
||||||
|
VARIABLE_TYPE BOOLEAN
|
||||||
|
VARIABLE_COMMENT If a user session disconnects after putting a transaction into the XA PREPAREd state, roll back the transaction. Can be used for backwards compatibility to enable this pre-10.5 behavior for applications that expect it. Note that this violates the XA specification and should not be used for new code
|
||||||
|
NUMERIC_MIN_VALUE NULL
|
||||||
|
NUMERIC_MAX_VALUE NULL
|
||||||
|
NUMERIC_BLOCK_SIZE NULL
|
||||||
|
ENUM_VALUE_LIST OFF,ON
|
||||||
|
READ_ONLY NO
|
||||||
|
COMMAND_LINE_ARGUMENT OPTIONAL
|
||||||
VARIABLE_NAME LICENSE
|
VARIABLE_NAME LICENSE
|
||||||
VARIABLE_SCOPE GLOBAL
|
VARIABLE_SCOPE GLOBAL
|
||||||
VARIABLE_TYPE VARCHAR
|
VARIABLE_TYPE VARCHAR
|
||||||
|
@ -1553,7 +1553,12 @@ void THD::cleanup(void)
|
|||||||
close_temporary_tables();
|
close_temporary_tables();
|
||||||
|
|
||||||
if (transaction->xid_state.is_explicit_XA())
|
if (transaction->xid_state.is_explicit_XA())
|
||||||
trans_xa_detach(this);
|
{
|
||||||
|
if (unlikely(variables.legacy_xa_rollback_at_disconnect))
|
||||||
|
xa_trans_force_rollback(this);
|
||||||
|
else
|
||||||
|
trans_xa_detach(this);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
trans_rollback(this);
|
trans_rollback(this);
|
||||||
|
|
||||||
|
@ -788,6 +788,7 @@ typedef struct system_variables
|
|||||||
my_bool binlog_annotate_row_events;
|
my_bool binlog_annotate_row_events;
|
||||||
my_bool binlog_direct_non_trans_update;
|
my_bool binlog_direct_non_trans_update;
|
||||||
my_bool column_compression_zlib_wrap;
|
my_bool column_compression_zlib_wrap;
|
||||||
|
my_bool legacy_xa_rollback_at_disconnect;
|
||||||
|
|
||||||
plugin_ref table_plugin;
|
plugin_ref table_plugin;
|
||||||
plugin_ref tmp_table_plugin;
|
plugin_ref tmp_table_plugin;
|
||||||
|
@ -6788,3 +6788,13 @@ static Sys_var_ulonglong Sys_max_rowid_filter_size(
|
|||||||
SESSION_VAR(max_rowid_filter_size), CMD_LINE(REQUIRED_ARG),
|
SESSION_VAR(max_rowid_filter_size), CMD_LINE(REQUIRED_ARG),
|
||||||
VALID_RANGE(1024, (ulonglong)~(intptr)0), DEFAULT(128*1024),
|
VALID_RANGE(1024, (ulonglong)~(intptr)0), DEFAULT(128*1024),
|
||||||
BLOCK_SIZE(1));
|
BLOCK_SIZE(1));
|
||||||
|
|
||||||
|
static Sys_var_mybool Sys_legacy_xa_rollback_at_disconnect(
|
||||||
|
"legacy_xa_rollback_at_disconnect",
|
||||||
|
"If a user session disconnects after putting a transaction into the XA "
|
||||||
|
"PREPAREd state, roll back the transaction. Can be used for backwards "
|
||||||
|
"compatibility to enable this pre-10.5 behavior for applications that "
|
||||||
|
"expect it. Note that this violates the XA specification and should not "
|
||||||
|
"be used for new code",
|
||||||
|
SESSION_VAR(legacy_xa_rollback_at_disconnect), CMD_LINE(OPT_ARG),
|
||||||
|
DEFAULT(FALSE), NO_MUTEX_GUARD, NOT_IN_BINLOG);
|
||||||
|
1
sql/xa.h
1
sql/xa.h
@ -46,6 +46,7 @@ bool xid_cache_insert(XID *xid);
|
|||||||
bool xid_cache_insert(THD *thd, XID_STATE *xid_state, XID *xid);
|
bool xid_cache_insert(THD *thd, XID_STATE *xid_state, XID *xid);
|
||||||
void xid_cache_delete(THD *thd, XID_STATE *xid_state);
|
void xid_cache_delete(THD *thd, XID_STATE *xid_state);
|
||||||
|
|
||||||
|
bool xa_trans_force_rollback(THD *thd);
|
||||||
bool trans_xa_start(THD *thd);
|
bool trans_xa_start(THD *thd);
|
||||||
bool trans_xa_end(THD *thd);
|
bool trans_xa_end(THD *thd);
|
||||||
bool trans_xa_prepare(THD *thd);
|
bool trans_xa_prepare(THD *thd);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user