| 1 |
# ==== Purpose ==== |
| 2 |
# |
| 3 |
# Test verifies that, in parallel replication, transaction failure notification |
| 4 |
# is propagated to all the workers. Workers should abort the execution of |
| 5 |
# transaction event groups, whose event positions are higher than the failing |
| 6 |
# transaction group. |
| 7 |
# |
| 8 |
# ==== Implementation ==== |
| 9 |
# |
| 10 |
# Steps: |
| 11 |
# 0 - Create a table t1 on master which has a primary key. Enable parallel |
| 12 |
# replication on slave with slave_parallel_mode='optimistic' and |
| 13 |
# slave_parallel_threads=3. |
| 14 |
# 1 - On slave start a transaction and execute a local INSERT statement |
| 15 |
# which will insert value 32. This is done to block the INSERT coming |
| 16 |
# from master. |
| 17 |
# 2 - On master execute an INSERT statement with value 32, so that it is |
| 18 |
# blocked on slave. |
| 19 |
# 3 - On slave enable a debug sync point such that it holds the worker thread |
| 20 |
# execution as soon as work is scheduled to it. |
| 21 |
# 4 - INSERT value 33 on master. It will be held on slave by other worker |
| 22 |
# thread due to debug simulation. |
| 23 |
# 5 - INSERT value 34 on master. |
| 24 |
# 6 - On slave, enusre that INSERT 34 has reached a state where it waits for |
| 25 |
# its prior transactions to commit. |
| 26 |
# 7 - Commit the local INSERT 32 on slave server so that first worker will |
| 27 |
# error out. |
| 28 |
# 8 - Now send a continue signal to second worker processing 33. It should |
| 29 |
# wakeup and propagate the error to INSERT 34. |
| 30 |
# 9 - Upon slave stop due to error, check that no rows are found after the |
| 31 |
# failed INSERT 32. |
| 32 |
# |
| 33 |
# ==== References ==== |
| 34 |
# |
| 35 |
# MDEV-20645: Replication consistency is broken as workers miss the error |
| 36 |
# notification from an earlier failed group. |
| 37 |
# |
| 38 |
|
| 39 |
--source include/have_innodb.inc |
| 40 |
--source include/have_debug.inc |
| 41 |
--source include/have_debug_sync.inc |
| 42 |
--source include/have_binlog_format_statement.inc |
| 43 |
--source include/master-slave.inc |
| 44 |
|
| 45 |
--enable_connect_log |
| 46 |
--connection server_2 |
| 47 |
--source include/stop_slave.inc |
| 48 |
SET @old_parallel_threads=@@GLOBAL.slave_parallel_threads; |
| 49 |
SET @old_parallel_mode=@@GLOBAL.slave_parallel_mode; |
| 50 |
SET @old_debug= @@GLOBAL.debug_dbug; |
| 51 |
SET GLOBAL slave_parallel_mode='optimistic'; |
| 52 |
SET GLOBAL slave_parallel_threads= 3; |
| 53 |
CHANGE MASTER TO master_use_gtid=slave_pos; |
| 54 |
CALL mtr.add_suppression("Commit failed due to failure of an earlier commit on which this one depends"); |
| 55 |
--source include/start_slave.inc |
| 56 |
|
| 57 |
--connection server_1 |
| 58 |
ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB; |
| 59 |
CREATE TABLE t1 (a int PRIMARY KEY) ENGINE=InnoDB; |
| 60 |
# MDEV-515 takes X-lock on the table for the first insert. |
| 61 |
# So concurrent insert won't happen on the table |
| 62 |
INSERT INTO t1 VALUES(1); |
| 63 |
--source include/save_master_gtid.inc |
| 64 |
|
| 65 |
--connection server_2 |
| 66 |
--source include/sync_with_master_gtid.inc |
| 67 |
|
| 68 |
--connect (con_temp2,127.0.0.1,root,,test,$SERVER_MYPORT_2,) |
| 69 |
BEGIN; |
| 70 |
INSERT INTO t1 VALUES (32); |
| 71 |
|
| 72 |
--connection server_1 |
| 73 |
INSERT INTO t1 VALUES (32); |
| 74 |
|
| 75 |
--connection server_2 |
| 76 |
--let $wait_condition= SELECT COUNT(*) = 1 FROM information_schema.processlist WHERE info like "INSERT INTO t1 VALUES (32)" |
| 77 |
--source include/wait_condition.inc |
| 78 |
SET GLOBAL debug_dbug="+d,hold_worker_on_schedule"; |
| 79 |
SET debug_sync="debug_sync_action SIGNAL reached_pause WAIT_FOR continue_worker"; |
| 80 |
|
| 81 |
--connection server_1 |
| 82 |
SET gtid_seq_no=100; |
| 83 |
INSERT INTO t1 VALUES (33); |
| 84 |
|
| 85 |
--connection server_2 |
| 86 |
SET debug_sync='now WAIT_FOR reached_pause'; |
| 87 |
|
| 88 |
--connection server_1 |
| 89 |
INSERT INTO t1 VALUES (34); |
| 90 |
|
| 91 |
--connection server_2 |
| 92 |
--let $wait_condition= SELECT COUNT(*) = 1 FROM information_schema.processlist WHERE state like "Waiting for prior transaction to commit" |
| 93 |
--source include/wait_condition.inc |
| 94 |
--connection con_temp2 |
| 95 |
COMMIT; |
| 96 |
|
| 97 |
# Clean up. |
| 98 |
--connection server_2 |
| 99 |
--let $slave_sql_errno= 1062 |
| 100 |
--source include/wait_for_slave_sql_error.inc |
| 101 |
--source include/stop_slave_io.inc |
| 102 |
--let $assert_cond= COUNT(*) = 0 FROM t1 WHERE a>32 |
| 103 |
--let $assert_text= table t1 should have zero rows where a>32 |
| 104 |
--source include/assert.inc |
| 105 |
SELECT * FROM t1 WHERE a>32; |
| 106 |
DELETE FROM t1 WHERE a=32; |
| 107 |
|
| 108 |
SET GLOBAL slave_parallel_threads=@old_parallel_threads; |
| 109 |
SET GLOBAL slave_parallel_mode=@old_parallel_mode; |
| 110 |
SET GLOBAL debug_dbug=@old_debug; |
| 111 |
SET DEBUG_SYNC= 'RESET'; |
| 112 |
--source include/start_slave.inc |
| 113 |
|
| 114 |
--connection server_1 |
| 115 |
DROP TABLE t1; |
| 116 |
--disable_connect_log |
| 117 |
--source include/rpl_end.inc |