summaryrefslogtreecommitdiffstats
path: root/mysql-test/suite/innodb/t/xa_recovery_debug.test
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test/suite/innodb/t/xa_recovery_debug.test')
-rw-r--r--mysql-test/suite/innodb/t/xa_recovery_debug.test43
1 files changed, 43 insertions, 0 deletions
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 00000000..ada2940e
--- /dev/null
+++ b/mysql-test/suite/innodb/t/xa_recovery_debug.test
@@ -0,0 +1,43 @@
+--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
+
+--disable_query_log
+FLUSH TABLES;
+--enable_query_log
+
+--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_after_rollback_row 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;
+# If the trx_undo_set_state_at_prepare() is omitted at the start of
+# XA ROLLBACK, then the XA COMMIT would succeed and the table would
+# incorrectly show the result of the INSERT but not the UPDATE,
+# because we would commit a partially rolled back transaction.
+--error ER_XAER_NOTA
+XA COMMIT 'zombie';
+SELECT * FROM t;
+DROP TABLE t;