Commit 5cb9e56a authored by Brandon Nesterenko's avatar Brandon Nesterenko

Fix slave_timestamp to match with parallel slave logic

In inc_group_relay_log_pos, slave_timestamp is set to
rgi->last_master_timestamp, but for the serial slave,
rgi->last_master_timestamp is never set (as it was done
in the parallel-specific code), thereby never updating
slave_timestamp in this part. So to fix this, when the
serial slave reads a new group event, it updates
serial_rgi->last_master_timestamp so slave_timestamp
can be updated at transaction commit.

Additionally, the update to slave_timestamp in
Xid_apply_log_event::do_apply_event() was removed, as
it is not safe for the parallel slave, and is
redundant with the update in inc_group_relay_log_pos.
parent 50f0dac4
......@@ -4151,8 +4151,6 @@ int Xid_apply_log_event::do_apply_event(rpl_group_info *rgi)
enum enum_sql_command cmd= !thd->transaction->xid_state.is_explicit_XA()
? SQLCOM_COMMIT : SQLCOM_XA_PREPARE;
status_var_increment(thd->status_var.com_stat[cmd]);
if (!res)
set_if_bigger(rgi->rli->slave_timestamp, when);
return res;
}
......
......@@ -1026,10 +1026,7 @@ void Relay_log_info::inc_group_relay_log_pos(ulonglong log_pos,
potentially thousands of events are still queued up for worker threads
waiting for execution.
*/
if (rgi->last_master_timestamp &&
rgi->last_master_timestamp > last_master_timestamp)
last_master_timestamp= rgi->last_master_timestamp;
set_if_bigger(slave_timestamp, rgi->last_master_timestamp);
set_if_bigger(last_master_timestamp, rgi->last_master_timestamp);
}
else
{
......@@ -1039,8 +1036,8 @@ void Relay_log_info::inc_group_relay_log_pos(ulonglong log_pos,
notify_group_relay_log_name_update();
if (log_pos) // not 3.23 binlogs (no log_pos there) and not Stop_log_event
group_master_log_pos= log_pos;
set_if_bigger(slave_timestamp, rgi->last_master_timestamp);
}
set_if_bigger(slave_timestamp, rgi->last_master_timestamp);
/*
If the slave does not support transactions and replicates a transaction,
......
......@@ -4318,6 +4318,15 @@ static int exec_relay_log_event(THD* thd, Relay_log_info* rli,
rli->last_master_timestamp= ev->when + (time_t) ev->exec_time;
rli->sql_thread_caught_up= false;
DBUG_ASSERT(rli->last_master_timestamp >= 0);
/*
For slave_timestamp, we update slave_timestamp at the end of the
transaction, so we follow the pattern of the parallel slave and
cache the timestamp of the last-event of the transaction within the
RGI, and then use it to update slave_timestamp at commit-time.
*/
if (Log_event::is_group_event(typ))
serial_rgi->last_master_timestamp= rli->last_master_timestamp;
}
if (unlikely(!rli->slave_timestamp) && Log_event::is_group_event(typ))
......
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