Skip to content

Commit f0de610

Browse files
committed
Merge 10.11 into 11.2
2 parents abd9833 + f9f92b4 commit f0de610

File tree

17 files changed

+837
-655
lines changed

17 files changed

+837
-655
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
connection node_2;
2+
connection node_1;
3+
connect node_1a,127.0.0.1,root,,test,$NODE_MYPORT_1;
4+
connection node_1;
5+
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
6+
SET GLOBAL DEBUG_DBUG = 'd,sync.wsrep_rollback_mdl_release';
7+
connection node_2;
8+
SET SESSION wsrep_trx_fragment_size = 1;
9+
START TRANSACTION;
10+
INSERT INTO t1 VALUES (1);
11+
connection node_1a;
12+
SELECT COUNT(*) FROM t1;
13+
COUNT(*)
14+
0
15+
SET SESSION wsrep_retry_autocommit = 0;
16+
SET DEBUG_SYNC = 'ha_write_row_start SIGNAL may_toi WAIT_FOR bf_abort';
17+
INSERT INTO t1 VALUES (2);
18+
connection node_1;
19+
SET DEBUG_SYNC = 'now WAIT_FOR may_toi';
20+
SET DEBUG_SYNC = 'after_wsrep_thd_abort WAIT_FOR sync.wsrep_rollback_mdl_release_reached';
21+
TRUNCATE TABLE t1;
22+
connection node_1a;
23+
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
24+
SET DEBUG_SYNC = 'now SIGNAL signal.wsrep_rollback_mdl_release';
25+
connection node_2;
26+
INSERT INTO t1 VALUES (3);
27+
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
28+
connection node_1;
29+
SET GLOBAL DEBUG_DBUG = '';
30+
SET DEBUG_SYNC = 'RESET';
31+
DROP TABLE t1;
32+
disconnect node_1a;
33+
disconnect node_2;
34+
disconnect node_1;
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#
2+
# MDEV-33133: MDL conflict handling code should skip transactions
3+
# BF-aborted before.
4+
#
5+
# It's possible that MDL conflict handling code is called more
6+
# than once for a transaction when:
7+
# - it holds more than one conflicting MDL lock
8+
# - reschedule_waiters() is executed,
9+
# which results in repeated attempts to BF-abort already aborted
10+
# transaction.
11+
# In such situations, it might be that BF-aborting logic sees
12+
# a partially rolled back transaction and erroneously decides
13+
# on future actions for such a transaction.
14+
#
15+
# The specific situation tested and fixed is when a SR transaction
16+
# applied in the node gets BF-aborted by a started TOI operation.
17+
# It's then caught with the server transaction already rolled back,
18+
# but with no MDL locks yet released. This caused wrong state
19+
# detection for such a transaction during repeated MDL conflict
20+
# handling code execution.
21+
#
22+
23+
--source include/galera_cluster.inc
24+
--source include/have_debug_sync.inc
25+
--source include/have_debug.inc
26+
27+
--connect node_1a,127.0.0.1,root,,test,$NODE_MYPORT_1
28+
29+
--connection node_1
30+
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
31+
SET GLOBAL DEBUG_DBUG = 'd,sync.wsrep_rollback_mdl_release';
32+
33+
--connection node_2
34+
SET SESSION wsrep_trx_fragment_size = 1;
35+
START TRANSACTION;
36+
INSERT INTO t1 VALUES (1);
37+
38+
--connection node_1a
39+
# Sync wait for SR transaction to replicate and apply fragment.
40+
SELECT COUNT(*) FROM t1;
41+
SET SESSION wsrep_retry_autocommit = 0;
42+
SET DEBUG_SYNC = 'ha_write_row_start SIGNAL may_toi WAIT_FOR bf_abort';
43+
--send
44+
INSERT INTO t1 VALUES (2);
45+
46+
--connection node_1
47+
SET DEBUG_SYNC = 'now WAIT_FOR may_toi';
48+
# BF-abort SR transaction and wait until it reaches the point
49+
# prior to release MDL locks.
50+
# Then abort local INSERT, which will go through rescedule_waiters()
51+
# and see SR transaction holding MDL locks but already rolled back.
52+
# In this case SR transaction should be skipped in MDL conflict
53+
# handling code.
54+
SET DEBUG_SYNC = 'after_wsrep_thd_abort WAIT_FOR sync.wsrep_rollback_mdl_release_reached';
55+
--send
56+
TRUNCATE TABLE t1;
57+
58+
--connection node_1a
59+
# Local INSERT gets aborted.
60+
--error ER_LOCK_DEADLOCK
61+
--reap
62+
# Let the aborted SR transaction continue and finally release MDL locks,
63+
# which in turn allows TRUNCATE to complete.
64+
SET DEBUG_SYNC = 'now SIGNAL signal.wsrep_rollback_mdl_release';
65+
66+
--connection node_2
67+
# SR transaction has been BF-aborted.
68+
--error ER_LOCK_DEADLOCK
69+
INSERT INTO t1 VALUES (3);
70+
71+
--connection node_1
72+
# TRUNCATE completes.
73+
--reap
74+
75+
# Cleanup
76+
SET GLOBAL DEBUG_DBUG = '';
77+
SET DEBUG_SYNC = 'RESET';
78+
DROP TABLE t1;
79+
--disconnect node_1a
80+
--source include/galera_end.inc

0 commit comments

Comments
 (0)