Skip to content

Commit da47c03

Browse files
committed
Fixed calculating of last_master_timestamp for parallel replication.
This effects the Seconds_Behind_Master value.
1 parent 3655cef commit da47c03

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

sql/rpl_rli.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,10 @@ class Relay_log_info : public Slave_reporting_capability
564564
565565
Guarded by data_lock. Written by the sql thread. Read by client
566566
threads executing SHOW SLAVE STATUS.
567+
568+
This is calculated as:
569+
clock_time_for_event_on_master + clock_difference_between_master_and_slave +
570+
SQL_DELAY.
567571
*/
568572
time_t sql_delay_end;
569573

sql/slave.cc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4342,6 +4342,13 @@ static int exec_relay_log_event(THD* thd, Relay_log_info* rli,
43424342
rli->last_inuse_relaylog->dequeued_count))) &&
43434343
event_can_update_last_master_timestamp(ev))
43444344
{
4345+
/*
4346+
This is the first event from the master after the slave was up to date
4347+
and has been waiting for new events.
4348+
We update last_master_timestamp before executing the event to not
4349+
have Seconds_after_master == 0 while executing the event.
4350+
last_master_timestamp will be updated again when the event is commited.
4351+
*/
43454352
if (rli->last_master_timestamp < ev->when)
43464353
{
43474354
rli->last_master_timestamp= ev->when;
@@ -4378,7 +4385,7 @@ static int exec_relay_log_event(THD* thd, Relay_log_info* rli,
43784385
Seconds_Behind_Master is zero.
43794386
*/
43804387
if (ev->get_type_code() != FORMAT_DESCRIPTION_EVENT &&
4381-
rli->last_master_timestamp < ev->when)
4388+
rli->last_master_timestamp < ev->when + (time_t) ev->exec_time)
43824389
rli->last_master_timestamp= ev->when + (time_t) ev->exec_time;
43834390

43844391
DBUG_ASSERT(rli->last_master_timestamp >= 0);

0 commit comments

Comments
 (0)