summaryrefslogtreecommitdiff
path: root/sql/rpl_parallel.cc
diff options
context:
space:
mode:
authorKristian Nielsen <knielsen@knielsen-hq.org>2016-10-16 23:44:44 +0200
committerKristian Nielsen <knielsen@knielsen-hq.org>2016-10-16 23:44:44 +0200
commite1ef99c3dcb8bb6fdea290e319d14f5a983d1785 (patch)
tree6118948d076e16868b46bc8b14646eee4de610da /sql/rpl_parallel.cc
parent057c560ee45c61d172ed0ed762b0b33b37349e5c (diff)
parentfb13616518975b84eea9b9e0d5a91122bb1abe7a (diff)
downloadmariadb-git-e1ef99c3dcb8bb6fdea290e319d14f5a983d1785.tar.gz
MDEV-7145: Delayed replication
Merge feature into 10.2 from feature branch. Delayed replication adds an option CHANGE MASTER TO master_delay=<seconds> Replication will then delay applying events with that many seconds. This creates a replication slave that reflects the state of the master some time in the past. Feature is ported from MySQL source tree. Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
Diffstat (limited to 'sql/rpl_parallel.cc')
-rw-r--r--sql/rpl_parallel.cc17
1 files changed, 12 insertions, 5 deletions
diff --git a/sql/rpl_parallel.cc b/sql/rpl_parallel.cc
index 8cd7474cb73..eeb96d8608a 100644
--- a/sql/rpl_parallel.cc
+++ b/sql/rpl_parallel.cc
@@ -47,9 +47,7 @@ rpt_handle_event(rpl_parallel_thread::queued_event *qev,
if (!(ev->is_artificial_event() || ev->is_relay_log_event() ||
(ev->when == 0)))
rgi->last_master_timestamp= ev->when + (time_t)ev->exec_time;
- mysql_mutex_lock(&rli->data_lock);
- /* Mutex will be released in apply_event_and_update_pos(). */
- err= apply_event_and_update_pos(ev, thd, rgi, rpt);
+ err= apply_event_and_update_pos_for_parallel(ev, thd, rgi);
thread_safe_increment64(&rli->executed_entries);
/* ToDo: error handling. */
@@ -2426,8 +2424,17 @@ rpl_parallel::do_event(rpl_group_info *serial_rgi, Log_event *ev,
!(unlikely(rli->gtid_skip_flag != GTID_SKIP_NOT) && is_group_event))
return -1;
- /* ToDo: what to do with this lock?!? */
- mysql_mutex_unlock(&rli->data_lock);
+ /* Note: rli->data_lock is released by sql_delay_event(). */
+ if (sql_delay_event(ev, rli->sql_driver_thd, serial_rgi))
+ {
+ /*
+ If sql_delay_event() returns non-zero, it means that the wait timed out
+ due to slave stop. We should not queue the event in this case, it must
+ not be applied yet.
+ */
+ delete ev;
+ return 1;
+ }
if (unlikely(typ == FORMAT_DESCRIPTION_EVENT))
{