Seconds_behind_master incorrect in parallel replication

Description

As reported by plinux on #maria:

09:03 < plinux> We found a display bug about parallel replication. When we update one row on master, and then stop
the updates on master, we can found Seconds_Behind_Master is still increasing on slave

I think the problem is a race between the SQL driver thread and the worker
threads.

Normally, the rli->last_master_timestamp is updated in stmt_done() to the
timestamp of an event from the master. When next_event() reaches the end of
the relay log, it is temporarily set to 0 to mark that SQL thread is caught
up; SHOW SLAVE STATUS handles this value special.

But with parallel replication, it can easily happen that the SQL driver thread
reaches the end of the relay log before a worker thread calls stmt_done(),
thus ending up with the wrong value in rli->last_master_timestamp and hence
wrong output of SHOW SLAVE STATUS.

Environment

None

Status

Assignee

Kristian Nielsen

Reporter

Kristian Nielsen

Labels

None

External issue ID

None

External issue ID

None

Fix versions

Affects versions

10.0.7

Priority

Major