Merge branch '2.2' into 2.2-mrm

This commit is contained in:
Markus Mäkelä
2017-10-30 11:06:34 +02:00
49 changed files with 1458 additions and 500 deletions

View File

@ -190,7 +190,6 @@ MXS_MODULE* MXS_CREATE_MODULE()
MXS_MODULE_OPT_NONE, enc_algo_values
},
{"encryption_key_file", MXS_MODULE_PARAM_PATH, NULL, MXS_MODULE_OPT_PATH_R_OK},
{"mariadb10_slave_gtid", MXS_MODULE_PARAM_BOOL, "false"},
{"mariadb10_master_gtid", MXS_MODULE_PARAM_BOOL, "false"},
{
"binlog_structure", MXS_MODULE_PARAM_ENUM, "flat",
@ -359,8 +358,8 @@ createInstance(SERVICE *service, char **options)
inst->request_semi_sync = config_get_bool(params, "semisync");
inst->master_semi_sync = 0;
/* Enable MariaDB GTID tracking for slaves */
inst->mariadb10_gtid = config_get_bool(params, "mariadb10_slave_gtid");
/* Enable MariaDB GTID tracking for slaves if MariaDB 10 compat is set */
inst->mariadb10_gtid = inst->mariadb10_compat;
/* Enable MariaDB GTID registration to master */
inst->mariadb10_master_gtid = config_get_bool(params, "mariadb10_master_gtid");
@ -379,10 +378,8 @@ createInstance(SERVICE *service, char **options)
/* Set router uuid */
inst->uuid = config_copy_string(params, "uuid");
/* Enable Flat or Tree storage of binlog files */
inst->storage_type = config_get_enum(params,
"binlog_structure",
binlog_storage_values);
/* Set Flat storage of binlog files as default */
inst->storage_type = BLR_BINLOG_STORAGE_FLAT;
if (inst->uuid == NULL)
{
@ -541,21 +538,10 @@ createInstance(SERVICE *service, char **options)
{
inst->encryption.enabled = config_truth_value(value);
}
else if (strcmp(options[i], "mariadb10_slave_gtid") == 0)
{
inst->mariadb10_gtid = config_truth_value(value);
}
else if (strcmp(options[i], "mariadb10_master_gtid") == 0)
{
inst->mariadb10_master_gtid = config_truth_value(value);
}
else if (strcmp(options[i], "binlog_structure") == 0)
{
/* Enable Flat or Tree storage of binlog files */
inst->storage_type = strcasecmp(value, "tree") == 0 ?
BLR_BINLOG_STORAGE_TREE :
BLR_BINLOG_STORAGE_FLAT;
}
else if (strcmp(options[i], "encryption_algorithm") == 0)
{
int ret = blr_check_encryption_algorithm(value);
@ -780,24 +766,12 @@ createInstance(SERVICE *service, char **options)
inst->mariadb10_compat = true;
}
/**
* Force GTID slave request handling if GTID Master registration is On
*/
if (inst->mariadb10_master_gtid)
{
/* Force GTID slave request handling */
inst->mariadb10_gtid = true;
}
if (!inst->mariadb10_master_gtid &&
inst->storage_type == BLR_BINLOG_STORAGE_TREE)
{
MXS_ERROR("%s: binlog_structure 'tree' mode can be enabled only"
" with MariaDB Master GTID registration feature."
" Please enable it with option"
" 'mariadb10_master_gtid = on'",
service->name);
free_instance(inst);
return NULL;
/* Force binlog storage as tree */
inst->storage_type = BLR_BINLOG_STORAGE_TREE;
}
/* Log binlog structure storage mode */
@ -806,6 +780,7 @@ createInstance(SERVICE *service, char **options)
inst->storage_type == BLR_BINLOG_STORAGE_FLAT ?
"'flat' mode" :
"'tree' mode using GTID domain_id and server_id");
/* Enable MariaDB the GTID maps store */
if (inst->mariadb10_compat &&
inst->mariadb10_gtid)

View File

@ -62,8 +62,7 @@
* 11/07/2016 Massimiliano Pinto Added SSL backend support
* 24/08/2016 Massimiliano Pinto Added slave notification via CS_WAIT_DATA
* 16/09/2016 Massimiliano Pinto Special events created by MaxScale are not sent to slaves:
* MARIADB10_START_ENCRYPTION_EVENT or IGNORABLE_EVENT
* Events with LOG_EVENT_IGNORABLE_F are skipped as well.
* MARIADB10_START_ENCRYPTION_EVENT or IGNORABLE_EVENT.
*
* @endverbatim
*/
@ -89,6 +88,7 @@
#include <zlib.h>
#include <maxscale/alloc.h>
#include <inttypes.h>
#include <maxscale/utils.h>
/**
* This struct is used by sqlite3_exec callback routine
@ -1169,6 +1169,20 @@ static const char *mariadb10_gtid_status_columns[] =
NULL
};
/*
* Extra Columns to send in "SHOW ALL SLAVES STATUS" MariaDB 10 command
*/
static const char *mariadb10_extra_status_columns[] =
{
"Retried_transactions",
"Max_relay_log_size",
"Executed_log_entries",
"Slave_received_heartbeats",
"Slave_heartbeat_period",
"Gtid_Slave_Pos",
NULL
};
/**
* Send the response to the SQL command "SHOW SLAVE STATUS" or
* SHOW ALL SLAVES STATUS
@ -1193,19 +1207,13 @@ blr_slave_send_slave_status(ROUTER_INSTANCE *router,
int gtid_cols = 0;
/* Count SHOW SLAVE STATUS the columns */
while (slave_status_columns[ncols])
{
ncols++;
}
ncols += MXS_ARRAY_NELEMS(slave_status_columns) - 1;
/* Add the new SHOW ALL SLAVES STATUS columns */
if (all_slaves)
{
int k = 0;
while (all_slaves_status_columns[k++])
{
ncols++;
}
ncols += MXS_ARRAY_NELEMS(all_slaves_status_columns) - 1;
ncols += MXS_ARRAY_NELEMS(mariadb10_extra_status_columns) - 1;
}
/* Get the right GTID columns array */
@ -1258,6 +1266,20 @@ blr_slave_send_slave_status(ROUTER_INSTANCE *router,
seqno++);
}
/* Send extra columns for SHOW ALL SLAVES STATUS */
if (all_slaves)
{
for (i = 0; mariadb10_extra_status_columns[i]; i++)
{
blr_slave_send_columndef(router,
slave,
mariadb10_extra_status_columns[i],
BLR_TYPE_STRING,
40,
seqno++);
}
}
/* Send EOF for columns def */
blr_slave_send_eof(router, slave, seqno++);
@ -1650,6 +1672,50 @@ blr_slave_send_slave_status(ROUTER_INSTANCE *router,
ptr += col_len;
}
if (all_slaves)
{
// Retried_transactions
sprintf(column, "%d", 0);
col_len = strlen(column);
*ptr++ = col_len; // Length of result string
memcpy((char *)ptr, column, col_len); // Result string
ptr += col_len;
*ptr++ = 0; // Max_relay_log_size
*ptr++ = 0; // Executed_log_entries
// Slave_received_heartbeats
sprintf(column, "%d", router->stats.n_heartbeats);
col_len = strlen(column);
*ptr++ = col_len; // Length of result string
memcpy((char *)ptr, column, col_len); // Result string
ptr += col_len;
// Slave_heartbeat_period
sprintf(column, "%lu", router->heartbeat);
col_len = strlen(column);
*ptr++ = col_len; // Length of result string
memcpy((char *)ptr, column, col_len); // Result string
ptr += col_len;
//Gtid_Slave_Pos
if (!router->mariadb10_gtid)
{
// No GTID support send empty values
*ptr++ = 0;
}
else
{
sprintf(column,
"%s",
router->last_mariadb_gtid);
col_len = strlen(column);
*ptr++ = col_len; // Length of result string
memcpy(ptr, column, col_len); // Result string
ptr += col_len;
}
}
*ptr++ = 0;
actual_len = ptr - (uint8_t *)GWBUF_DATA(pkt);
@ -2308,8 +2374,7 @@ blr_slave_catchup(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, bool large)
/* Don't sent special events generated by MaxScale */
if (hdr.event_type == MARIADB10_START_ENCRYPTION_EVENT ||
hdr.event_type == IGNORABLE_EVENT ||
(hdr.flags & LOG_EVENT_IGNORABLE_F))
hdr.event_type == IGNORABLE_EVENT)
{
/* In case of file rotation or pos = 4 the events
* are sent from position 4 and the new FDE at pos 4 is read.