| 1 |
# Test should work with both conservative and optimistic modes |
| 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 |
# Test various aspects of parallel replication. |
| 9 |
|
| 10 |
--connection server_2 |
| 11 |
SET @old_parallel_threads=@@GLOBAL.slave_parallel_threads; |
| 12 |
--error ER_SLAVE_MUST_STOP |
| 13 |
SET GLOBAL slave_parallel_threads=10; |
| 14 |
--source include/stop_slave.inc |
| 15 |
SET GLOBAL slave_parallel_threads=10; |
| 16 |
|
| 17 |
# Check that we do not spawn any worker threads when no slave is running. |
| 18 |
SELECT IF(COUNT(*) < 10, "OK", CONCAT("Found too many system user processes: ", COUNT(*))) FROM information_schema.processlist WHERE user = "system user"; |
| 19 |
|
| 20 |
CHANGE MASTER TO master_use_gtid=slave_pos; |
| 21 |
--source include/start_slave.inc |
| 22 |
|
| 23 |
# Check that worker threads get spawned when slave starts. |
| 24 |
SELECT IF(COUNT(*) >= 10, "OK", CONCAT("Found too few system user processes: ", COUNT(*))) FROM information_schema.processlist WHERE user = "system user"; |
| 25 |
# ... and that worker threads get removed when slave stops. |
| 26 |
--source include/stop_slave.inc |
| 27 |
SELECT IF(COUNT(*) < 10, "OK", CONCAT("Found too many system user processes: ", COUNT(*))) FROM information_schema.processlist WHERE user = "system user"; |
| 28 |
--source include/start_slave.inc |
| 29 |
SELECT IF(COUNT(*) >= 10, "OK", CONCAT("Found too few system user processes: ", COUNT(*))) FROM information_schema.processlist WHERE user = "system user"; |
| 30 |
|
| 31 |
--echo *** Test long-running query in domain 1 can run in parallel with short queries in domain 0 *** |
| 32 |
|
| 33 |
--connection server_1 |
| 34 |
ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB; |
| 35 |
CREATE TABLE t1 (a int PRIMARY KEY) ENGINE=MyISAM; |
| 36 |
CREATE TABLE t2 (a int PRIMARY KEY) ENGINE=InnoDB; |
| 37 |
INSERT INTO t1 VALUES (1); |
| 38 |
INSERT INTO t2 VALUES (1); |
| 39 |
--save_master_pos |
| 40 |
|
| 41 |
--connection server_2 |
| 42 |
--sync_with_master |
| 43 |
|
| 44 |
# Block the table t1 to simulate a replicated query taking a long time. |
| 45 |
--connect (con_temp1,127.0.0.1,root,,test,$SERVER_MYPORT_2,) |
| 46 |
LOCK TABLE t1 WRITE; |
| 47 |
|
| 48 |
--connection server_1 |
| 49 |
SET gtid_domain_id=1; |
| 50 |
# This query will be blocked on the slave until UNLOCK TABLES. |
| 51 |
INSERT INTO t1 VALUES (2); |
| 52 |
SET gtid_domain_id=0; |
| 53 |
# These t2 queries can be replicated in parallel with the prior t1 query, as |
| 54 |
# they are in a separate replication domain. |
| 55 |
INSERT INTO t2 VALUES (2); |
| 56 |
INSERT INTO t2 VALUES (3); |
| 57 |
BEGIN; |
| 58 |
INSERT INTO t2 VALUES (4); |
| 59 |
INSERT INTO t2 VALUES (5); |
| 60 |
COMMIT; |
| 61 |
INSERT INTO t2 VALUES (6); |
| 62 |
|
| 63 |
--connection server_2 |
| 64 |
--let $wait_condition= SELECT COUNT(*) = 6 FROM t2 |
| 65 |
--source include/wait_condition.inc |
| 66 |
|
| 67 |
SELECT * FROM t2 ORDER by a; |
| 68 |
|
| 69 |
--connection con_temp1 |
| 70 |
SELECT * FROM t1; |
| 71 |
UNLOCK TABLES; |
| 72 |
|
| 73 |
--connection server_2 |
| 74 |
--let $wait_condition= SELECT COUNT(*) = 2 FROM t1 |
| 75 |
--source include/wait_condition.inc |
| 76 |
|
| 77 |
SELECT * FROM t1 ORDER BY a; |
| 78 |
|
| 79 |
# Clean up. |
| 80 |
--connection server_2 |
| 81 |
--source include/stop_slave.inc |
| 82 |
SET GLOBAL slave_parallel_threads=@old_parallel_threads; |
| 83 |
--source include/start_slave.inc |
| 84 |
|
| 85 |
--connection server_1 |
| 86 |
DROP TABLE t1,t2; |
| 87 |
--source include/rpl_end.inc |