From fb217449dce9f6996563d5aa257be01c12df4a11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 31 Mar 2020 15:10:54 +0300 Subject: [PATCH] MDEV-13626: Import and adapt innodb.xa_recovery_debug Adapt the test that was added in mysql/mysql-server@6b65d9032cbb6c1016cb09d056df6885e3d25dc6 but omitted in commit 2e814d4702d71a04388386a9f591d14a35980bfe. Instead of triggering a log checkpoint, we will only trigger a redo log flush before killing the server. Note: the mtr.commit() call in trx_rollback_for_mysql() will not actually make the undo log header page state change durable. A call to log_write_up_to(mtr.commit_lsn(), true) would do that. It is unclear what the originally reported bug scenario was. As long as innobase_rollback_by_xid() will not return without ensuring that the redo log has been durably written, we should be safe. --- .../suite/innodb/r/xa_recovery_debug.result | 27 ++++++++++++++ .../suite/innodb/t/xa_recovery_debug.test | 35 +++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 mysql-test/suite/innodb/r/xa_recovery_debug.result create mode 100644 mysql-test/suite/innodb/t/xa_recovery_debug.test diff --git a/mysql-test/suite/innodb/r/xa_recovery_debug.result b/mysql-test/suite/innodb/r/xa_recovery_debug.result new file mode 100644 index 00000000000..082fc96e198 --- /dev/null +++ b/mysql-test/suite/innodb/r/xa_recovery_debug.result @@ -0,0 +1,27 @@ +# +# Bug#20872655 XA ROLLBACK IS NOT CRASH-SAFE +# +CREATE TABLE t(a INT PRIMARY KEY, b INT UNIQUE) ENGINE=INNODB; +INSERT INTO t SET a=0; +connect con1,localhost,root; +XA START 'zombie'; +INSERT INTO t SET a=1; +UPDATE t SET b=1 WHERE a=1; +SELECT COUNT(*) FROM t; +COUNT(*) +2 +XA END 'zombie'; +XA PREPARE 'zombie'; +SET DEBUG_SYNC='trx_xa_rollback SIGNAL s1 WAIT_FOR s2'; +XA ROLLBACK 'zombie'; +connection default; +SET DEBUG_SYNC='now WAIT_FOR s1'; +SET GLOBAL innodb_flush_log_at_trx_commit=1; +DELETE FROM t LIMIT 1; +disconnect con1; +XA COMMIT 'zombie'; +ERROR XAE04: XAER_NOTA: Unknown XID +SELECT COUNT(*) FROM t; +COUNT(*) +0 +DROP TABLE t; diff --git a/mysql-test/suite/innodb/t/xa_recovery_debug.test b/mysql-test/suite/innodb/t/xa_recovery_debug.test new file mode 100644 index 00000000000..8b1f188a0e3 --- /dev/null +++ b/mysql-test/suite/innodb/t/xa_recovery_debug.test @@ -0,0 +1,35 @@ +--source include/have_innodb.inc +--source include/have_debug.inc +--source include/have_debug_sync.inc +# Embedded server does not support restarting +--source include/not_embedded.inc + +--echo # +--echo # Bug#20872655 XA ROLLBACK IS NOT CRASH-SAFE +--echo # + +CREATE TABLE t(a INT PRIMARY KEY, b INT UNIQUE) ENGINE=INNODB; +INSERT INTO t SET a=0; +connect (con1,localhost,root); +XA START 'zombie'; +INSERT INTO t SET a=1; +UPDATE t SET b=1 WHERE a=1; +SELECT COUNT(*) FROM t; +XA END 'zombie'; +XA PREPARE 'zombie'; +SET DEBUG_SYNC='trx_xa_rollback SIGNAL s1 WAIT_FOR s2'; +--send XA ROLLBACK 'zombie' +connection default; +SET DEBUG_SYNC='now WAIT_FOR s1'; +# Ensure that the state change from XA PREPARE to ACTIVE gets flushed +# to the redo log. Without this, it could be that we will recover to +# a state that precedes the start of the XA ROLLBACK. +SET GLOBAL innodb_flush_log_at_trx_commit=1; +DELETE FROM t LIMIT 1; +let $shutdown_timeout=0; +--source include/restart_mysqld.inc +disconnect con1; +--error ER_XAER_NOTA +XA COMMIT 'zombie'; +SELECT COUNT(*) FROM t; +DROP TABLE t;