Debian Codegraph @

mysql-test/suite/innodb/r/trx_deadlock.result

raw
1 #
2 # MDEV-36959 Deadlock does not rollback transaction fully
3 #
4 CREATE TABLE t1(col1 INT PRIMARY KEY, col2 INT) ENGINE=InnoDB;
5 INSERT INTO t1 VALUES (1, 1), (2, 2);
6 SELECT * FROM t1;
7 col1 col2
8 1 1
9 2 2
10 connect con1,localhost,root,,;
11 START TRANSACTION;
12 # Trx-1: Lock 1st record
13 UPDATE t1 SET col2=10 where col1=1;
14 connection default;
15 START TRANSACTION;
16 # Trx-2: Lock 2nd record
17 UPDATE t1 SET col2=100 where col1=2;
18 connection con1;
19 # Trx-1: Try locking 1st record : Wait
20 UPDATE t1 SET col2=10 where col1=2;
21 connection default;
22 # Wait for Trx-1 to get into lock wait stage
23 # Trx-2: Try locking 2nd record : Deadlock
24 UPDATE t1 SET col2=100 where col1=1;
25 ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
26 connection con1;
27 ROLLBACK;
28 connection default;
29 SELECT @@in_transaction;
30 @@in_transaction
31 0
32 UPDATE t1 SET col2=10 where col1=1;
33 UPDATE t1 SET col2=100 where col1=2;
34 SELECT @@in_transaction;
35 @@in_transaction
36 0
37 ROLLBACK;
38 SELECT * FROM t1;
39 col1 col2
40 1 10
41 2 100
42 DROP TABLE t1;
43 #
44 # MDEV-37141 DML committed within XA transaction block after deadlock error and implicit rollback
45 #
46 CREATE TABLE t1(col1 INT PRIMARY KEY, col2 INT) ENGINE=InnoDB;
47 INSERT INTO t1 VALUES (1, 1), (2, 2);
48 SELECT * FROM t1;
49 col1 col2
50 1 1
51 2 2
52 # Wait for information schema cache for locks to get cleared
53 connection con1;
54 XA BEGIN 'x1';
55 # XA Trx-1: Lock 1st record
56 UPDATE t1 SET col2=10 where col1=1;
57 connection default;
58 XA BEGIN 'x2';
59 # XA Trx-2: Lock 2nd record
60 UPDATE t1 SET col2=100 where col1=2;
61 connection con1;
62 # XA Trx-1: Try locking 1st record : Wait
63 UPDATE t1 SET col2=10 where col1=2;
64 connection default;
65 # Wait for XA Trx-1 to get into lock wait stage
66 # XA Trx-2: Try locking 2nd record : Deadlock
67 UPDATE t1 SET col2=100 where col1=1;
68 ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
69 INSERT INTO t1 VALUES (3, 3), (4, 4);
70 ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the ROLLBACK ONLY state
71 XA END 'x2';
72 ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the ROLLBACK ONLY state
73 XA ROLLBACK 'x2';
74 connection con1;
75 XA END 'x1';
76 XA ROLLBACK 'x1';
77 connection default;
78 SELECT * FROM t1;
79 col1 col2
80 1 1
81 2 2
82 DROP TABLE t1;
83 disconnect con1;