1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375
|
# Skipping the test when logbin is enabled due to Bug#22292900
--source include/not_log_bin.inc
# This file contains XA-related test cases that requires mysql server
# built with debug.
--source include/not_valgrind.inc
--source include/have_debug.inc
# Test requires --xa_detach_on_prepare
--let $option_name = xa_detach_on_prepare
--let $option_value = 1
--source include/only_with_option.inc
--disable_query_log
call mtr.add_suppression("Found 1 prepared XA transactions");
--enable_query_log
--echo #
--echo # WL#7155: Test 1: check that prepared transaction branch
--echo # is recovered after abnormal server termination.
--echo #
CREATE TABLE t1 (a INT) ENGINE=INNODB;
XA START 'xid1';
INSERT INTO t1 VALUES (1);
XA END 'xid1';
XA PREPARE 'xid1';
--disable_query_log
set session debug="+d,crash_after_xa_recover";
--enable_query_log
# Write file to make mysql-test-run.pl wait for the server to stop
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--error 2013
XA RECOVER;
# Call script that will poll the server waiting for it to disappear
--source include/wait_until_disconnected.inc
--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--source include/start_mysqld.inc
--disable_query_log
set session debug="-d,crash_after_xa_recover";
--enable_query_log
XA RECOVER;
SELECT * FROM t1;
XA COMMIT 'xid1';
SELECT * FROM t1;
DROP TABLE t1;
--echo #
--echo # WL#7155: Test 2: check that in case of abnormal server termination
--echo # the changes done by unprepared transaction branch will be rolled back
--echo # after the server restart.
--echo #
CREATE TABLE t1 (a INT) ENGINE=INNODB;
XA START 'xid1';
INSERT INTO t1 VALUES (1);
XA END 'xid1';
--disable_query_log
set session debug="+d,crash_after_xa_recover";
--enable_query_log
# Write file to make mysql-test-run.pl wait for the server to stop
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--error 2013
XA RECOVER;
# Call script that will poll the server waiting for it to disappear
--source include/wait_until_disconnected.inc
--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--source include/start_mysqld.inc
--disable_query_log
set session debug="-d,crash_after_xa_recover";
--enable_query_log
XA RECOVER;
SELECT * FROM t1;
DROP TABLE t1;
--echo #
--echo # WL#7155: Test 3: Check that escaped "'" symbol for xid value
--echo # is handled correctly during recovering XA transaction.
--echo #
CREATE TABLE t1 (a INT) ENGINE=INNODB;
XA START 'xid1', 'br\'_1';
INSERT INTO t1 VALUES (1);
XA END 'xid1', 'br\'_1';
XA PREPARE 'xid1', 'br\'_1';
--disable_query_log
set session debug="+d,crash_after_xa_recover";
--enable_query_log
# Write file to make mysql-test-run.pl wait for the server to stop
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--error 2013
XA RECOVER;
# Call script that will poll the server waiting for it to disappear
--source include/wait_until_disconnected.inc
--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--source include/start_mysqld.inc
--disable_query_log
set session debug="-d,crash_after_xa_recover";
--enable_query_log
XA RECOVER;
XA ROLLBACK 'xid1', 'br\'_1';
DROP TABLE t1;
--echo #
--echo # Bug#18068253 - XA START WITH THE EXIST XID, AND THEN XA COMMIT WITH THE XID WILL FAILED
--echo #
CREATE TABLE t1 (a INT) ENGINE=INNODB;
XA START 'xid1';
INSERT INTO t1 VALUES (1);
XA END 'xid1';
XA PREPARE 'xid1';
set session debug="+d,crash_after_xa_recover";
# Write file to make mysql-test-run.pl wait for the server to stop
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--error 2013
XA RECOVER;
# Call script that will poll the server waiting for it to disappear
--source include/wait_until_disconnected.inc
--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--source include/start_mysqld.inc
set session debug="-d,crash_after_xa_recover";
XA RECOVER;
--error ER_XAER_DUPID
XA START 'xid1';
XA COMMIT 'xid1';
DROP TABLE t1;
--echo #
--echo # Bug#20538956 - XA PREPARE ERROR BRANCH LEAVES THE TRANSACTION IN SCREWED STATE
--echo #
--connect (con1, 127.0.0.1,root,,test,$MASTER_MYPORT,)
CREATE TABLE t1 (a INT);
XA START 'xid1';
INSERT INTO t1 VALUES (1);
XA END 'xid1';
SET @@session.debug = '+d,simulate_xa_failure_prepare';
--error ER_XA_RBROLLBACK
XA PREPARE 'xid1';
SET @@session.debug = '-d,simulate_xa_failure_prepare';
--error ER_XAER_NOTA
XA ROLLBACK 'xid1';
#
# The following query failed before patch applied.
#
XA START 'trx_another_one';
--disconnect con1
--connection default
--echo #
--echo # Bug#20488921 - ERROR PROPAGATION DOES NOT FULLY WORK IN XA
--echo #
--let $CURSESS_xa_detach_on_prepare = `SELECT @@SESSION.xa_detach_on_prepare`
SET SESSION xa_detach_on_prepare = OFF;
XA START 'xid1';
INSERT INTO t1 VALUES (1);
XA END 'xid1';
XA PREPARE 'xid1';
SET @@session.debug= '+d,simulate_xa_commit_log_failure';
--error ER_XAER_RMERR
XA COMMIT 'xid1';
# Without a patch for the bug#20488921 execution of the following SET statement
# led to an assert firing.
SET @@session.debug= '-d,simulate_xa_commit_log_failure';
# The following statement is just to check that there isn't any XA transaction
# independently from its state.
INSERT INTO t1 VALUES (2);
DROP TABLE t1;
--replace_result $CURSESS_xa_detach_on_prepare OLD_VALUE_xa_detach_on_prepare
--eval SET SESSION xa_detach_on_prepare = $CURSESS_xa_detach_on_prepare
--echo #
--echo # Bug#23264552 - XA: ASSERT `m_status == da_error' IN mysql_errno:sql_error.h:385
--echo #
--connect (con1, 127.0.0.1,root,,test,$MASTER_MYPORT,)
CREATE TABLE t1 (a INT);
XA START 'xid1';
INSERT INTO t1 VALUES (1);
XA END 'xid1';
SET @@session.debug = '+d,simulate_xa_failure_prepare_in_engine';
--error ER_XA_RBROLLBACK
XA PREPARE 'xid1';
SET @@session.debug = '-d,simulate_xa_failure_prepare_in_engine';
--error ER_XAER_NOTA
XA ROLLBACK 'xid1';
#
# Check that subsequent XA transaction can be initiated.
#
XA START 'trx_another_one';
--disconnect con1
--source include/wait_until_disconnected.inc
--connection default
DROP TABLE t1;
--echo #
--echo # BUG#29293279 -- XA COMMIT MAY LEAD REPLICATION BROKEN
--echo #
--echo Establish session con1
connect (con1,localhost,root,,);
CREATE TABLE t1(a INT);
XA START 'xid1';
INSERT INTO t1 VALUES (1);
XA END 'xid1';
XA PREPARE 'xid1';
--echo Disconnect con1 to save the XA transaction with xid1 into the cache
--disconnect con1
--source include/wait_until_disconnected.inc
--enable_connect_log
connect (con2,localhost,root,,);
set debug_sync='detached_xa_commit_after_acquire_commit_lock SIGNAL parked WAIT_FOR go';
--send XA COMMIT 'xid1'
--connection default
set debug_sync='now WAIT_FOR parked';
set debug_sync='detached_xa_commit_before_acquire_xa_lock SIGNAL go';
--error ER_XAER_NOTA
XA COMMIT 'xid1';
DROP TABLE t1;
--disable_connect_log
--echo #
--echo # Bug#32025408: MAIN.XA_PREPARED_BINLOG_OFF,BINLOG.BINLOG_XA_PREPARED_DISCON FAILS ON ASAN/UBSAN
--echo #
--source include/have_debug_sync.inc
CREATE TABLE t1(i INT);
--echo # Create a connection which as non-prepared XA trans.
connect(conA,localhost,root,,);
XA START 'trx1';
INSERT INTO t1 set i=0;
XA END 'trx1';
--echo # Create new connection which will execute XA COMMIT and be blocked between search in transaction cache and
--echo # accessing xid_state (to see if txn can be committed).
connect(conB,localhost,root,,);
SET DEBUG_SYNC="before_accessing_xid_state SIGNAL proceed_disconnect WAIT_FOR proceed_check_xid_state";
--send XA COMMIT 'trx1'
--echo # Terminate conA which will delete the Transaction_ctx and with it the XID_STATE
--connection conA
SET DEBUG_SYNC="now WAIT_FOR proceed_disconnect";
--disconnect conA
--source include/wait_until_disconnected.inc
--connection default
--echo # Unblock XA COMMIT. Without fix this will access the now freed memory, and trigger ASAN error.
SET DEBUG_SYNC="now SIGNAL proceed_check_xid_state";
--connection conB
--error ER_XAER_NOTA
--reap
--disconnect conB
--connection default
DROP TABLE t1;
# Uses DBUG_EVALUATE_IF to simulate errors in various functions called during
# XA PREPARE, to verify that transaction handling works as expected.
--echo # Test error handling in XA PREPARE.
CREATE TABLE t1(d VARCHAR(128));
XA START 'xid1';
INSERT INTO t1 VALUES ('I: The first string'), ('I: The second string');
--echo # Test errors which leave the XA transaction in place
--error ER_XAER_RMFAIL
XA PREPARE 'xid1';
XA END 'xid1';
--error ER_XAER_NOTA
XA PREPARE 'xidX';
XA ROLLBACK 'xid1';
SELECT * FROM t1;
XA START 'xid2';
INSERT INTO t1 VALUES ('II: The first string'), ('II: The second string');
XA END 'xid2';
SET DEBUG = "+d,xaprep_mdl_fail";
--error ER_XA_RBROLLBACK
XA PREPARE 'xid2';
SET DEBUG = "-d,xaprep_mdl_fail";
SELECT * FROM t1;
XA START 'xid3';
INSERT INTO t1 VALUES ('III: The first string'), ('III: The second string');
XA END 'xid3';
SET DEBUG = "+d,xaprep_ha_xa_prepare_fail";
--error ER_XA_RBROLLBACK
XA PREPARE 'xid3';
SET DEBUG = "-d,xaprep_ha_xa_prepare_fail";
SELECT * FROM t1;
XA START 'xid4';
INSERT INTO t1 VALUES ('IV: The first string'), ('IV: The second string');
XA END 'xid4';
SET DEBUG = "+d,xaprep_create_mdl_backup_fail";
--error ER_OUT_OF_RESOURCES
XA PREPARE 'xid4';
SHOW ERRORS;
SET DEBUG = "-d,xaprep_create_mdl_backup_fail";
SELECT * FROM t1;
XA START 'xid5';
INSERT INTO t1 VALUES ('V: The first string'), ('V: The second string');
XA END 'xid5';
SET DEBUG = "+d,xaprep_trans_detach_fail";
--error ER_XA_RBROLLBACK
XA PREPARE 'xid5';
SET DEBUG = "-d,xaprep_trans_detach_fail";
SELECT * FROM t1;
--echo # Cleanup
XA RECOVER;
DROP TABLE t1;
|