| 1 |
# ==== Purpose ==== |
| 2 |
# |
| 3 |
# The purpose of this test is to ensure that the server properly disregards XA |
| 4 |
# transaction related statements that try to operate upon an unknown XID, when |
| 5 |
# on SBR. |
| 6 |
# |
| 7 |
# ==== Requirements ==== |
| 8 |
# |
| 9 |
# R1. Ensure that execution proceeds normaly after trying - and failling - to |
| 10 |
# execute `XA COMMIT / ROLLBACK` with an unkown XID. |
| 11 |
# |
| 12 |
# ==== Implementation ==== |
| 13 |
# |
| 14 |
# Ensure that the server properly disregards XA related statements that operate |
| 15 |
# on unknown XIDs given the following setup / statements combinations: |
| 16 |
# |
| 17 |
# TC1. Manual GTID and apply `XA ROLLBACK` with unkown XID |
| 18 |
# -------------------------------------------------------- |
| 19 |
# 1) Ensure that `AUTOCOMMIT` is OFF. |
| 20 |
# 2) Set `GTID_NEXT` to manually introduced value. |
| 21 |
# 3) Execute a DML statement. |
| 22 |
# 4) Execute `XA ROLLBACK` with an unknown XID. |
| 23 |
# 5) Set `AUTOCOMMIT` to the default value so that the DML statement gets |
| 24 |
# commited. |
| 25 |
# |
| 26 |
# TC2. Manual GTID and apply `XA ROLLBACK` with unkown XID |
| 27 |
# -------------------------------------------------------- |
| 28 |
# 1) Ensure that `AUTOCOMMIT` is OFF. |
| 29 |
# 2) Set `GTID_NEXT` to manually introduced value. |
| 30 |
# 3) Execute a DML statement. |
| 31 |
# 4) Execute `XA ROLLBACK` with an unknown XID. |
| 32 |
# 5) Set `AUTOCOMMIT` to the default value so that the DML statement gets |
| 33 |
# commited. |
| 34 |
# |
| 35 |
# TC3. Manual GTID and apply `XA ROLLBACK` to an existent XA transaction |
| 36 |
# -------------------------------------------------------------------- |
| 37 |
# 1) Ensure that `AUTOCOMMIT` is OFF. |
| 38 |
# 2) Set `GTID_NEXT` to manually introduced value. |
| 39 |
# 3) Execute a DML statement. |
| 40 |
# 4) Execute `XA ROLLBACK` with an existent XID. |
| 41 |
# 5) Set `AUTOCOMMIT` to the default value so that the DML statement gets |
| 42 |
# commited. |
| 43 |
# |
| 44 |
# TC4. Manual GTID and apply `XA COMMIT` to an existent XA transaction |
| 45 |
# ----------------------------------------------------------------------- |
| 46 |
# 1) Ensure that `AUTOCOMMIT` is OFF. |
| 47 |
# 2) Set `GTID_NEXT` to manually introduced value. |
| 48 |
# 3) Execute a DML statement. |
| 49 |
# 4) Execute `XA COMMIT` with an existent XID. |
| 50 |
# 5) Set `AUTOCOMMIT` to the default value so that the DML statement gets |
| 51 |
# commited. |
| 52 |
# |
| 53 |
# ==== References ==== |
| 54 |
# |
| 55 |
# BUG#27928837 `HEAD->VARIABLES.GTID_NEXT.TYPE != UNDEFINED_GTID` |
| 56 |
|
| 57 |
--let $current_autocommit= `SELECT @@AUTOCOMMIT` |
| 58 |
|
| 59 |
CREATE TABLE t2(a INT); |
| 60 |
|
| 61 |
# TC1. Manual GTID and apply `XA ROLLBACK` with unkown XID |
| 62 |
# -------------------------------------------------------- |
| 63 |
# 1) Ensure that `AUTOCOMMIT` is OFF. |
| 64 |
SET @@AUTOCOMMIT=0; |
| 65 |
# 2) Set `GTID_NEXT` to manually introduced value. |
| 66 |
SET SESSION GTID_NEXT='aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee:1'; |
| 67 |
# 3) Execute a DML statement. |
| 68 |
INSERT INTO t2 VALUES(1); |
| 69 |
# 4) Execute `XA ROLLBACK` with an unknown XID. |
| 70 |
--error ER_XAER_RMFAIL |
| 71 |
XA ROLLBACK 'xa1'; |
| 72 |
# 5) Set `AUTOCOMMIT` to the default value so that the DML statement gets |
| 73 |
# commited. |
| 74 |
SET @@AUTOCOMMIT=1; |
| 75 |
# |
| 76 |
|
| 77 |
# TC2. Manul GTID and apply `XA ROLLBACK` with unkown XID |
| 78 |
# ----------------------------------------------------------- |
| 79 |
# 1) Ensure that `AUTOCOMMIT` is OFF. |
| 80 |
SET @@AUTOCOMMIT=0; |
| 81 |
# 2) Set `GTID_NEXT` to manually introduced value. |
| 82 |
SET SESSION GTID_NEXT='aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee:2'; |
| 83 |
# 3) Execute a DML statement. |
| 84 |
INSERT INTO t2 VALUES(2); |
| 85 |
# 4) Execute `XA COMMIT` with an unknown XID. |
| 86 |
--error ER_XAER_RMFAIL |
| 87 |
XA COMMIT 'xa1'; |
| 88 |
# 5) Set `AUTOCOMMIT` to the default value so that the DML statement gets |
| 89 |
# commited. |
| 90 |
SET @@AUTOCOMMIT=1; |
| 91 |
# |
| 92 |
|
| 93 |
--connect (other_conn, 127.0.0.1,root,,test,$MASTER_MYPORT,) |
| 94 |
XA START 'xa1'; |
| 95 |
XA END 'xa1'; |
| 96 |
XA PREPARE 'xa1'; |
| 97 |
--let $connection_id= `SELECT CONNECTION_ID()` |
| 98 |
--disconnect other_conn |
| 99 |
# Wait for the `other_conn` to be cleared from the server |
| 100 |
--connection default |
| 101 |
--let $wait_condition = SELECT COUNT(*) = 0 FROM information_schema.processlist WHERE id = '$connection_id' |
| 102 |
--source include/wait_condition.inc |
| 103 |
|
| 104 |
--connection default |
| 105 |
# TC3. Manual GTID and apply `XA ROLLBACK` to an existent XA transaction |
| 106 |
# -------------------------------------------------------------------- |
| 107 |
# 1) Ensure that `AUTOCOMMIT` is OFF. |
| 108 |
SET @@AUTOCOMMIT=0; |
| 109 |
# 2) Set `GTID_NEXT` to manually introduced value. |
| 110 |
SET SESSION GTID_NEXT='aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee:3'; |
| 111 |
# 3) Execute a DML statement. |
| 112 |
INSERT INTO t2 VALUES(3); |
| 113 |
# 4) Execute `XA ROLLBACK` with an existent XID. |
| 114 |
--error ER_XAER_RMFAIL |
| 115 |
XA ROLLBACK 'xa1'; |
| 116 |
# 5) Set `AUTOCOMMIT` to the default value so that the DML statement gets |
| 117 |
# commited. |
| 118 |
SET @@AUTOCOMMIT=1; |
| 119 |
# |
| 120 |
|
| 121 |
# TC4. Manual GTID and apply `XA COMMIT` to an existent XA transaction |
| 122 |
# ----------------------------------------------------------------------- |
| 123 |
# 1) Ensure that `AUTOCOMMIT` is OFF. |
| 124 |
SET @@AUTOCOMMIT=0; |
| 125 |
# 2) Set `GTID_NEXT` to manually introduced value. |
| 126 |
SET SESSION GTID_NEXT='aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee:4'; |
| 127 |
# 3) Execute a DML statement. |
| 128 |
INSERT INTO t2 VALUES(4); |
| 129 |
# 4) Execute `XA COMMIT` with an existent XID. |
| 130 |
--error ER_XAER_RMFAIL |
| 131 |
XA COMMIT 'xa1'; |
| 132 |
# 5) Set `AUTOCOMMIT` to the default value so that the DML statement gets |
| 133 |
# commited. |
| 134 |
SET @@AUTOCOMMIT=1; |
| 135 |
# |
| 136 |
|
| 137 |
--let $assert_text= All inserts were committed, XA statements and respective failures, were disregarded |
| 138 |
--let $assert_cond= "[SELECT COUNT(1) FROM t2]" = "4" |
| 139 |
--source include/assert.inc |
| 140 |
|
| 141 |
# CLEAN UP |
| 142 |
SET SESSION GTID_NEXT='AUTOMATIC'; |
| 143 |
XA ROLLBACK 'xa1'; |
| 144 |
--let $pending = query_get_value(XA RECOVER, data, 1) |
| 145 |
--let $assert_text= All XA transactions were cleared |
| 146 |
--let $assert_cond= "$pending" = "No such row" |
| 147 |
--source include/assert.inc |
| 148 |
DROP TABLE t2; |
| 149 |
--replace_result $current_autocommit DEFAULT_AUTOCOMMIT |
| 150 |
--eval SET @@AUTOCOMMIT=$current_autocommit |
| 151 |
RESET MASTER; |