Commit bdbf90b9 authored by unknown's avatar unknown

MDEV-4506: Parallel replication

MDEV-5217: Incorrect event pos update leading to corruption of reading of events from relay log

The rli->event_relay_log_pos was sometimes undated incorrectly when using
parallel replication, especially around relay log rotates. This could cause
the SQL thread to seek into an invalid position in the relay log, resulting in
errors about invalid events or even random corruption in some cases.
parent b0391d1b
......@@ -946,6 +946,7 @@ rpl_parallel::do_event(rpl_group_info *serial_rgi, Log_event *ev,
qev->future_event_master_log_pos= log_pos;
if (!current)
{
rli->event_relay_log_pos= rli->future_event_relay_log_pos;
handle_queued_pos_update(rli->sql_driver_thd, qev);
my_free(qev);
return false;
......
......@@ -688,8 +688,7 @@ public:
inline void inc_event_relay_log_pos()
{
if (!is_parallel_exec ||
rli->event_relay_log_pos < future_event_relay_log_pos)
if (!is_parallel_exec)
rli->event_relay_log_pos= future_event_relay_log_pos;
}
};
......
......@@ -6019,6 +6019,7 @@ static Log_event* next_event(rpl_group_info *rgi, ulonglong *event_size)
The other case is much simpler:
We just have a read only log that nobody else will be updating.
*/
ulonglong old_pos;
bool hot_log;
if ((hot_log = (cur_log != &rli->cache_buf)))
{
......@@ -6070,12 +6071,12 @@ static Log_event* next_event(rpl_group_info *rgi, ulonglong *event_size)
But if the relay log is created by new_file(): then the solution is:
MYSQL_BIN_LOG::open() will write the buffered description event.
*/
old_pos= rli->event_relay_log_pos;
if ((ev= Log_event::read_log_event(cur_log,0,
rli->relay_log.description_event_for_exec,
opt_slave_sql_verify_checksum)))
{
ulonglong old_pos= rli->future_event_relay_log_pos;
/*
read it while we have a lock, to avoid a mutex lock in
inc_event_relay_log_pos()
......
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