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