mariadb/client
Brandon Nesterenko ea9869504d MDEV-33921: Replication breaks when filtering two-phase XA transactions
There are two problems.

First, replication fails when XA transactions are used where the
slave has replicate_do_db set and the client has touched a different
database when running DML such as inserts. This is because XA
commands are not treated as keywords, and are thereby not exempt
from the replication filter. The effect of this is that during an XA
transaction, if its logged “use db” from the master is filtered out
by the replication filter, then XA END will be ignored, yet its
corresponding XA PREPARE will be executed in an invalid state,
thereby breaking replication.

Second, if the slave replicates an XA transaction which results in
an empty transaction, the XA START through XA PREPARE first phase of
the transaction won’t be binlogged, yet the XA COMMIT will be
binlogged. This will break replication in chain configurations.

The first problem is fixed by treating XA commands in
Query_log_event as keywords, thus allowing them to bypass the
replication filter. Note that Query_log_event::is_trans_keyword() is
changed to accept a new parameter to define its mode, to either
check for XA commands or regular transaction commands, but not both.
In addition, mysqlbinlog is adapted to use this mode so its
--database filter does not remove XA commands from its output.

The second problem fixed by overwriting the XA state in the XID
cache to be XA_ROLLBACK_ONLY, so at commit time, the server knows to
rollback the transaction and skip its binlogging. If the xid cache
is cleared before an XA transaction receives its completion command
(e.g. on server shutdown), then before reporting ER_XAER_NOTA when
the completion command is executed, the filter is first checked if
the database is ignored, and if so, the error is ignored.

Reviewed By:
============
Kristian Nielsen <knielsen@knielsen-hq.org>
Andrei Elkin <andrei.elkin@mariadb.com>
2024-07-10 14:37:39 -06:00
..
async_example.c MWL#192: non-blocking client API, after-review fixes. 2012-01-06 12:43:18 +01:00
client_metadata.h MDEV-17832 Protocol: extensions for Pluggable types and JSON, GEOMETRY 2020-03-10 20:43:32 +04:00
client_priv.h cleanup: unused OPT_xxx and client_priv.h 2024-05-06 17:16:10 +02:00
CMakeLists.txt MDEV-33876 CMake, zlib - use names compatible with official FindZLIB.cmake 2024-05-03 21:48:47 +02:00
completion_hash.cc Merge 10.4 into 10.5 2020-11-03 16:24:47 +02:00
completion_hash.h Update FSF Address 2019-05-11 21:29:06 +03:00
echo.c Fix typos in the codebase. 2022-08-09 18:41:09 +03:00
mariadb-conv.cc Added 'const' to arguments in get_one_option and find_typeset() 2021-02-08 12:16:29 +02:00
my_readline.h Update FSF Address 2019-05-11 21:29:06 +03:00
mysql.cc MDEV-34406 Enhance mariadb_upgrade to print failing query in case of error 2024-06-16 10:51:33 +03:00
mysql_plugin.c MDEV-34266 safe_strcpy() includes an unnecessary conditional branch 2024-06-07 19:24:36 +03:00
mysql_upgrade.c MDEV-34406 Enhance mariadb_upgrade to print failing query in case of error 2024-06-16 10:51:33 +03:00
mysqladmin.cc Fix Various Typos 2024-05-28 11:31:49 +10:00
mysqlbinlog.cc MDEV-33921: Replication breaks when filtering two-phase XA transactions 2024-07-10 14:37:39 -06:00
mysqlcheck.c cleanup: unused OPT_xxx and client_priv.h 2024-05-06 17:16:10 +02:00
mysqldump.c Change mysqldump to use DO instead of 'SELECT' for storing sequences. 2024-06-16 10:51:33 +03:00
mysqlimport.c Fix Various Typos 2024-05-28 11:31:49 +10:00
mysqlshow.c cleanup: unused OPT_xxx and client_priv.h 2024-05-06 17:16:10 +02:00
mysqlslap.c cleanup: unused OPT_xxx and client_priv.h 2024-05-06 17:16:10 +02:00
mysqltest.cc MDEV-33616 workaround libmariadb bug : mysql_errno = 0 on failed connection 2024-06-11 09:15:32 +02:00
readline.cc perfschema memory related instrumentation changes 2020-03-10 19:24:22 +01:00