diff options
author | Kristian Nielsen <knielsen@knielsen-hq.org> | 2016-11-16 11:00:38 +0100 |
---|---|---|
committer | Kristian Nielsen <knielsen@knielsen-hq.org> | 2016-11-16 11:00:38 +0100 |
commit | 390f2a013b1b223bdce2cd9011a799131eaf13ce (patch) | |
tree | 09d81e87d67b2e7a23c08b2f7286655f11d15323 /sql/slave.cc | |
parent | f1fcc1fc105ad0e329b8f6dd11923f99d6edd42b (diff) | |
download | mariadb-git-390f2a013b1b223bdce2cd9011a799131eaf13ce.tar.gz |
Fix incorrect reading of events from relaylog in parallel replication.
The SQL thread keeps track of the position in the current relay log from
which to read the next event. This position is not normally used, but a
certain interaction with the IO thread can cause the SQL thread to re-open
the relay log and seek to the stored position.
In parallel replication, there were a couple of places where the position
was not updated. This created a race where a re-open of the relay log could
seek to the wrong position and start re-reading and processing events
already handled once, causing various kinds of problems.
Fix this by moving the position update into a single place in
apply_event_and_update_pos(), which should ensure that the position is
always updated in the parallel replication case.
This problem was found from the testcase of MDEV-10863, but it is logically
a separate problem.
Diffstat (limited to 'sql/slave.cc')
-rw-r--r-- | sql/slave.cc | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/sql/slave.cc b/sql/slave.cc index e6a0ac086a8..65bcdc48c6a 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -3569,6 +3569,13 @@ static int exec_relay_log_event(THD* thd, Relay_log_info* rli, if (rli->mi->using_parallel()) { int res= rli->parallel.do_event(serial_rgi, ev, event_size); + /* + In parallel replication, we need to update the relay log position + immediately so that it will be the correct position from which to + read the next event. + */ + if (res == 0) + rli->event_relay_log_pos= rli->future_event_relay_log_pos; if (res >= 0) DBUG_RETURN(res); /* |