mirror of
https://github.com/MariaDB/server.git
synced 2025-11-28 17:36:30 +03:00
Improve the test that was imported and adapted for MariaDB in
commit fb217449dc.
row_undo_step(): Move the DEBUG_SYNC point from trx_rollback_for_mysql().
This DEBUG_SYNC point is executed after rolling back one row.
trx_rollback_for_mysql(): Clarify the comments that describe the scenario,
and remove the DEBUG_SYNC point.
If the statement "if (trx->has_logged_persistent())" and its body are
removed from trx_rollback_for_mysql(), then the test
innodb.xa_recovery_debug will fail because the transaction would still
exist in the XA PREPARE state. If we allow the XA COMMIT statement
to succeed in the test, we would observe an incorrect state of the
XA transaction where the table would contain row (1,NULL). Depending
on whether the XA transaction was committed, the table should either
be empty or contain the record (1,1). The intermediate state of
(1,NULL) should never be observed after completed recovery.
40 lines
1.3 KiB
Plaintext
40 lines
1.3 KiB
Plaintext
--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_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;
|