diff options
author | Kristian Nielsen <knielsen@knielsen-hq.org> | 2016-11-04 12:33:42 +0100 |
---|---|---|
committer | Kristian Nielsen <knielsen@knielsen-hq.org> | 2016-11-04 12:33:42 +0100 |
commit | 717f212840a35b2da228d0cc2877b8e1b32204a3 (patch) | |
tree | f3da9174cf78cbdd5ae3e3117bbf216f2375968e /sql/slave.cc | |
parent | eca8c324e9a02f530853580991b11b587f54b24a (diff) | |
download | mariadb-git-717f212840a35b2da228d0cc2877b8e1b32204a3.tar.gz |
MDEV-10863: parallel replication tries to continue from wrong position
This occured when the SQL thread (but not the IO thread) stops while
GTID and parallel replication are used with multiple domain ids in the
GTID position, and is restarted.
In this case, the SQL needs to start some way back in the relay log,
applying or skipping events within each replication domain as
appropriate.
The SQL threads starts at the beginning of an old relay log file, and
this position may be in the middle of an event group. The bug was that
such partial event group could be re-applied, causing replication
corruption.
This patch fixes the issue, by making sure to skip any initial events
that were part of an earlier (already applied) event group.
Diffstat (limited to 'sql/slave.cc')
-rw-r--r-- | sql/slave.cc | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/sql/slave.cc b/sql/slave.cc index a124ca6be7e..04d62749fb1 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -4546,7 +4546,22 @@ pthread_handler_t handle_slave_sql(void *arg) serial_rgi->gtid_sub_id= 0; serial_rgi->gtid_pending= false; - rli->gtid_skip_flag = GTID_SKIP_NOT; + if (mi->using_gtid != Master_info::USE_GTID_NO && + opt_slave_parallel_threads > 0 && + rli->restart_gtid_pos.count() > 0) + { + /* + With parallel replication in GTID mode, if we have a multi-domain GTID + position, we need to start some way back in the relay log and skip any + GTID that was already applied before. Since event groups can be split + across multiple relay logs, this earlier starting point may be in the + middle of an already applied event group, so we also need to skip any + remaining part of such group. + */ + rli->gtid_skip_flag = GTID_SKIP_TRANSACTION; + } + else + rli->gtid_skip_flag = GTID_SKIP_NOT; if (init_relay_log_pos(rli, rli->group_relay_log_name, rli->group_relay_log_pos, |