Commit 2cf3d61f authored by unknown's avatar unknown

MDEV-26: Global Transaction ID

 - Fix skipping initial MyISAM DML when connecting using GTID.

 - Fix RESET MASTER not clearing in-memory binlog state.

 - Fix not reading standalone flag in Gtid_log_event::peek().

 - Fix skipping DDL that the slave has already seen when using GTID position.
parent fff47f40
......@@ -3834,6 +3834,9 @@ bool MYSQL_BIN_LOG::reset_logs(THD* thd, bool create_new_log)
break;
}
if (!is_relay_log)
rpl_global_gtid_binlog_state.reset();
/* Start logging with a new file */
close(LOG_CLOSE_INDEX | LOG_CLOSE_TO_BE_OPENED);
if ((error= my_delete_allow_opened(index_file_name, MYF(0)))) // Reset (open will update)
......
......@@ -4271,6 +4271,17 @@ Query_log_event::do_shall_skip(Relay_log_info *rli)
DBUG_RETURN(Log_event::do_shall_skip(rli));
}
bool
Query_log_event::peek_is_commit_rollback(const char *event_start,
size_t event_len)
{
if (event_len < LOG_EVENT_HEADER_LEN + QUERY_HEADER_LEN || event_len < 9)
return false;
return !memcmp(event_start + (event_len-7), "\0COMMIT", 7) ||
!memcmp(event_start + (event_len-9), "\0ROLLBACK", 9);
}
#endif
......@@ -7028,6 +7039,8 @@ Gtid_log_event::peek(const char *event_start, size_t event_len,
*seq_no= uint8korr(p);
p+= 8;
*domain_id= uint4korr(p);
p+= 4;
*flags2= (uchar)*p;
return false;
}
......
......@@ -1913,6 +1913,8 @@ public: /* !!! Public in this patch to allow old usage */
int do_apply_event(Relay_log_info const *rli,
const char *query_arg,
uint32 q_len_arg);
static bool peek_is_commit_rollback(const char *event_start,
size_t event_len);
#endif /* HAVE_REPLICATION */
/*
If true, the event always be applied by slave SQL thread or be printed by
......
......@@ -1015,6 +1015,7 @@ send_event_to_slave(THD *thd, NET *net, String* const packet, ushort flags,
enum_gtid_skip_type *gtid_skip_group)
{
my_off_t pos;
size_t len= packet->length();
/* Skip GTID event groups until we reach slave position within a domain_id. */
if (event_type == GTID_EVENT && using_gtid_state && gtid_state->count() > 0)
......@@ -1023,7 +1024,6 @@ send_event_to_slave(THD *thd, NET *net, String* const packet, ushort flags,
uint64 seq_no;
uchar flags2;
rpl_gtid *gtid;
size_t len= packet->length();
if (ev_offset > len ||
Gtid_log_event::peek(packet->ptr()+ev_offset, len - ev_offset,
......@@ -1054,7 +1054,8 @@ send_event_to_slave(THD *thd, NET *net, String* const packet, ushort flags,
switch (*gtid_skip_group)
{
case GTID_SKIP_STANDALONE:
if (event_type != INTVAR_EVENT &&
if (event_type != GTID_EVENT &&
event_type != INTVAR_EVENT &&
event_type != RAND_EVENT &&
event_type != USER_VAR_EVENT &&
event_type != TABLE_MAP_EVENT &&
......@@ -1062,7 +1063,10 @@ send_event_to_slave(THD *thd, NET *net, String* const packet, ushort flags,
*gtid_skip_group= GTID_SKIP_NOT;
return NULL;
case GTID_SKIP_TRANSACTION:
if (event_type == XID_EVENT /* ToDo || is_COMMIT_query_event() */)
if (event_type == XID_EVENT ||
(event_type == QUERY_EVENT &&
Query_log_event::peek_is_commit_rollback(packet->ptr() + ev_offset,
len - ev_offset)))
*gtid_skip_group= GTID_SKIP_NOT;
return NULL;
case GTID_SKIP_NOT:
......@@ -1173,7 +1177,7 @@ send_event_to_slave(THD *thd, NET *net, String* const packet, ushort flags,
(thd, flags, packet, log_file_name, pos)))
return "run 'before_send_event' hook failed";
if (my_net_write(net, (uchar*) packet->ptr(), packet->length()))
if (my_net_write(net, (uchar*) packet->ptr(), len))
return "Failed on my_net_write()";
DBUG_PRINT("info", ("log event code %d", (*packet)[LOG_EVENT_OFFSET+1] ));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment