| 1 |
--echo ***MDEV-5914: Parallel replication deadlock due to InnoDB lock conflicts *** |
| 2 |
|
| 3 |
--source include/have_innodb.inc |
| 4 |
--source include/have_debug.inc |
| 5 |
--source include/have_debug_sync.inc |
| 6 |
--source include/master-slave.inc |
| 7 |
|
| 8 |
ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB; |
| 9 |
CALL mtr.add_suppression("InnoDB: Transaction was aborted due to "); |
| 10 |
CALL mtr.add_suppression("Commit failed due to failure of an earlier commit on which this one depends"); |
| 11 |
--save_master_pos |
| 12 |
|
| 13 |
--connection server_2 |
| 14 |
--sync_with_master |
| 15 |
SET @old_parallel_threads=@@GLOBAL.slave_parallel_threads; |
| 16 |
--source include/stop_slave.inc |
| 17 |
SET GLOBAL slave_parallel_threads=10; |
| 18 |
CHANGE MASTER TO master_use_gtid=slave_pos; |
| 19 |
|
| 20 |
--connection server_1 |
| 21 |
CREATE TABLE t4 (a INT PRIMARY KEY, b INT, KEY b_idx(b)) ENGINE=InnoDB; |
| 22 |
INSERT INTO t4 VALUES (1,NULL), (2,2), (3,NULL), (4,4), (5, NULL), (6, 6); |
| 23 |
--connect (con1,127.0.0.1,root,,test,$SERVER_MYPORT_1,) |
| 24 |
--connect (con2,127.0.0.1,root,,test,$SERVER_MYPORT_1,) |
| 25 |
|
| 26 |
# Create a group commit with UPDATE and DELETE, in that order. |
| 27 |
# The bug was that while the UPDATE's row lock does not block the DELETE, the |
| 28 |
# DELETE's gap lock _does_ block the UPDATE. This could cause a deadlock |
| 29 |
# on the slave. |
| 30 |
--connection con1 |
| 31 |
SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued1 WAIT_FOR master_cont1'; |
| 32 |
send UPDATE t4 SET b=NULL WHERE a=6; |
| 33 |
--connection server_1 |
| 34 |
SET debug_sync='now WAIT_FOR master_queued1'; |
| 35 |
|
| 36 |
--connection con2 |
| 37 |
SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued2'; |
| 38 |
send DELETE FROM t4 WHERE b <= 3; |
| 39 |
|
| 40 |
--connection server_1 |
| 41 |
SET debug_sync='now WAIT_FOR master_queued2'; |
| 42 |
SET debug_sync='now SIGNAL master_cont1'; |
| 43 |
|
| 44 |
--connection con1 |
| 45 |
REAP; |
| 46 |
--connection con2 |
| 47 |
REAP; |
| 48 |
SET debug_sync='RESET'; |
| 49 |
--save_master_pos |
| 50 |
|
| 51 |
--connection server_2 |
| 52 |
--source include/start_slave.inc |
| 53 |
--sync_with_master |
| 54 |
--source include/stop_slave.inc |
| 55 |
|
| 56 |
SELECT * FROM t4 ORDER BY a; |
| 57 |
|
| 58 |
|
| 59 |
# Another example, this one with INSERT vs. DELETE |
| 60 |
--connection server_1 |
| 61 |
DELETE FROM t4; |
| 62 |
INSERT INTO t4 VALUES (1,NULL), (2,2), (3,NULL), (4,4), (5, NULL), (6, 6); |
| 63 |
|
| 64 |
# Create a group commit with INSERT and DELETE, in that order. |
| 65 |
# The bug was that while the INSERT's insert intention lock does not block |
| 66 |
# the DELETE, the DELETE's gap lock _does_ block the INSERT. This could cause |
| 67 |
# a deadlock on the slave. |
| 68 |
--connection con1 |
| 69 |
SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued1 WAIT_FOR master_cont1'; |
| 70 |
send INSERT INTO t4 VALUES (7, NULL); |
| 71 |
--connection server_1 |
| 72 |
SET debug_sync='now WAIT_FOR master_queued1'; |
| 73 |
|
| 74 |
--connection con2 |
| 75 |
SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued2'; |
| 76 |
send DELETE FROM t4 WHERE b <= 3; |
| 77 |
|
| 78 |
--connection server_1 |
| 79 |
SET debug_sync='now WAIT_FOR master_queued2'; |
| 80 |
SET debug_sync='now SIGNAL master_cont1'; |
| 81 |
|
| 82 |
--connection con1 |
| 83 |
REAP; |
| 84 |
--connection con2 |
| 85 |
REAP; |
| 86 |
SET debug_sync='RESET'; |
| 87 |
--save_master_pos |
| 88 |
|
| 89 |
--connection server_2 |
| 90 |
--source include/start_slave.inc |
| 91 |
--sync_with_master |
| 92 |
--source include/stop_slave.inc |
| 93 |
|
| 94 |
SELECT * FROM t4 ORDER BY a; |
| 95 |
|
| 96 |
|
| 97 |
# Clean up. |
| 98 |
--connection server_2 |
| 99 |
SET GLOBAL slave_parallel_threads=@old_parallel_threads; |
| 100 |
--source include/start_slave.inc |
| 101 |
SET DEBUG_SYNC= 'RESET'; |
| 102 |
|
| 103 |
--connection server_1 |
| 104 |
--disconnect con1 |
| 105 |
--disconnect con2 |
| 106 |
DROP TABLE t4; |
| 107 |
SET DEBUG_SYNC= 'RESET'; |
| 108 |
|
| 109 |
--source include/rpl_end.inc |