Debian Codegraph @

mysql-test/suite/innodb/t/xa_another.test

raw
1 --source include/count_sessions.inc
2 --echo # The specific purpose of this test is to test the
3 --echo # detach at disconnect behavior
4 SET @saved_xa_detach_on_prepare = @@GLOBAL.xa_detach_on_prepare;
5 SET GLOBAL xa_detach_on_prepare = OFF;
6 CREATE TABLE t (id INT PRIMARY KEY);
7
8 --connect (con1, localhost, root,,)
9 XA START "xa1";
10 INSERT INTO t VALUES (1);
11 XA END "xa1";
12 XA PREPARE "xa1";
13
14 --connect (con2, localhost, root,,)
15 # Trying to commit by XID from another connection, should fail
16 # if there is still a client connected to it
17 --error ER_XAER_NOTA
18 XA COMMIT "xa1";
19 # same for rollback
20 --error ER_XAER_NOTA
21 XA ROLLBACK "xa1";
22 # Yet the transaction's XID should appear in the XA RECOVER output
23 XA RECOVER;
24
25 # We disconnect a client from "xa1", so that it becomes available for con2
26 --connection con1
27 --disconnect con1
28 --source include/wait_until_disconnected.inc
29
30 --connection default
31 let $wait_condition=
32 SELECT COUNT(1)=0
33 FROM information_schema.innodb_trx
34 WHERE trx_mysql_thread_id>0;
35 --source include/wait_condition.inc
36
37 --connection con2
38 # Check that the XID is still visible
39 XA RECOVER;
40 # Trying to commit an abandoned XID should now succeed
41 XA COMMIT "xa1";
42 # And it should no longer appear in the list of available XIDs
43 XA RECOVER;
44 # Trying to commit it again, should fail
45 --error ER_XAER_NOTA
46 XA COMMIT "xa1";
47
48 --connection default
49
50 --disconnect con2
51
52 DROP TABLE t;
53
54 SET GLOBAL xa_detach_on_prepare = @saved_xa_detach_on_prepare;
55 --source include/wait_until_count_sessions.inc