Commit fb136165 authored by Kristian Nielsen's avatar Kristian Nielsen

MDEV-7145: Delayed replication.

Add test cases for delayed slave with parallel replication.
Signed-off-by: default avatarKristian Nielsen <knielsen@knielsen-hq.org>
parent 3011060b
--- mysql-test/suite/rpl/r/rpl_delayed_slave.result 2016-10-14 21:14:02.338075590 +0200
+++ mysql-test/suite/rpl/r/rpl_delayed_slave,parallel.reject 2016-10-14 21:17:51.296986686 +0200
@@ -45,7 +45,6 @@
# wait for first query to execute
# sleep 1*T
# Asserted this: Second query executed
-# Asserted this: Status should be executing third query (i.e., 'User sleep')
# sleep 2*T
# Asserted this: Third query executed
# Asserted this: Status should be 'Has read all relay log...'
@@ -167,5 +166,5 @@
conservative
SELECT @@GLOBAL.slave_parallel_threads;
@@GLOBAL.slave_parallel_threads
-0
+10
include/rpl_end.inc
......@@ -162,4 +162,10 @@ include/start_slave.inc
DROP TABLE t1, t_check_dml_not_executed_prematurely;
DROP FUNCTION delay_on_slave;
[on slave]
SELECT @@GLOBAL.slave_parallel_mode;
@@GLOBAL.slave_parallel_mode
conservative
SELECT @@GLOBAL.slave_parallel_threads;
@@GLOBAL.slave_parallel_threads
0
include/rpl_end.inc
include/master-slave.inc
[connection master]
ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB;
CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(100));
INSERT INTO t1 VALUES (1, "a");
include/stop_slave.inc
CHANGE MASTER TO master_use_gtid=slave_pos;
SET @old_mode= @@GLOBAL.slave_parallel_mode;
SET GLOBAL slave_parallel_mode=optimistic;
SET @old_threads= @@GLOBAL.slave_parallel_threads;
SET GLOBAL slave_parallel_threads=10;
INSERT INTO t1 VALUES (2, "b");
INSERT INTO t1 VALUES (3, "b");
INSERT INTO t1 VALUES (4, "b");
SET timestamp= @@timestamp + 24*60*60;
INSERT INTO t1 VALUES (5, "c");
INSERT INTO t1 VALUES (6, "c");
SET timestamp= 0;
include/save_master_gtid.inc
CHANGE MASTER TO master_delay=1;
include/start_slave.inc
SELECT MASTER_GTID_WAIT('GTID1');
MASTER_GTID_WAIT('GTID1')
0
SELECT MASTER_GTID_WAIT('GTID2', 2);
MASTER_GTID_WAIT('GTID2', 2)
-1
include/stop_slave.inc
SELECT * FROM t1 ORDER BY a;
a b
1 a
2 b
3 b
4 b
CHANGE MASTER TO master_delay=0;
include/start_slave.inc
include/sync_with_master_gtid.inc
SELECT * FROM t1 ORDER BY a;
a b
1 a
2 b
3 b
4 b
5 c
6 c
include/stop_slave.inc
CHANGE MASTER TO master_use_gtid=no, master_delay=0;
SET GLOBAL slave_parallel_mode=@old_mode;
SET GLOBAL slave_parallel_threads=@old_threads;
include/start_slave.inc
DROP TABLE t1;
include/rpl_end.inc
[nonparallel]
[parallel]
--slave-parallel-mode=conservative
--slave-parallel-threads=10
......@@ -151,9 +151,13 @@ INSERT INTO t1 SELECT delay_on_slave(2), 4;
--let $assert_cond= MAX(b) = 3 FROM t1
--source include/rpl_assert.inc
--let $assert_text= Status should be executing third query (i.e., 'User sleep')
--let $assert_cond= "[SHOW SLAVE STATUS, Slave_SQL_Running_State, 1]" = "User sleep"
--source include/rpl_assert.inc
let $parallel= `SELECT @@GLOBAL.slave_parallel_threads`;
if (!$parallel)
{
let $assert_text= Status should be executing third query (i.e., 'User sleep');
let $assert_cond= "[SHOW SLAVE STATUS, Slave_SQL_Running_State, 1]" = "User sleep";
source include/rpl_assert.inc;
}
--echo # sleep 2*T
--sleep $time2
......@@ -414,5 +418,7 @@ DROP FUNCTION delay_on_slave;
--echo [on slave]
--sync_slave_with_master
SELECT @@GLOBAL.slave_parallel_mode;
SELECT @@GLOBAL.slave_parallel_threads;
--source include/rpl_end.inc
--source include/have_innodb.inc
--source include/master-slave.inc
# This test file tests delayed slave for parallel replication (and GTID).
# Uses a different approach from rpl_delayed_slave.test, setting @@timestamp
# to simulate events logged on master at different times.
--connection master
ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB;
CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(100));
INSERT INTO t1 VALUES (1, "a");
--save_master_pos
--connection slave
--sync_with_master
--source include/stop_slave.inc
CHANGE MASTER TO master_use_gtid=slave_pos;
SET @old_mode= @@GLOBAL.slave_parallel_mode;
SET GLOBAL slave_parallel_mode=optimistic;
SET @old_threads= @@GLOBAL.slave_parallel_threads;
SET GLOBAL slave_parallel_threads=10;
--connection master
INSERT INTO t1 VALUES (2, "b");
INSERT INTO t1 VALUES (3, "b");
INSERT INTO t1 VALUES (4, "b");
--let $gtid1= `SELECT @@gtid_binlog_pos`
# Simulate an event a days in the future, for delayed slave to wait on.
SET timestamp= @@timestamp + 24*60*60;
INSERT INTO t1 VALUES (5, "c");
INSERT INTO t1 VALUES (6, "c");
SET timestamp= 0;
--let $gtid2= `SELECT @@gtid_binlog_pos`
--source include/save_master_gtid.inc
--connection slave
CHANGE MASTER TO master_delay=1;
--source include/start_slave.inc
--replace_result $gtid1 GTID1
# First sync halfways, to avoid timing-dependent test failures.
eval SELECT MASTER_GTID_WAIT('$gtid1');
# Try to sync up, should timeout because slave is waiting for one day.
--replace_result $gtid2 GTID2
eval SELECT MASTER_GTID_WAIT('$gtid2', 2);
# Check that we can stop slave while delaying.
--source include/stop_slave.inc
SELECT * FROM t1 ORDER BY a;
CHANGE MASTER TO master_delay=0;
--source include/start_slave.inc
--source include/sync_with_master_gtid.inc
SELECT * FROM t1 ORDER BY a;
--connection slave
--source include/stop_slave.inc
CHANGE MASTER TO master_use_gtid=no, master_delay=0;
SET GLOBAL slave_parallel_mode=@old_mode;
SET GLOBAL slave_parallel_threads=@old_threads;
--source include/start_slave.inc
--connection master
DROP TABLE t1;
--source include/rpl_end.inc
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment