• unknown's avatar
    MDEV-26: Global transaction ID. · 5cb486d1
    unknown authored
    Fix problems related to reconnect. When we need to reconnect (ie. explict
    stop/start of just the IO thread by user, or automatic reconnect due to
    loosing network connection with the master), it is a bit complex to correctly
    resume at the right point without causing duplicate or missing events in the
    relay log. The previous code had multiple problems in this regard.
    
    With this patch, the problem is solved as follows. The IO thread keeps track
    (in memory) of which GTID was last queued to the relay log. If it needs to
    reconnect, it resumes at that GTID position. It also counts number of events
    received within the last, possibly partial, event group, and skips the same
    number of events after a reconnect, so that events already enqueued before the
    reconnect are not duplicated.
    
    (There is no need to keep any persistent state; whenever we restart slave
    threads after both of them being stopped (such as after server restart), we
    erase the relay logs and start over from the last GTID applied by SQL thread.
    But while the SQL thread is running, this patch is needed to get correct relay
    log).
    5cb486d1
rpl_mi.cc 41.7 KB