mariadb/mysql-test/include/show_events.inc
unknown 5aa0d185ca 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.
2013-05-03 11:27:29 +02:00

67 lines
2.2 KiB
PHP

##############################################################################
# It's an auxiliary file used to show binary log events or relay log events.
# It is only called by show_binlog_events.inc and show_relaylog_events.inc.
##############################################################################
# Do not modify $binlog_start - if we did, it could wrongly persist until a
# later call of show_events.inc.
if ($binlog_start)
{
--let $_binlog_start= $binlog_start
}
--let $_statement=show binlog events
if ($is_relay_log)
{
--let $_statement=show relaylog events
}
if ($binlog_file)
{
--let $_binlog_file= $binlog_file
if ($_binlog_file == 'LAST')
{
if ($is_relay_log)
{
--let $_binlog_file= query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1)
}
if (!$is_relay_log)
{
--let $_binlog_file= query_get_value(SHOW MASTER STATUS, File, 1)
}
}
--let $_statement= $_statement in '$_binlog_file'
}
if (!$binlog_start)
{
# If $binlog_start is not set, we will set it as the fourth event's
# position (second in relay log which has not Binlog Checkpoing nor
# Gtid_list events).
# The first three events (Description Event, Gtid list, and Binlog Checkpoint
# event) are always ignored. For description event's length might be changed
# because of adding new events, 'SHOW BINLOG EVENTS LIMIT 3' is used to get
# the right value.
if ($is_relay_log)
{
--let $_binlog_start= query_get_value($_statement LIMIT 1, End_log_pos, 1)
}
if (!$is_relay_log)
{
--let $_binlog_start= query_get_value($_statement LIMIT 3, End_log_pos, 3)
}
}
--let $_statement= $_statement from $_binlog_start
# Cannot use if($binlog_limit) since the variable may begin with a 0
if (`SELECT '$binlog_limit' <> ''`)
{
--let $_statement= $_statement limit $binlog_limit
}
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR $_binlog_start <binlog_start>
--replace_column 2 # 4 # 5 #
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ /file_id=[0-9]+/file_id=#/ /block_len=[0-9]+/block_len=#/ /Server ver:.*$/SERVER_VERSION, BINLOG_VERSION/ /GTID [0-9]+-[0-9]+-[0-9]+/GTID #-#-#/ /\[([0-9]-[0-9]-[0-9]+)\]/[#-#-#]/
--eval $_statement