summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Mazur <igor.mazur@grammarly.com>2017-11-11 22:32:39 +0200
committerAndrei Elkin <andrei.elkin@mariadb.com>2018-11-06 21:11:49 +0200
commit54b8856b87629e9fec075e3a71179eefc7fa02ac (patch)
tree35451763fcc4a7167d365d22f137e09e70f6457f
parent7dfcb871079ce03c4ad0f6562f94b5a3cd0e1ecb (diff)
downloadmariadb-git-54b8856b87629e9fec075e3a71179eefc7fa02ac.tar.gz
MDEV-14528 Track master timestamp in case rolling back to serial replication
When replicated events are from Master unaware of MariaDB GTID their handling by the Parallel slave misses Seconds_Behind_Master updating. In the bug condition the Show-Slave-Status' field remains unchanged. Because in such case event execution is sequential the bug is fixed with deploying the same logics as in the explicit single-threaded mode with is to set Relay_log_event::last_master_timestamp member early at the end of event reading from the relay log.
-rw-r--r--mysql-test/suite/rpl/r/rpl_old_master.result3
-rw-r--r--mysql-test/suite/rpl/t/rpl_old_master.test8
-rw-r--r--sql/slave.cc5
3 files changed, 16 insertions, 0 deletions
diff --git a/mysql-test/suite/rpl/r/rpl_old_master.result b/mysql-test/suite/rpl/r/rpl_old_master.result
index dd3de4d327b..f985bee6832 100644
--- a/mysql-test/suite/rpl/r/rpl_old_master.result
+++ b/mysql-test/suite/rpl/r/rpl_old_master.result
@@ -9,7 +9,10 @@ connection slave;
SET @old_parallel= @@GLOBAL.slave_parallel_threads;
SET GLOBAL slave_parallel_threads=10;
CHANGE MASTER TO master_host='127.0.0.1', master_port=SERVER_MYPORT_1, master_user='root', master_log_file='master-bin.000001', master_log_pos=4;
+FLUSH TABLES WITH READ LOCK;
include/start_slave.inc
+include/wait_for_slave_param.inc [Seconds_Behind_Master]
+UNLOCK TABLES;
connection master;
CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t2 VALUES (1);
diff --git a/mysql-test/suite/rpl/t/rpl_old_master.test b/mysql-test/suite/rpl/t/rpl_old_master.test
index 8f61d6979cd..6ddc227fc14 100644
--- a/mysql-test/suite/rpl/t/rpl_old_master.test
+++ b/mysql-test/suite/rpl/t/rpl_old_master.test
@@ -27,7 +27,15 @@ SET @old_parallel= @@GLOBAL.slave_parallel_threads;
SET GLOBAL slave_parallel_threads=10;
--replace_result $SERVER_MYPORT_1 SERVER_MYPORT_1
eval CHANGE MASTER TO master_host='127.0.0.1', master_port=$SERVER_MYPORT_1, master_user='root', master_log_file='master-bin.000001', master_log_pos=4;
+
+# Block execution yet when the blocked query timestamp has been already accounted
+FLUSH TABLES WITH READ LOCK;
--source include/start_slave.inc
+--let $slave_param = Seconds_Behind_Master
+--let $slave_param_value = 1
+--let $slave_param_comparison= >=
+--source include/wait_for_slave_param.inc
+UNLOCK TABLES;
--connection master
CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=InnoDB;
diff --git a/sql/slave.cc b/sql/slave.cc
index 7e52822ca51..d6223453a5b 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -3960,6 +3960,11 @@ static int exec_relay_log_event(THD* thd, Relay_log_info* rli,
This is the case for pre-10.0 events without GTID, and for handling
slave_skip_counter.
*/
+ if (!(ev->is_artificial_event() || ev->is_relay_log_event() || (ev->when == 0)))
+ {
+ rli->last_master_timestamp= ev->when + (time_t) ev->exec_time;
+ DBUG_ASSERT(rli->last_master_timestamp >= 0);
+ }
}
if (typ == GTID_EVENT)