mirror of
https://github.com/MariaDB/server.git
synced 2025-07-27 18:02:13 +03:00
MDEV-6403: Temporary tables lost at STOP SLAVE in GTID mode if master has not rotated binlog since restart
The binlog contains specially marked format description events to mark when a master restart happened (which could have caused temporary tables to be silently dropped). Such events also cause slave to close temporary tables. However, there was a bug that if after this, slave re-connects to the master in GTID mode, the master can send an old format description event again. If temporary tables are closed when such event is seen for the second time, it might drop temporary tables created after that event, and cause replication failure. With this patch, the restart flag of the format description event is cleared by the master when it is sent to the slave in a subsequent connection, to avoid the errorneous temp table close.
This commit is contained in:
@ -2375,6 +2375,31 @@ impossible position";
|
||||
info.fdev= tmp;
|
||||
|
||||
(*packet)[FLAGS_OFFSET+ev_offset] &= ~LOG_EVENT_BINLOG_IN_USE_F;
|
||||
|
||||
if (info.using_gtid_state)
|
||||
{
|
||||
/*
|
||||
If this event has the field `created' set, then it will cause the
|
||||
slave to delete all active temporary tables. This must not happen
|
||||
if the slave received any later GTIDs in a previous connect, as
|
||||
those GTIDs might have created new temporary tables that are still
|
||||
needed.
|
||||
|
||||
So here, we check if the starting GTID position was already
|
||||
reached before this format description event. If not, we clear the
|
||||
`created' flag to preserve temporary tables on the slave. (If the
|
||||
slave connects at a position past this event, it means that it
|
||||
already received and handled it in a previous connect).
|
||||
*/
|
||||
if (!info.gtid_state.is_pos_reached())
|
||||
{
|
||||
int4store((char*) packet->ptr()+LOG_EVENT_MINIMAL_HEADER_LEN+
|
||||
ST_CREATED_OFFSET+ev_offset, (ulong) 0);
|
||||
if (info.current_checksum_alg != BINLOG_CHECKSUM_ALG_OFF &&
|
||||
info.current_checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF)
|
||||
fix_checksum(packet, ev_offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef DBUG_OFF
|
||||
|
Reference in New Issue
Block a user