mirror of
https://github.com/MariaDB/server.git
synced 2026-02-22 18:49:01 +01:00
the only query of the XA transaction is on a non-transactional table errors out: XA BEGIN 'x'; --error ER_DUP_ENTRY INSERT INTO t1 VALUES (1),(1); XA END 'x'; XA PREPARE 'x'; The binlogging pattern is correctly started as expected with the errored-out Query or its ROW format events, but there is no empty XA_prepare_log_event group. The following XA COMMIT 'x'; therefore should not be logged either, but it does. The bug is fixed with proper maintaining of a read-write binlog hton property and use it to enforce correct binlogging decisions. Specifically in the bug description case XA COMMIT won't be binlogged in both when given in the same connection and externally after disconnect. The same continue to apply to an empty XA that do not change any data in all transactional engines involved.
175 lines
5.5 KiB
Text
175 lines
5.5 KiB
Text
#
|
|
# Purpose:
|
|
# This test ensures consistency in binlogging behavior for XA transactions
|
|
# that have all statements error and rollback, effectively leaving an "empty"
|
|
# transaction. In such cases, an empty XA transaction should be binlogged. The
|
|
# bug reported by MDEV-25616 revealed that an "empty" XA transaction would
|
|
# binlog an XA ROLLBACK or XA COMMIT event without a preceding setup, i.e.
|
|
# XA START through XA PREPARE. The bug presented differently for XA
|
|
# transactions consisting of transactional and non-transactional statements.
|
|
# Therefore, this test validates that an entire XA transaction is binlogged
|
|
# for different combinations of transactional or non-transactional statements.
|
|
# Note that the behavior changes when binlogging empty XA transactions
|
|
# depending on the binlog_row_format variables. That is, when the content of
|
|
# the transaction consists of errored transactional statements, in row format,
|
|
# an empty XA transaction will be binlogged; however, in mixed and statement
|
|
# formats, nothing will be written into the binary log.
|
|
#
|
|
# Methodology:
|
|
# Create XA transactions with various combinations of erroring transactional
|
|
# or non-transactional statements. The binary log is examined to ensure all
|
|
# XA components are written. Chain replication is used, i.e.
|
|
# (primary->replica->replica), to ensure replica binlogging is consistent with
|
|
# manual execution. The transactional and non-transactional tables use InnoDB
|
|
# and MyISAM, respectively.
|
|
#
|
|
# Parameters
|
|
# $expect_transactional_xa_binlog : Boolean indicating whether or not an
|
|
# errored transactional statement should result in XA statements written
|
|
# into the binary log.
|
|
#
|
|
# References:
|
|
# MDEV-25616: Binlog event for XA COMMIT is generated without matching
|
|
# XA START, replication aborts
|
|
#
|
|
--source include/have_log_bin.inc
|
|
|
|
--let $rpl_server_count= 3
|
|
--let $rpl_topology= 1->2->3
|
|
--source include/rpl_init.inc
|
|
|
|
--connection server_1
|
|
-- source include/have_innodb.inc
|
|
--connection server_2
|
|
-- source include/have_innodb.inc
|
|
--connection server_3
|
|
-- source include/have_innodb.inc
|
|
--connection server_1
|
|
|
|
--echo #
|
|
--echo # Test Case 1: An XA transaction without any statements should not be
|
|
--echo # binlogged
|
|
--let $trx_statements=
|
|
|
|
--let $xa_completion_action= COMMIT
|
|
--source include/rpl_xa_empty_transaction.inc
|
|
|
|
--let $xa_completion_action= ROLLBACK
|
|
--source include/rpl_xa_empty_transaction.inc
|
|
|
|
|
|
--echo #
|
|
--echo # Test Case 2: An XA transaction consisting of a successfully rolled back
|
|
--echo # statement should not be binlogged
|
|
--let $trx_statements= T
|
|
|
|
--let $xa_completion_action= COMMIT
|
|
--source include/rpl_xa_empty_transaction.inc
|
|
|
|
--let $xa_completion_action= ROLLBACK
|
|
--source include/rpl_xa_empty_transaction.inc
|
|
|
|
|
|
--echo #
|
|
--echo # Test Case 3: An XA transaction with a statement that cannot be rolled
|
|
--echo # back should be binlogged
|
|
|
|
# TODO: remove work-around MDEV-24654 when fixed.
|
|
--connection server_1
|
|
set @sav_binlog_format = @@binlog_format;
|
|
set @@binlog_format = row;
|
|
set @@global.binlog_format = row;
|
|
--let $trx_statements= N
|
|
|
|
--let $xa_completion_action= COMMIT
|
|
--source include/rpl_xa_empty_transaction.inc
|
|
|
|
--let $xa_completion_action= ROLLBACK
|
|
--source include/rpl_xa_empty_transaction.inc
|
|
|
|
--connection server_1
|
|
set @@binlog_format = @sav_binlog_format;
|
|
set @@global.binlog_format = @sav_binlog_format;
|
|
|
|
|
|
--echo #
|
|
--echo # Test Case 4: An XA transaction with multiple statements that can all
|
|
--echo # be rolled back should not be binlogged
|
|
--let $trx_statements= T,T
|
|
|
|
--let $xa_completion_action= COMMIT
|
|
--source include/rpl_xa_empty_transaction.inc
|
|
|
|
--let $xa_completion_action= ROLLBACK
|
|
--source include/rpl_xa_empty_transaction.inc
|
|
|
|
|
|
--echo #
|
|
--echo # Test Case 5: A mixed XA transaction consisting of one statement that
|
|
--echo # can successfully be rolled back (first statement), and another that
|
|
--echo # can not (second statement) should be binlogged
|
|
|
|
--connection server_1
|
|
set @sav_binlog_format = @@binlog_format;
|
|
set @@binlog_format = row;
|
|
set @@global.binlog_format = row;
|
|
--let $trx_statements= T,N
|
|
|
|
--let $xa_completion_action= COMMIT
|
|
--source include/rpl_xa_empty_transaction.inc
|
|
|
|
--let $xa_completion_action= ROLLBACK
|
|
--source include/rpl_xa_empty_transaction.inc
|
|
|
|
--connection server_1
|
|
set @@binlog_format = @sav_binlog_format;
|
|
set @@global.binlog_format = @sav_binlog_format;
|
|
|
|
|
|
--echo #
|
|
--echo # Test Case 6: A mixed XA transaction consisting of one statement that
|
|
--echo # cannot successfully be rolled back (first statement), and another that
|
|
--echo # can (second statement) should be binlogged
|
|
|
|
--connection server_1
|
|
set @sav_binlog_format = @@binlog_format;
|
|
set @@binlog_format = row;
|
|
set @@global.binlog_format = row;
|
|
--let $trx_statements= N,T
|
|
|
|
--let $xa_completion_action= COMMIT
|
|
--source include/rpl_xa_empty_transaction.inc
|
|
|
|
--let $xa_completion_action= ROLLBACK
|
|
--source include/rpl_xa_empty_transaction.inc
|
|
|
|
--connection server_1
|
|
set @@binlog_format = @sav_binlog_format;
|
|
set @@global.binlog_format = @sav_binlog_format;
|
|
|
|
--echo #
|
|
--echo # Test Case 7: An XA transaction consisting of two failed
|
|
--echo # non-transactional statements should be binlogged
|
|
|
|
--connection server_1
|
|
set @sav_binlog_format = @@binlog_format;
|
|
set @@binlog_format = row;
|
|
set @@global.binlog_format = row;
|
|
--let $trx_statements= N,N
|
|
|
|
--let $xa_completion_action= COMMIT
|
|
--source include/rpl_xa_empty_transaction.inc
|
|
|
|
--let $xa_completion_action= ROLLBACK
|
|
--source include/rpl_xa_empty_transaction.inc
|
|
|
|
--connection server_1
|
|
set @@binlog_format = @sav_binlog_format;
|
|
set @@global.binlog_format = @sav_binlog_format;
|
|
|
|
#
|
|
# Cleanup
|
|
--connection server_1
|
|
--source include/rpl_end.inc
|
|
|
|
--echo # End of rpl_xa_empty_transaction.test
|