| 1 |
|
| 2 |
############################################################ |
| 3 |
# 1. Prepare the data for the test. |
| 4 |
CREATE TABLE t1 (c1 INT PRIMARY KEY); |
| 5 |
|
| 6 |
############################################################ |
| 7 |
# 2. Execute a XA PREPARE with id '1'. |
| 8 |
XA START 'xid1'; |
| 9 |
INSERT INTO t1 VALUES (1); |
| 10 |
XA END 'xid1'; |
| 11 |
XA PREPARE 'xid1'; |
| 12 |
# Waiting for the connection server1_conn2 disappeared on the server side |
| 13 |
|
| 14 |
############################################################ |
| 15 |
# 3. Force a local failure in before_commit listener on the |
| 16 |
# XA COMMIT. |
| 17 |
# Wait until a record about a prepared XA transaction be found in output of XA RECOVER. |
| 18 |
# Having two conditions satisfied (first one for disappeared connection server1_conn2 |
| 19 |
# and the second one for presence of the prepared XA transaction with xid value equaled xid1) |
| 20 |
# guarantees that the connection server1_conn2 was really closed and a prepared XA transaction |
| 21 |
# with xid1 was really placed into an internal server cache of prepared XA transactions. |
| 22 |
# Output result of XA RECOVER into result file for sanity check. |
| 23 |
XA RECOVER; |
| 24 |
formatID gtrid_length bqual_length data |
| 25 |
1 4 0 xid1 |
| 26 |
SET @debug_save= @@GLOBAL.DEBUG; |
| 27 |
SET @@GLOBAL.DEBUG= '+d,simulate_failure_in_before_commit_hook'; |
| 28 |
XA COMMIT 'xid1'; |
| 29 |
ERROR HY000: Error on observer while running replication hook 'before_commit'. |
| 30 |
SHOW ERRORS; |
| 31 |
Level Code Message |
| 32 |
Error 3100 Error on observer while running replication hook 'before_commit'. |
| 33 |
SET @@GLOBAL.DEBUG= @debug_save; |
| 34 |
|
| 35 |
############################################################ |
| 36 |
# 4. Clean up. |
| 37 |
DROP TABLE t1; |
| 38 |
# restart |
| 39 |
CALL mtr.add_suppression("Found 1 prepared XA transactions"); |
| 40 |
XA ROLLBACK 'xid1'; |