Added mariadb10_slave_gtid and mariadb10_master_gtid options
The “mariadb_gtid” parameter is no longer available: “mariadb10_slave_gtid” is the new one. Another parameter “mariadb10_master_gtid” enable GTID registration. The latter set to On forces option “mariadb10_slave_gtid” to be On
This commit is contained in:
@ -196,7 +196,8 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
||||
{"encrypt_binlog", MXS_MODULE_PARAM_BOOL, "false"},
|
||||
{"encryption_algorithm", MXS_MODULE_PARAM_ENUM, "aes_cbc", MXS_MODULE_OPT_NONE, enc_algo_values},
|
||||
{"encryption_key_file", MXS_MODULE_PARAM_PATH, NULL, MXS_MODULE_OPT_PATH_R_OK},
|
||||
{"mariadb_gtid", MXS_MODULE_PARAM_BOOL, "false"},
|
||||
{"mariadb10_slave_gtid", MXS_MODULE_PARAM_BOOL, "false"},
|
||||
{"mariadb10_master_gtid", MXS_MODULE_PARAM_BOOL, "false"},
|
||||
{"shortburst", MXS_MODULE_PARAM_COUNT, DEF_SHORT_BURST},
|
||||
{"longburst", MXS_MODULE_PARAM_COUNT, DEF_LONG_BURST},
|
||||
{"burstsize", MXS_MODULE_PARAM_SIZE, DEF_BURST_SIZE},
|
||||
@ -362,8 +363,11 @@ createInstance(SERVICE *service, char **options)
|
||||
inst->request_semi_sync = config_get_bool(params, "semisync");
|
||||
inst->master_semi_sync = 0;
|
||||
|
||||
/* Enable MariaDB GTID tracking */
|
||||
inst->mariadb_gtid = config_get_bool(params, "mariadb_gtid");
|
||||
/* Enable MariaDB GTID tracking for slaves */
|
||||
inst->mariadb10_gtid = config_get_bool(params, "mariadb10_slave_gtid");
|
||||
|
||||
/* Enable MariaDB GTID registration to master */
|
||||
inst->mariadb10_master_gtid = config_get_bool(params, "mariadb10_master_gtid");
|
||||
|
||||
/* Binlog encryption */
|
||||
inst->encryption.enabled = config_get_bool(params, "encrypt_binlog");
|
||||
@ -528,9 +532,9 @@ createInstance(SERVICE *service, char **options)
|
||||
{
|
||||
inst->encryption.enabled = config_truth_value(value);
|
||||
}
|
||||
else if (strcmp(options[i], "mariadb_gtid") == 0)
|
||||
else if (strcmp(options[i], "mariadb10_slave_gtid") == 0)
|
||||
{
|
||||
inst->mariadb_gtid = config_truth_value(value);
|
||||
inst->mariadb10_gtid = config_truth_value(value);
|
||||
}
|
||||
else if (strcmp(options[i], "encryption_algorithm") == 0)
|
||||
{
|
||||
@ -689,9 +693,17 @@ createInstance(SERVICE *service, char **options)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Force GTID slave request handling if GTID Master registration is On
|
||||
*/
|
||||
if (inst->mariadb10_master_gtid)
|
||||
{
|
||||
inst->mariadb10_gtid = true;
|
||||
}
|
||||
|
||||
/* Enable MariaDB the GTID maps store */
|
||||
if (inst->mariadb10_compat &&
|
||||
inst->mariadb_gtid)
|
||||
inst->mariadb10_gtid)
|
||||
{
|
||||
if (!inst->trx_safe)
|
||||
{
|
||||
@ -1472,7 +1484,7 @@ diagnostics(MXS_ROUTER *router, DCB *dcb)
|
||||
dcb_printf(dcb, "\tLast event from master: 0x%x, %s\n",
|
||||
router_inst->lastEventReceived, (ptr != NULL) ? ptr : "unknown");
|
||||
|
||||
if (router_inst->mariadb_gtid &&
|
||||
if (router_inst->mariadb10_gtid &&
|
||||
router_inst->last_mariadb_gtid[0])
|
||||
{
|
||||
dcb_printf(dcb, "\tLast seen MariaDB GTID: %s\n",
|
||||
|
@ -648,11 +648,15 @@ typedef struct router_instance
|
||||
BINLOG_ENCRYPTION_SETUP encryption; /*< Binlog encryption setup */
|
||||
void *encryption_ctx; /*< Encryption context */
|
||||
char last_mariadb_gtid[GTID_MAX_LEN + 1]; /*< Last seen MariaDB 10 GTID */
|
||||
bool mariadb_gtid; /*< Save received MariaDB GTIDs into repo.
|
||||
* This allows MariaDB 10 slave servers
|
||||
* connecting with GTID */
|
||||
uint32_t mariadb_gtid_domain; /*< MariaDB 10 GTID Domain ID */
|
||||
sqlite3 *gtid_maps; /*< GTID storage */
|
||||
bool mariadb10_gtid; /*< Save received MariaDB GTIDs into repo.
|
||||
* This allows MariaDB 10 slave servers
|
||||
* connecting with GTID
|
||||
*/
|
||||
bool mariadb10_master_gtid;/*< Enables MariaDB 10 GTID registration
|
||||
* to MariaDB 10.0/10.1 Master
|
||||
*/
|
||||
uint32_t mariadb10_gtid_domain;/*< MariaDB 10 GTID Domain ID */
|
||||
sqlite3 *gtid_maps; /*< MariaDB 10 GTID storage */
|
||||
struct router_instance *next;
|
||||
} ROUTER_INSTANCE;
|
||||
|
||||
|
@ -2072,7 +2072,7 @@ blr_read_events_all_events(ROUTER_INSTANCE *router,
|
||||
router->pending_transaction.end_pos = 0;
|
||||
|
||||
/* Set MariaDB GTID */
|
||||
if (router->mariadb_gtid)
|
||||
if (router->mariadb10_gtid)
|
||||
{
|
||||
strcpy(router->pending_transaction.gtid, mariadb_gtid);
|
||||
}
|
||||
@ -2203,7 +2203,7 @@ blr_read_events_all_events(ROUTER_INSTANCE *router,
|
||||
replace_trx_events = false;
|
||||
|
||||
if (router->mariadb10_compat &&
|
||||
router->mariadb_gtid)
|
||||
router->mariadb10_gtid)
|
||||
{
|
||||
/* Update Last Seen MariaDB GTID */
|
||||
strcpy(router->last_mariadb_gtid, router->pending_transaction.gtid);
|
||||
|
@ -1065,8 +1065,8 @@ blr_handle_binlog_record(ROUTER_INSTANCE *router, GWBUF *pkt)
|
||||
|
||||
router->pending_transaction.state = BLRM_TRANSACTION_START;
|
||||
|
||||
/* Handle MariaDB GTID */
|
||||
if (router->mariadb_gtid)
|
||||
/* Handle MariaDB 10 GTID */
|
||||
if (router->mariadb10_gtid)
|
||||
{
|
||||
char mariadb_gtid[GTID_MAX_LEN + 1];
|
||||
snprintf(mariadb_gtid, GTID_MAX_LEN, "%u-%u-%lu",
|
||||
@ -1306,7 +1306,7 @@ blr_handle_binlog_record(ROUTER_INSTANCE *router, GWBUF *pkt)
|
||||
router->pending_transaction.end_pos = router->current_pos;
|
||||
|
||||
if (router->mariadb10_compat &&
|
||||
router->mariadb_gtid)
|
||||
router->mariadb10_gtid)
|
||||
{
|
||||
/* Update last seen MariaDB GTID */
|
||||
strcpy(router->last_mariadb_gtid, router->pending_transaction.gtid);
|
||||
@ -2734,7 +2734,7 @@ static void blr_register_cache_response(ROUTER_INSTANCE *router,
|
||||
static void blr_start_master_registration(ROUTER_INSTANCE *router, GWBUF *buf)
|
||||
{
|
||||
char task_name[BLRM_TASK_NAME_LEN + 1] = "";
|
||||
|
||||
|
||||
switch (router->master_state)
|
||||
{
|
||||
case BLRM_TIMESTAMP:
|
||||
@ -2780,10 +2780,10 @@ static void blr_start_master_registration(ROUTER_INSTANCE *router, GWBUF *buf)
|
||||
buf);
|
||||
// Next state is BLRM_MARIADB10_GTID_DOMAIN or BLRM_LATIN1
|
||||
{
|
||||
unsigned int state = router->mariadb_gtid ?
|
||||
unsigned int state = router->mariadb10_master_gtid ?
|
||||
BLRM_MARIADB10_GTID_DOMAIN :
|
||||
BLRM_LATIN1;
|
||||
const char *command = router->mariadb_gtid ?
|
||||
const char *command = router->mariadb10_master_gtid ?
|
||||
"SELECT @@GLOBAL.gtid_domain_id" :
|
||||
"SET NAMES latin1";
|
||||
blr_register_send_command(router, command, state);
|
||||
@ -3019,7 +3019,7 @@ static void blr_register_mariadb_gtid_domain(ROUTER_INSTANCE *router,
|
||||
// Extract GTID domain
|
||||
char *val = blr_extract_column(buf, 1);
|
||||
// Store the Master GTID domain
|
||||
router->mariadb_gtid_domain = atol(val);
|
||||
router->mariadb10_gtid_domain = atol(val);
|
||||
MXS_FREE(val);
|
||||
// Don't save the server response
|
||||
gwbuf_free(buf);
|
||||
|
@ -6019,7 +6019,7 @@ static bool blr_handle_select_stmt(ROUTER_INSTANCE *router,
|
||||
strcpy(heading, word);
|
||||
|
||||
if (router->mariadb10_compat &&
|
||||
router->mariadb_gtid)
|
||||
router->mariadb10_gtid)
|
||||
{
|
||||
spinlock_acquire(&router->binlog_lock);
|
||||
strcpy(mariadb_gtid, router->last_mariadb_gtid);
|
||||
@ -6035,14 +6035,15 @@ static bool blr_handle_select_stmt(ROUTER_INSTANCE *router,
|
||||
}
|
||||
else if (strcasecmp(word, "@@GLOBAL.gtid_domain_id") == 0)
|
||||
{
|
||||
/* If not mariadb an error message will be returned */
|
||||
if (slave->mariadb10_compat && router->mariadb_gtid)
|
||||
/* If not mariadb10 mastergtid an error message will be returned */
|
||||
if (slave->mariadb10_compat &&
|
||||
router->mariadb10_master_gtid)
|
||||
{
|
||||
char heading[40];
|
||||
char gtid_domain[40];
|
||||
sprintf(gtid_domain,
|
||||
"%lu",
|
||||
(unsigned long)router->mariadb_gtid_domain);
|
||||
(unsigned long)router->mariadb10_gtid_domain);
|
||||
strcpy(heading, word);
|
||||
|
||||
blr_slave_send_var_value(router,
|
||||
@ -6911,7 +6912,7 @@ static bool blr_handle_set_stmt(ROUTER_INSTANCE *router,
|
||||
{
|
||||
/* If not mariadb an error message will be returned */
|
||||
if (slave->mariadb10_compat &&
|
||||
router->mariadb_gtid &&
|
||||
router->mariadb10_gtid &&
|
||||
(word = strtok_r(NULL, sep, &brkb)) != NULL)
|
||||
{
|
||||
char heading[GTID_MAX_LEN + 1];
|
||||
@ -6938,7 +6939,7 @@ static bool blr_handle_set_stmt(ROUTER_INSTANCE *router,
|
||||
{
|
||||
/* If not mariadb an error message will be returned */
|
||||
if (slave->mariadb10_compat &&
|
||||
router->mariadb_gtid &&
|
||||
router->mariadb10_gtid &&
|
||||
(word = strtok_r(NULL, sep, &brkb)) != NULL)
|
||||
{
|
||||
/* Set strict mode */
|
||||
@ -6951,7 +6952,7 @@ static bool blr_handle_set_stmt(ROUTER_INSTANCE *router,
|
||||
{
|
||||
/* If not mariadb an error message will be returned */
|
||||
if (slave->mariadb10_compat &&
|
||||
router->mariadb_gtid)
|
||||
router->mariadb10_gtid)
|
||||
{
|
||||
blr_slave_send_ok(router, slave);
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user