• Brandon Nesterenko's avatar
    MDEV-32265: seconds_behind_master is inaccurate for Delayed replication · c5f776e9
    Brandon Nesterenko authored
    If a replica is actively delaying a transaction when restarted (STOP
    SLAVE/START SLAVE), when the sql thread is back up,
    Seconds_Behind_Master will present as 0 until the configured
    MASTER_DELAY has passed. That is, before the restart,
    last_master_timestamp is updated to the timestamp of the delayed
    event. Then after the restart, the negation of sql_thread_caught_up
    is skipped because the timestamp of the event has already been used
    for the last_master_timestamp, and their update is grouped together
    in the same conditional block.
    
    This patch fixes this by separating the negation of
    sql_thread_caught_up out of the timestamp-dependent block, so it is
    called any time an idle parallel slave queues an event to a worker.
    
    Note that sql_thread_caught_up is still left in the check for internal
    events, as SBM should remain idle in such case to not "magically" begin
    incrementing.
    
    Reviewed By:
    ============
    Andrei Elkin <andrei.elkin@mariadb.com>
    c5f776e9
rpl_parallel_sbm.result 3.05 KB