• unknown's avatar
    MDEV-4473: mysql_binlog_send() starts sending events from wrong GTID position... · 5aa0d185
    unknown authored
    MDEV-4473: mysql_binlog_send() starts sending events from wrong GTID position in some master failover scenarios
    
    Suppose binlog file X has in its Gtid_list_event: 0-1-3,0-2-5, and suppose the
    slave requests to start replicating after 0-1-3.
    
    In this case the bug was that master would start sending events from the start
    of X. This is wrong, because 0-2-4 and 0-2-5 are contained in X-1, and are
    needed by the slave. So these events were lost.
    
    On the other hand, if the slave requested 0-2-5, then it _is_ correct to start
    sending from the beginning of binlog file X, because 0-2-5 is the last GTID
    logged in earlier binlogs. The difference is that 0-2-5 is the last of the
    GTIDs in the Gtid_list_event. The problem was that the code did not check that
    the matched GTID was the last one in the list.
    
    Fixed by checking if the gtid requested by slave that matches a gtid in the
    Gtid_list_event is the last event for that domain in the list. If not, go back
    to a prior binlog to ensure all needed events are sent to slave.
    
    mysql-test/include/show_events.inc:
      Backport --let $binlog_file=LAST, used by MDEV-4473 test case.
    5aa0d185
sql_repl.cc 108 KB