• Kristian Nielsen's avatar
    MDEV-6589: Incorrect relay log start position when restarting SQL thread after... · ad0d203f
    Kristian Nielsen authored
    MDEV-6589: Incorrect relay log start position when restarting SQL thread after error in parallel replication
    
    The problem occurs in parallel replication in GTID mode, when we are using
    multiple replication domains. In this case, if the SQL thread stops, the
    slave GTID position may refer to a different point in the relay log for each
    domain.
    
    The bug was that when the SQL thread was stopped and restarted (but the IO
    thread was kept running), the SQL thread would resume applying the relay log
    from the point of the most advanced replication domain, silently skipping all
    earlier events within other domains. This caused replication corruption.
    
    This patch solves the problem by storing, when the SQL thread stops with
    multiple parallel replication domains active, the current GTID
    position. Additionally, the current position in the relay logs is moved back
    to a point known to be earlier than the current position of any replication
    domain. Then when the SQL thread restarts from the earlier position, GTIDs
    encountered are compared against the stored GTID position. Any GTID that was
    already applied before the stop is skipped to avoid duplicate apply.
    
    This patch should have no effect if multi-domain GTID parallel replication is
    not used. Similarly, if both SQL and IO thread are stopped and restarted, the
    patch has no effect, as in this case the existing relay logs are removed and
    re-fetched from the master at the current global @@gtid_slave_pos.
    ad0d203f
rpl_parallel.h 11.3 KB