include/master-slave.inc
[connection master]
#
# MDEV-21953: deadlock between BACKUP STAGE BLOCK_COMMIT and parallel
# replication
#
connection master;
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE = innodb;
INSERT INTO t1 VALUES(100);
connection slave;
call mtr.add_suppression("Deadlock found when trying to get lock");
call mtr.add_suppression("Commit failed due to failure of an earlier commit");
include/stop_slave.inc
SET @old_parallel_threads= @@GLOBAL.slave_parallel_threads;
SET @old_parallel_mode   = @@GLOBAL.slave_parallel_mode;
SET @@global.slave_parallel_threads= 2;
SET @@global.slave_parallel_mode   = 'optimistic';
connection master;
INSERT INTO  t1 VALUES (1);
INSERT INTO  t1 VALUES (2);
connect  aux_slave,127.0.0.1,root,,test,$SLAVE_MYPORT,;
BEGIN;
INSERT INTO t1 VALUES (1);
connection slave;
include/start_slave.inc
connection aux_slave;
connect  backup_slave,127.0.0.1,root,,test,$SLAVE_MYPORT,;
BACKUP STAGE START;
BACKUP STAGE BLOCK_COMMIT;
connection aux_slave;
ROLLBACK;
connection backup_slave;
BACKUP STAGE END;
connection slave;
include/diff_tables.inc [master:t1,slave:t1]
# MDEV-30423: dealock XA COMMIT vs BACKUP
#
# Normal XA COMMIT
connection slave;
include/stop_slave.inc
connection master;
connection aux_slave;
BEGIN;
INSERT INTO t1 VALUES (102);
connection master;
XA START '1';
INSERT INTO  t1 VALUES (101);
XA END '1';
XA PREPARE '1';
connection master1;
INSERT INTO t1 VALUES (102);
connection master;
XA COMMIT '1';
include/save_master_gtid.inc
connection slave;
include/start_slave.inc
connection aux_slave;
# Xid '1' must be in the output:
XA RECOVER;
formatID	gtrid_length	bqual_length	data
1	1	0	1
connection backup_slave;
BACKUP STAGE START;
BACKUP STAGE BLOCK_COMMIT;
connection aux_slave;
ROLLBACK;
connection backup_slave;
BACKUP STAGE END;
connection slave;
include/sync_with_master_gtid.inc
include/stop_slave.inc
#
# Normal XA ROLLBACK
connection slave;
include/stop_slave.inc
connection master;
connection aux_slave;
BEGIN;
INSERT INTO t1 VALUES (104);
connection master;
XA START '1';
INSERT INTO  t1 VALUES (103);
XA END '1';
XA PREPARE '1';
connection master1;
INSERT INTO t1 VALUES (104);
connection master;
XA ROLLBACK '1';
include/save_master_gtid.inc
connection slave;
include/start_slave.inc
connection aux_slave;
# Xid '1' must be in the output:
XA RECOVER;
formatID	gtrid_length	bqual_length	data
1	1	0	1
connection backup_slave;
BACKUP STAGE START;
BACKUP STAGE BLOCK_COMMIT;
connection aux_slave;
ROLLBACK;
connection backup_slave;
BACKUP STAGE END;
connection slave;
include/sync_with_master_gtid.inc
include/stop_slave.inc
#
# Errored out XA COMMIT
connection slave;
include/stop_slave.inc
connection master;
connection aux_slave;
BEGIN;
INSERT INTO t1 VALUES (106);
connection master;
XA START '1';
INSERT INTO  t1 VALUES (105);
XA END '1';
XA PREPARE '1';
connection master1;
INSERT INTO t1 VALUES (106);
connection master;
XA COMMIT '1';
include/save_master_gtid.inc
connection slave;
SET @sav_innodb_lock_wait_timeout  = @@global.innodb_lock_wait_timeout;
SET @sav_slave_transaction_retries = @@global.slave_transaction_retries;
SET @@global.innodb_lock_wait_timeout =5;
SET @@global.slave_transaction_retries=0;
include/start_slave.inc
connection aux_slave;
# Xid '1' must be in the output:
XA RECOVER;
formatID	gtrid_length	bqual_length	data
1	1	0	1
connection backup_slave;
BACKUP STAGE START;
BACKUP STAGE BLOCK_COMMIT;
connection aux_slave;
ROLLBACK;
connection backup_slave;
BACKUP STAGE END;
connection slave;
include/stop_slave.inc
SET @@global.innodb_lock_wait_timeout = @sav_innodb_lock_wait_timeout;
SET @@global.slave_transaction_retries= @sav_slave_transaction_retries;
connection slave;
include/start_slave.inc
include/sync_with_master_gtid.inc
#
# Errored out XA ROLLBACK
connection slave;
include/stop_slave.inc
connection master;
connection aux_slave;
BEGIN;
INSERT INTO t1 VALUES (108);
connection master;
XA START '1';
INSERT INTO  t1 VALUES (107);
XA END '1';
XA PREPARE '1';
connection master1;
INSERT INTO t1 VALUES (108);
connection master;
XA ROLLBACK '1';
include/save_master_gtid.inc
connection slave;
SET @sav_innodb_lock_wait_timeout  = @@global.innodb_lock_wait_timeout;
SET @sav_slave_transaction_retries = @@global.slave_transaction_retries;
SET @@global.innodb_lock_wait_timeout =5;
SET @@global.slave_transaction_retries=0;
include/start_slave.inc
connection aux_slave;
# Xid '1' must be in the output:
XA RECOVER;
formatID	gtrid_length	bqual_length	data
1	1	0	1
connection backup_slave;
BACKUP STAGE START;
BACKUP STAGE BLOCK_COMMIT;
connection aux_slave;
ROLLBACK;
connection backup_slave;
BACKUP STAGE END;
connection slave;
include/stop_slave.inc
SET @@global.innodb_lock_wait_timeout = @sav_innodb_lock_wait_timeout;
SET @@global.slave_transaction_retries= @sav_slave_transaction_retries;
connection slave;
include/start_slave.inc
include/sync_with_master_gtid.inc
connection slave;
include/stop_slave.inc
SET @@global.slave_parallel_threads= @old_parallel_threads;
SET @@global.slave_parallel_mode   = @old_parallel_mode;
include/start_slave.inc
connection server_1;
DROP TABLE t1;
include/rpl_end.inc
