MXS-1530: check ANNOTATE_ROWS flag in connecting slave

MXS-1530: check ANNOTATE_ROWS flag in connecting slave.

In MariaDB 10.2.4 replicate_annotate_row_events and
binlog_annotate_row_events have default to ON: this change checks
whether the connecting slave is not has ANNOTATE_ROWS in
blr_slave_binlog_dump(), those ANNOTATE_ROWS events can be sent or not
to the slave.
This commit is contained in:
MassimilianoPinto
2017-11-24 09:38:17 +01:00
parent dd699f2739
commit 927b4addc8
2 changed files with 31 additions and 2 deletions

View File

@ -440,6 +440,7 @@ typedef struct router_slave
char lsi_binlog_name[BINLOG_FNAMELEN + 1]; /*< Which binlog file */
uint32_t lsi_binlog_pos; /*< What position */
void *encryption_ctx; /*< Encryption context */
bool annotate_rows; /*< MariaDB 10 Slave requests ANNOTATE_ROWS */
#if defined(SS_DEBUG)
skygw_chk_t rses_chk_tail;
#endif

View File

@ -2033,7 +2033,21 @@ blr_slave_binlog_dump(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, GWBUF *queue
}
slave->binlog_pos = extract_field(ptr, 32);
/* Go ahead: after 4 bytes pos we have 2 bytes flags */
ptr += 4;
uint16_t flags = gw_mysql_get_byte2(ptr);
/* Check whether connected slave is asking for ANNOTATE_ROWS events */
if (flags & BLR_REQUEST_ANNOTATE_ROWS_EVENT)
{
slave->annotate_rows = true;
MXS_INFO("Registering slave (server-id %d) asks "
"for ANNOTATE_ROWS events.",
slave->serverid);
}
/* Go ahead: after 2 bytes flags and 4 bytes serverid */
ptr += 2;
ptr += 4;
memcpy(slave->binlogfile, (char *)ptr, binlognamelen);
@ -2381,9 +2395,13 @@ blr_slave_catchup(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, bool large)
strcpy(binlog_name, slave->binlogfile);
binlog_pos = slave->binlog_pos;
/* Don't sent special events generated by MaxScale */
/* Don't sent special events generated by MaxScale
* or ANNOTATE_ROWS events if not requested
*/
if (hdr.event_type == MARIADB10_START_ENCRYPTION_EVENT ||
hdr.event_type == IGNORABLE_EVENT)
hdr.event_type == IGNORABLE_EVENT ||
(!slave->annotate_rows &&
hdr.event_type == MARIADB_ANNOTATE_ROWS_EVENT))
{
/* In case of file rotation or pos = 4 the events are sent from position 4.
* new FDE at pos 4 is read.
@ -2416,6 +2434,16 @@ blr_slave_catchup(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, bool large)
slave->binlogfile,
(unsigned long) hdr.next_pos);
}
/* MARIADB_ANNOTATE_ROWS_EVENT is skipped: just log that */
else if (hdr.event_type == MARIADB_ANNOTATE_ROWS_EVENT)
{
MXS_INFO("Skipping ANNOTATE_ROWS event [%s] of size %lu while "
"reading binlog %s at %lu",
blr_get_event_description(router, hdr.event_type),
(unsigned long)hdr.event_size,
slave->binlogfile,
(unsigned long)slave->binlog_pos);
}
else
{
MXS_INFO("Found ignorable event [%s] of size %lu while reading binlog %s at %lu",