| 1 |
--source include/have_innodb.inc |
| 2 |
--source include/have_debug.inc |
| 3 |
--source include/have_debug_sync.inc |
| 4 |
# Embedded server does not support restarting |
| 5 |
--source include/not_embedded.inc |
| 6 |
|
| 7 |
--disable_query_log |
| 8 |
FLUSH TABLES; |
| 9 |
--enable_query_log |
| 10 |
|
| 11 |
--echo # |
| 12 |
--echo # Bug#20872655 XA ROLLBACK IS NOT CRASH-SAFE |
| 13 |
--echo # |
| 14 |
|
| 15 |
CREATE TABLE t(a INT PRIMARY KEY, b INT UNIQUE) ENGINE=INNODB; |
| 16 |
INSERT INTO t SET a=0; |
| 17 |
connect (con1,localhost,root); |
| 18 |
XA START 'zombie'; |
| 19 |
INSERT INTO t SET a=1; |
| 20 |
UPDATE t SET b=1 WHERE a=1; |
| 21 |
SELECT COUNT(*) FROM t; |
| 22 |
XA END 'zombie'; |
| 23 |
XA PREPARE 'zombie'; |
| 24 |
SET DEBUG_SYNC='trx_after_rollback_row SIGNAL s1 WAIT_FOR s2'; |
| 25 |
--send XA ROLLBACK 'zombie' |
| 26 |
connection default; |
| 27 |
SET DEBUG_SYNC='now WAIT_FOR s1'; |
| 28 |
# Ensure that the state change from XA PREPARE to ACTIVE gets flushed |
| 29 |
# to the redo log. Without this, it could be that we will recover to |
| 30 |
# a state that precedes the start of the XA ROLLBACK. |
| 31 |
SET GLOBAL innodb_flush_log_at_trx_commit=1; |
| 32 |
DELETE FROM t LIMIT 1; |
| 33 |
let $shutdown_timeout=0; |
| 34 |
--source include/restart_mysqld.inc |
| 35 |
disconnect con1; |
| 36 |
# If the trx_undo_set_state_at_prepare() is omitted at the start of |
| 37 |
# XA ROLLBACK, then the XA COMMIT would succeed and the table would |
| 38 |
# incorrectly show the result of the INSERT but not the UPDATE, |
| 39 |
# because we would commit a partially rolled back transaction. |
| 40 |
--error ER_XAER_NOTA |
| 41 |
XA COMMIT 'zombie'; |
| 42 |
SELECT * FROM t; |
| 43 |
DROP TABLE t; |