| 1 |
--source include/have_innodb.inc |
| 2 |
# The test is not format specific, MIXED is required to optimize testing time |
| 3 |
--source include/have_binlog_format_mixed.inc |
| 4 |
--source include/master-slave.inc |
| 5 |
|
| 6 |
--echo # |
| 7 |
--echo # MDEV-21953: deadlock between BACKUP STAGE BLOCK_COMMIT and parallel |
| 8 |
--echo # replication |
| 9 |
--echo # |
| 10 |
|
| 11 |
--connection master |
| 12 |
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE = innodb; |
| 13 |
# MDEV-515 takes X-lock on the table for the first insert. |
| 14 |
# So concurrent insert won't happen on the table |
| 15 |
INSERT INTO t1 VALUES(100); |
| 16 |
|
| 17 |
--sync_slave_with_master |
| 18 |
call mtr.add_suppression("Deadlock found when trying to get lock"); |
| 19 |
call mtr.add_suppression("Commit failed due to failure of an earlier commit"); |
| 20 |
|
| 21 |
--source include/stop_slave.inc |
| 22 |
SET @old_parallel_threads= @@GLOBAL.slave_parallel_threads; |
| 23 |
SET @old_parallel_mode = @@GLOBAL.slave_parallel_mode; |
| 24 |
SET @@global.slave_parallel_threads= 2; |
| 25 |
SET @@global.slave_parallel_mode = 'optimistic'; |
| 26 |
|
| 27 |
--connection master |
| 28 |
INSERT INTO t1 VALUES (1); |
| 29 |
INSERT INTO t1 VALUES (2); |
| 30 |
--save_master_pos |
| 31 |
|
| 32 |
# The plot: |
| 33 |
# Block the 1st of two workers and, at waiting-for-prior-commit by the 2nd, |
| 34 |
# issue BACKUP commands. |
| 35 |
# BLOCK_COMMIT may hang so it is --send. |
| 36 |
# Release the 1st worker to observe a deadlock unless its fixed. |
| 37 |
|
| 38 |
--connect (aux_slave,127.0.0.1,root,,test,$SLAVE_MYPORT,) |
| 39 |
BEGIN; |
| 40 |
# block the 1st worker and wait for the 2nd ready to commit |
| 41 |
INSERT INTO t1 VALUES (1); |
| 42 |
|
| 43 |
--connection slave |
| 44 |
--source include/start_slave.inc |
| 45 |
|
| 46 |
--connection aux_slave |
| 47 |
--let $wait_condition= SELECT COUNT(*) > 0 FROM information_schema.processlist WHERE state = "Waiting for prior transaction to commit" |
| 48 |
--source include/wait_condition.inc |
| 49 |
|
| 50 |
# While the 1st worker is locked out run backup |
| 51 |
--connect (backup_slave,127.0.0.1,root,,test,$SLAVE_MYPORT,) |
| 52 |
BACKUP STAGE START; |
| 53 |
--send BACKUP STAGE BLOCK_COMMIT |
| 54 |
|
| 55 |
# release the 1st work |
| 56 |
--connection aux_slave |
| 57 |
--sleep 1 |
| 58 |
ROLLBACK; |
| 59 |
|
| 60 |
--connection backup_slave |
| 61 |
--reap |
| 62 |
BACKUP STAGE END; |
| 63 |
|
| 64 |
--connection slave |
| 65 |
--sync_with_master |
| 66 |
|
| 67 |
--let $diff_tables= master:t1,slave:t1 |
| 68 |
--source include/diff_tables.inc |
| 69 |
|
| 70 |
# |
| 71 |
--echo # MDEV-30423: dealock XA COMMIT vs BACKUP |
| 72 |
# Prove XA "COMPLETE" 'xid' does not dealock similary to the normal trx case. |
| 73 |
# The slave binlog group commit leader is blocked by a local trx like in |
| 74 |
# the above normal trx case. |
| 75 |
# [Notice a reuse of t1,aux_conn from above.] |
| 76 |
# |
| 77 |
--let $complete = COMMIT |
| 78 |
--source parallel_backup_xa.inc |
| 79 |
--let $complete = ROLLBACK |
| 80 |
--source parallel_backup_xa.inc |
| 81 |
|
| 82 |
--let $slave_ooo_error = 1 |
| 83 |
--let $complete = COMMIT |
| 84 |
--source parallel_backup_xa.inc |
| 85 |
--connection slave |
| 86 |
--source include/start_slave.inc |
| 87 |
--source include/sync_with_master_gtid.inc |
| 88 |
|
| 89 |
--let $slave_ooo_error = 1 |
| 90 |
--let $complete = ROLLBACK |
| 91 |
--source parallel_backup_xa.inc |
| 92 |
--connection slave |
| 93 |
--source include/start_slave.inc |
| 94 |
--source include/sync_with_master_gtid.inc |
| 95 |
|
| 96 |
|
| 97 |
# Clean up. |
| 98 |
--connection slave |
| 99 |
--source include/stop_slave.inc |
| 100 |
SET @@global.slave_parallel_threads= @old_parallel_threads; |
| 101 |
SET @@global.slave_parallel_mode = @old_parallel_mode; |
| 102 |
--source include/start_slave.inc |
| 103 |
|
| 104 |
--connection server_1 |
| 105 |
DROP TABLE t1; |
| 106 |
|
| 107 |
--source include/rpl_end.inc |