Merge branch '2.2' into 2.2-mrm
This commit is contained in:
@ -99,7 +99,8 @@ void avro_close_binlog(int fd)
|
||||
* @param filepath Path to the created file
|
||||
* @param json_schema The schema of the table in JSON format
|
||||
*/
|
||||
AVRO_TABLE* avro_table_alloc(const char* filepath, const char* json_schema, const char *codec, size_t block_size)
|
||||
AVRO_TABLE* avro_table_alloc(const char* filepath, const char* json_schema, const char *codec,
|
||||
size_t block_size)
|
||||
{
|
||||
AVRO_TABLE *table = MXS_CALLOC(1, sizeof(AVRO_TABLE));
|
||||
if (table)
|
||||
|
@ -69,15 +69,15 @@ static const char* codec_to_string(enum mxs_avro_codec_type type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case MXS_AVRO_CODEC_NULL:
|
||||
return "null";
|
||||
case MXS_AVRO_CODEC_DEFLATE:
|
||||
return "deflate";
|
||||
case MXS_AVRO_CODEC_SNAPPY:
|
||||
return "snappy";
|
||||
default:
|
||||
ss_dassert(false);
|
||||
return "null";
|
||||
case MXS_AVRO_CODEC_NULL:
|
||||
return "null";
|
||||
case MXS_AVRO_CODEC_DEFLATE:
|
||||
return "deflate";
|
||||
case MXS_AVRO_CODEC_SNAPPY:
|
||||
return "snappy";
|
||||
default:
|
||||
ss_dassert(false);
|
||||
return "null";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -87,11 +87,11 @@ static char *avro_client_ouput[] = { "Undefined", "JSON", "Avro" };
|
||||
static inline bool is_reserved_word(const char* word)
|
||||
{
|
||||
return strcasecmp(word, avro_domain) == 0 ||
|
||||
strcasecmp(word, avro_server_id) == 0 ||
|
||||
strcasecmp(word, avro_sequence) == 0 ||
|
||||
strcasecmp(word, avro_event_number) == 0 ||
|
||||
strcasecmp(word, avro_event_type) == 0 ||
|
||||
strcasecmp(word, avro_timestamp) == 0;
|
||||
strcasecmp(word, avro_server_id) == 0 ||
|
||||
strcasecmp(word, avro_sequence) == 0 ||
|
||||
strcasecmp(word, avro_event_number) == 0 ||
|
||||
strcasecmp(word, avro_event_type) == 0 ||
|
||||
strcasecmp(word, avro_timestamp) == 0;
|
||||
}
|
||||
|
||||
static inline void fix_reserved_word(char *tok)
|
||||
|
@ -185,13 +185,17 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
||||
{"transaction_safety", MXS_MODULE_PARAM_BOOL, "false"},
|
||||
{"semisync", MXS_MODULE_PARAM_BOOL, "false"},
|
||||
{"encrypt_binlog", MXS_MODULE_PARAM_BOOL, "false"},
|
||||
{"encryption_algorithm", MXS_MODULE_PARAM_ENUM, "aes_cbc",
|
||||
MXS_MODULE_OPT_NONE, enc_algo_values},
|
||||
{
|
||||
"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},
|
||||
{"mariadb10_slave_gtid", MXS_MODULE_PARAM_BOOL, "false"},
|
||||
{"mariadb10_master_gtid", MXS_MODULE_PARAM_BOOL, "false"},
|
||||
{"binlog_structure", MXS_MODULE_PARAM_ENUM, "flat",
|
||||
MXS_MODULE_OPT_NONE, binlog_storage_values},
|
||||
{
|
||||
"binlog_structure", MXS_MODULE_PARAM_ENUM, "flat",
|
||||
MXS_MODULE_OPT_NONE, binlog_storage_values
|
||||
},
|
||||
{"shortburst", MXS_MODULE_PARAM_COUNT, DEF_SHORT_BURST},
|
||||
{"longburst", MXS_MODULE_PARAM_COUNT, DEF_LONG_BURST},
|
||||
{"burstsize", MXS_MODULE_PARAM_SIZE, DEF_BURST_SIZE},
|
||||
@ -788,9 +792,9 @@ createInstance(SERVICE *service, char **options)
|
||||
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'",
|
||||
" with MariaDB Master GTID registration feature."
|
||||
" Please enable it with option"
|
||||
" 'mariadb10_master_gtid = on'",
|
||||
service->name);
|
||||
free_instance(inst);
|
||||
return NULL;
|
||||
@ -1117,9 +1121,9 @@ createInstance(SERVICE *service, char **options)
|
||||
" Please issue SET @@GLOBAL.GTID_SLAVE_POS =''"
|
||||
" and START SLAVE."
|
||||
" Existing binlogs might be overwritten.");
|
||||
MXS_ERROR("%s: %s",
|
||||
inst->service->name,
|
||||
inst->m_errmsg);
|
||||
MXS_ERROR("%s: %s",
|
||||
inst->service->name,
|
||||
inst->m_errmsg);
|
||||
|
||||
return (MXS_ROUTER *)inst;
|
||||
}
|
||||
@ -1239,7 +1243,7 @@ newSession(MXS_ROUTER *instance, MXS_SESSION *session)
|
||||
slave->encryption_ctx = NULL;
|
||||
slave->mariadb_gtid = NULL;
|
||||
slave->gtid_maps = NULL;
|
||||
memset(&slave->f_info, 0 , sizeof (MARIADB_GTID_INFO));
|
||||
memset(&slave->f_info, 0, sizeof (MARIADB_GTID_INFO));
|
||||
|
||||
/**
|
||||
* Add this session to the list of active sessions.
|
||||
@ -1975,10 +1979,12 @@ static json_t* diagnostics_json(const MXS_ROUTER *router)
|
||||
{
|
||||
json_t* obj = json_object();
|
||||
|
||||
json_object_set_new(obj, "ssl_ca_cert", json_string(router_inst->service->dbref->server->server_ssl->ssl_ca_cert));
|
||||
json_object_set_new(obj, "ssl_ca_cert",
|
||||
json_string(router_inst->service->dbref->server->server_ssl->ssl_ca_cert));
|
||||
json_object_set_new(obj, "ssl_cert", json_string(router_inst->service->dbref->server->server_ssl->ssl_cert));
|
||||
json_object_set_new(obj, "ssl_key", json_string(router_inst->service->dbref->server->server_ssl->ssl_key));
|
||||
json_object_set_new(obj, "ssl_version", json_string(router_inst->ssl_version ? router_inst->ssl_version : "MAX"));
|
||||
json_object_set_new(obj, "ssl_version",
|
||||
json_string(router_inst->ssl_version ? router_inst->ssl_version : "MAX"));
|
||||
|
||||
json_object_set_new(rval, "master_ssl", obj);
|
||||
}
|
||||
@ -1989,9 +1995,9 @@ static json_t* diagnostics_json(const MXS_ROUTER *router)
|
||||
json_t* obj = json_object();
|
||||
|
||||
json_object_set_new(obj, "key", json_string(
|
||||
router_inst->encryption.key_management_filename));
|
||||
router_inst->encryption.key_management_filename));
|
||||
json_object_set_new(obj, "algorithm", json_string(
|
||||
blr_get_encryption_algorithm(router_inst->encryption.encryption_algorithm)));
|
||||
blr_get_encryption_algorithm(router_inst->encryption.encryption_algorithm)));
|
||||
json_object_set_new(obj, "key_length",
|
||||
json_integer(8 * router_inst->encryption.key_len));
|
||||
|
||||
@ -2050,7 +2056,7 @@ static json_t* diagnostics_json(const MXS_ROUTER *router)
|
||||
json_object_set_new(rval, "residual_packets", json_integer(router_inst->stats.n_residuals));
|
||||
|
||||
double average_packets = router_inst->stats.n_reads != 0 ?
|
||||
((double)router_inst->stats.n_binlogs / router_inst->stats.n_reads) : 0;
|
||||
((double)router_inst->stats.n_binlogs / router_inst->stats.n_reads) : 0;
|
||||
|
||||
json_object_set_new(rval, "average_events_per_packets", json_real(average_packets));
|
||||
|
||||
@ -2424,11 +2430,11 @@ errorReply(MXS_ROUTER *instance,
|
||||
{
|
||||
/* Stopped state, no reconnection */
|
||||
MXS_INFO("%s: Master connection has been closed. State is '%s', "
|
||||
"%snot retrying a new connection to master [%s]:%d",
|
||||
router->service->name,
|
||||
blrm_states[router->master_state], msg,
|
||||
router->service->dbref->server->name,
|
||||
router->service->dbref->server->port);
|
||||
"%snot retrying a new connection to master [%s]:%d",
|
||||
router->service->name,
|
||||
blrm_states[router->master_state], msg,
|
||||
router->service->dbref->server->name,
|
||||
router->service->dbref->server->port);
|
||||
}
|
||||
|
||||
if (errmsg)
|
||||
@ -2853,9 +2859,9 @@ blr_handle_config_item(const char *name, const char *value, ROUTER_INSTANCE *ins
|
||||
if (new_val < 0)
|
||||
{
|
||||
MXS_WARNING("Found invalid 'master_heartbeat_period' value"
|
||||
" for service '%s': %s, ignoring it.",
|
||||
inst->service->name,
|
||||
value);
|
||||
" for service '%s': %s, ignoring it.",
|
||||
inst->service->name,
|
||||
value);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2872,9 +2878,9 @@ blr_handle_config_item(const char *name, const char *value, ROUTER_INSTANCE *ins
|
||||
if (new_val <= 0)
|
||||
{
|
||||
MXS_WARNING("Found invalid 'master_connect_retry' value"
|
||||
" for service '%s': %s, ignoring it.",
|
||||
inst->service->name,
|
||||
value);
|
||||
" for service '%s': %s, ignoring it.",
|
||||
inst->service->name,
|
||||
value);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -3350,15 +3356,15 @@ static bool blr_open_gtid_maps_storage(ROUTER_INSTANCE *inst)
|
||||
int rc = sqlite3_exec(inst->gtid_maps,
|
||||
"BEGIN;"
|
||||
"CREATE TABLE IF NOT EXISTS gtid_maps("
|
||||
"id INTEGER PRIMARY KEY AUTOINCREMENT, "
|
||||
"rep_domain INT, "
|
||||
"server_id INT, "
|
||||
"sequence BIGINT, "
|
||||
"binlog_file VARCHAR(255), "
|
||||
"start_pos BIGINT, "
|
||||
"end_pos BIGINT);"
|
||||
"id INTEGER PRIMARY KEY AUTOINCREMENT, "
|
||||
"rep_domain INT, "
|
||||
"server_id INT, "
|
||||
"sequence BIGINT, "
|
||||
"binlog_file VARCHAR(255), "
|
||||
"start_pos BIGINT, "
|
||||
"end_pos BIGINT);"
|
||||
"CREATE UNIQUE INDEX IF NOT EXISTS gtid_index "
|
||||
"ON gtid_maps(rep_domain, server_id, sequence, binlog_file);"
|
||||
"ON gtid_maps(rep_domain, server_id, sequence, binlog_file);"
|
||||
"COMMIT;",
|
||||
NULL, NULL, &errmsg);
|
||||
if (rc != SQLITE_OK)
|
||||
|
@ -158,10 +158,10 @@ static uint8_t *blr_create_ignorable_event(uint32_t event_size,
|
||||
uint32_t event_pos,
|
||||
bool do_checksum);
|
||||
int blr_write_special_event(ROUTER_INSTANCE *router,
|
||||
uint32_t file_offset,
|
||||
uint32_t hole_size,
|
||||
REP_HEADER *hdr,
|
||||
int type);
|
||||
uint32_t file_offset,
|
||||
uint32_t hole_size,
|
||||
REP_HEADER *hdr,
|
||||
int type);
|
||||
static uint8_t *blr_create_start_encryption_event(ROUTER_INSTANCE *router,
|
||||
uint32_t event_pos,
|
||||
bool do_checksum);
|
||||
@ -481,13 +481,13 @@ blr_file_create(ROUTER_INSTANCE *router, char *orig_file)
|
||||
strcpy(path, router->binlogdir);
|
||||
strcat(path, "/");
|
||||
|
||||
/**
|
||||
* Create file using domain and server_id prefix
|
||||
*/
|
||||
if (router->mariadb10_compat &&
|
||||
router->mariadb10_master_gtid &&
|
||||
router->storage_type == BLR_BINLOG_STORAGE_TREE)
|
||||
{
|
||||
/**
|
||||
* Create file using domain and server_id prefix
|
||||
*/
|
||||
if (router->mariadb10_compat &&
|
||||
router->mariadb10_master_gtid &&
|
||||
router->storage_type == BLR_BINLOG_STORAGE_TREE)
|
||||
{
|
||||
char prefix[BINLOG_FILE_EXTRA_INFO];
|
||||
// Add prefix
|
||||
sprintf(prefix,
|
||||
@ -1585,17 +1585,17 @@ blr_file_next_exists(ROUTER_INSTANCE *router,
|
||||
char bigbuf[PATH_MAX + 1];
|
||||
char select_query[GTID_SQL_BUFFER_SIZE];
|
||||
const char select_tpl[] = "SELECT "
|
||||
"(rep_domain || '/' || server_id || '/' || binlog_file) AS file, "
|
||||
"rep_domain, "
|
||||
"server_id, "
|
||||
"binlog_file "
|
||||
"(rep_domain || '/' || server_id || '/' || binlog_file) AS file, "
|
||||
"rep_domain, "
|
||||
"server_id, "
|
||||
"binlog_file "
|
||||
"FROM gtid_maps "
|
||||
"WHERE id = "
|
||||
"(SELECT MAX(id) "
|
||||
"FROM gtid_maps "
|
||||
"WHERE (binlog_file='%s' AND "
|
||||
"rep_domain = %" PRIu32 " AND "
|
||||
"server_id = %" PRIu32 ")) + 1;";
|
||||
"WHERE id = "
|
||||
"(SELECT MAX(id) "
|
||||
"FROM gtid_maps "
|
||||
"WHERE (binlog_file='%s' AND "
|
||||
"rep_domain = %" PRIu32 " AND "
|
||||
"server_id = %" PRIu32 ")) + 1;";
|
||||
|
||||
MARIADB_GTID_INFO result = {};
|
||||
MARIADB_GTID_ELEMS gtid_elms = {};
|
||||
@ -2603,8 +2603,8 @@ blr_read_events_all_events(ROUTER_INSTANCE *router,
|
||||
n_sequence);
|
||||
|
||||
MXS_DEBUG("GTID List Event has %lu GTIDs, first one is %s",
|
||||
n_gtids,
|
||||
mariadb_gtid);
|
||||
n_gtids,
|
||||
mariadb_gtid);
|
||||
|
||||
if (router->storage_type == BLR_BINLOG_STORAGE_TREE)
|
||||
{
|
||||
@ -3945,27 +3945,27 @@ bool blr_save_mariadb_gtid(ROUTER_INSTANCE *inst)
|
||||
{
|
||||
int sql_ret;
|
||||
static const char insert_tpl[] = "INSERT OR FAIL INTO gtid_maps("
|
||||
"rep_domain, "
|
||||
"server_id, "
|
||||
"sequence, "
|
||||
"binlog_file, "
|
||||
"start_pos, "
|
||||
"end_pos) "
|
||||
"rep_domain, "
|
||||
"server_id, "
|
||||
"sequence, "
|
||||
"binlog_file, "
|
||||
"start_pos, "
|
||||
"end_pos) "
|
||||
"VALUES ( "
|
||||
"%" PRIu32 ", "
|
||||
"%" PRIu32 ", "
|
||||
"%" PRIu64 ", "
|
||||
"\"%s\", "
|
||||
"%" PRIu64 ", "
|
||||
"%" PRIu64 ");";
|
||||
"%" PRIu32 ", "
|
||||
"%" PRIu32 ", "
|
||||
"%" PRIu64 ", "
|
||||
"\"%s\", "
|
||||
"%" PRIu64 ", "
|
||||
"%" PRIu64 ");";
|
||||
|
||||
static const char update_tpl[] = "UPDATE gtid_maps SET "
|
||||
"start_pos = %" PRIu64 ", "
|
||||
"end_pos = %" PRIu64 " "
|
||||
"start_pos = %" PRIu64 ", "
|
||||
"end_pos = %" PRIu64 " "
|
||||
"WHERE rep_domain = %" PRIu32 " AND "
|
||||
"server_id = %" PRIu32 " AND "
|
||||
"sequence = %" PRIu64 " AND "
|
||||
"binlog_file = \"%s\";";
|
||||
"server_id = %" PRIu32 " AND "
|
||||
"sequence = %" PRIu64 " AND "
|
||||
"binlog_file = \"%s\";";
|
||||
char *errmsg;
|
||||
char sql_stmt[GTID_SQL_BUFFER_SIZE];
|
||||
MARIADB_GTID_INFO gtid_info;
|
||||
@ -4132,19 +4132,19 @@ bool blr_fetch_mariadb_gtid(ROUTER_SLAVE *slave,
|
||||
* with old content.
|
||||
*/
|
||||
static const char select_tpl[] = "SELECT "
|
||||
"(rep_domain ||"
|
||||
" '-' || server_id ||"
|
||||
" '-' || sequence) AS gtid, "
|
||||
"binlog_file, "
|
||||
"start_pos, "
|
||||
"end_pos, "
|
||||
"rep_domain, "
|
||||
"server_id, "
|
||||
"sequence "
|
||||
"(rep_domain ||"
|
||||
" '-' || server_id ||"
|
||||
" '-' || sequence) AS gtid, "
|
||||
"binlog_file, "
|
||||
"start_pos, "
|
||||
"end_pos, "
|
||||
"rep_domain, "
|
||||
"server_id, "
|
||||
"sequence "
|
||||
"FROM gtid_maps "
|
||||
"WHERE (rep_domain = %" PRIu32 " AND "
|
||||
"server_id = %" PRIu32 " AND "
|
||||
"sequence = %" PRIu64 ") "
|
||||
"WHERE (rep_domain = %" PRIu32 " AND "
|
||||
"server_id = %" PRIu32 " AND "
|
||||
"sequence = %" PRIu64 ") "
|
||||
"ORDER BY id DESC LIMIT 1;";
|
||||
ss_dassert(gtid != NULL);
|
||||
|
||||
@ -4295,20 +4295,20 @@ bool blr_load_last_mariadb_gtid(ROUTER_INSTANCE *router,
|
||||
char *errmsg = NULL;
|
||||
MARIADB_GTID_ELEMS gtid_elms = {};
|
||||
static const char last_gtid[] = "SELECT "
|
||||
"(rep_domain ||"
|
||||
" '-' || server_id ||"
|
||||
" '-' || sequence) AS gtid, "
|
||||
"binlog_file, "
|
||||
"start_pos, "
|
||||
"end_pos, "
|
||||
"rep_domain, "
|
||||
"server_id, "
|
||||
"sequence "
|
||||
"FROM gtid_maps "
|
||||
"WHERE id = "
|
||||
"(SELECT MAX(id) "
|
||||
"FROM gtid_maps "
|
||||
"WHERE start_pos > 4);";
|
||||
"(rep_domain ||"
|
||||
" '-' || server_id ||"
|
||||
" '-' || sequence) AS gtid, "
|
||||
"binlog_file, "
|
||||
"start_pos, "
|
||||
"end_pos, "
|
||||
"rep_domain, "
|
||||
"server_id, "
|
||||
"sequence "
|
||||
"FROM gtid_maps "
|
||||
"WHERE id = "
|
||||
"(SELECT MAX(id) "
|
||||
"FROM gtid_maps "
|
||||
"WHERE start_pos > 4);";
|
||||
|
||||
/* Find the last GTID */
|
||||
if (sqlite3_exec(router->gtid_maps,
|
||||
@ -4376,18 +4376,18 @@ bool blr_get_last_file(ROUTER_INSTANCE *router,
|
||||
char *errmsg = NULL;
|
||||
MARIADB_GTID_ELEMS gtid_elms = {};
|
||||
static const char last_gtid[] = "SELECT "
|
||||
"(rep_domain ||"
|
||||
" '-' || server_id ||"
|
||||
" '-' || sequence) AS gtid, "
|
||||
"binlog_file, "
|
||||
"start_pos, "
|
||||
"end_pos, "
|
||||
"rep_domain, "
|
||||
"server_id, "
|
||||
"sequence "
|
||||
"FROM gtid_maps "
|
||||
"WHERE id = "
|
||||
"(SELECT MAX(id) FROM gtid_maps);";
|
||||
"(rep_domain ||"
|
||||
" '-' || server_id ||"
|
||||
" '-' || sequence) AS gtid, "
|
||||
"binlog_file, "
|
||||
"start_pos, "
|
||||
"end_pos, "
|
||||
"rep_domain, "
|
||||
"server_id, "
|
||||
"sequence "
|
||||
"FROM gtid_maps "
|
||||
"WHERE id = "
|
||||
"(SELECT MAX(id) FROM gtid_maps);";
|
||||
|
||||
/* Find the the last file */
|
||||
if (sqlite3_exec(router->gtid_maps,
|
||||
@ -4428,10 +4428,10 @@ bool blr_compare_binlogs(ROUTER_INSTANCE *router,
|
||||
}
|
||||
else
|
||||
{
|
||||
// domain_id, server_id and strcmp()
|
||||
return ((router->mariadb10_gtid_domain == info->domain_id) &&
|
||||
(router->orig_masterid == info->server_id) &&
|
||||
strcmp(r_file, s_file) == 0);
|
||||
// domain_id, server_id and strcmp()
|
||||
return ((router->mariadb10_gtid_domain == info->domain_id) &&
|
||||
(router->orig_masterid == info->server_id) &&
|
||||
strcmp(r_file, s_file) == 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4489,7 +4489,7 @@ bool blr_binlog_file_exists(ROUTER_INSTANCE *router,
|
||||
"%" PRIu32 "/%" PRIu32 "/",
|
||||
router->mariadb10_gtid_domain,
|
||||
router->orig_masterid);
|
||||
strcat(path, prefix);
|
||||
strcat(path, prefix);
|
||||
}
|
||||
|
||||
// Set final file name full path
|
||||
|
@ -172,8 +172,8 @@ static void blr_start_master(void* data)
|
||||
else
|
||||
{
|
||||
MXS_NOTICE("%s: Master Connect: binlog current state is [%s]\n",
|
||||
router->service->name,
|
||||
blrm_states[router->master_state]);
|
||||
router->service->name,
|
||||
blrm_states[router->master_state]);
|
||||
}
|
||||
|
||||
/* Return only if state is not BLRM_CONNECTING */
|
||||
@ -3187,10 +3187,10 @@ static void blr_start_master_registration(ROUTER_INSTANCE *router, GWBUF *buf)
|
||||
*/
|
||||
if (router->master_state == BLRM_CHECK_SEMISYNC)
|
||||
{
|
||||
if (blr_register_setsemisync(router, buf))
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (blr_register_setsemisync(router, buf))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
case BLRM_REQUEST_SEMISYNC:
|
||||
/**
|
||||
@ -3284,9 +3284,9 @@ static void blr_register_mariadb_gtid_request(ROUTER_INSTANCE *router,
|
||||
format_gtid_val,
|
||||
router->last_mariadb_gtid);
|
||||
|
||||
MXS_INFO("%s: Requesting GTID (%s) from master server.",
|
||||
router->service->name,
|
||||
router->last_mariadb_gtid);
|
||||
MXS_INFO("%s: Requesting GTID (%s) from master server.",
|
||||
router->service->name,
|
||||
router->last_mariadb_gtid);
|
||||
// Send the request
|
||||
blr_register_send_command(router,
|
||||
set_gtid,
|
||||
@ -3412,27 +3412,27 @@ static void blr_handle_fake_gtid_list(ROUTER_INSTANCE *router,
|
||||
*/
|
||||
if (hdr->next_pos && (hdr->next_pos > binlog_file_eof))
|
||||
{
|
||||
uint64_t hole_size = hdr->next_pos - binlog_file_eof;
|
||||
uint64_t hole_size = hdr->next_pos - binlog_file_eof;
|
||||
|
||||
MXS_INFO("Detected hole while processing"
|
||||
" a Fake GTID_LIST Event: hole size will be %"
|
||||
PRIu64 " bytes",
|
||||
hole_size);
|
||||
MXS_INFO("Detected hole while processing"
|
||||
" a Fake GTID_LIST Event: hole size will be %"
|
||||
PRIu64 " bytes",
|
||||
hole_size);
|
||||
|
||||
/* Set the offet for the write routine */
|
||||
spinlock_acquire(&router->binlog_lock);
|
||||
/* Set the offet for the write routine */
|
||||
spinlock_acquire(&router->binlog_lock);
|
||||
|
||||
router->last_written = binlog_file_eof;
|
||||
router->last_written = binlog_file_eof;
|
||||
|
||||
spinlock_release(&router->binlog_lock);
|
||||
spinlock_release(&router->binlog_lock);
|
||||
|
||||
// Write One Hole
|
||||
// TODO: write small holes
|
||||
blr_write_special_event(router,
|
||||
binlog_file_eof,
|
||||
hole_size,
|
||||
hdr,
|
||||
BLRM_IGNORABLE);
|
||||
// Write One Hole
|
||||
// TODO: write small holes
|
||||
blr_write_special_event(router,
|
||||
binlog_file_eof,
|
||||
hole_size,
|
||||
hdr,
|
||||
BLRM_IGNORABLE);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -100,13 +100,13 @@
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int seq_no; /* Output sequence in result set */
|
||||
char *last_file; /* Last binlog file found in GTID repo */
|
||||
const char *binlogdir; /* Binlog files cache dir */
|
||||
DCB *client; /* Connected client DCB */
|
||||
bool use_tree; /* Binlog structure type */
|
||||
size_t n_files; /* How many files */
|
||||
uint64_t rowid; /* ROWID of router current file*/
|
||||
int seq_no; /* Output sequence in result set */
|
||||
char *last_file; /* Last binlog file found in GTID repo */
|
||||
const char *binlogdir; /* Binlog files cache dir */
|
||||
DCB *client; /* Connected client DCB */
|
||||
bool use_tree; /* Binlog structure type */
|
||||
size_t n_files; /* How many files */
|
||||
uint64_t rowid; /* ROWID of router current file*/
|
||||
} BINARY_LOG_DATA_RESULT;
|
||||
|
||||
extern void poll_fake_write_event(DCB *dcb);
|
||||
@ -486,7 +486,8 @@ blr_skip_leading_sql_comments(const char *sql_query)
|
||||
{
|
||||
const char *p = sql_query;
|
||||
|
||||
while (*p) {
|
||||
while (*p)
|
||||
{
|
||||
if (*p == '/' && p[1] == '*')
|
||||
{
|
||||
++p; // skip '/'
|
||||
@ -709,15 +710,16 @@ blr_slave_query(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, GWBUF *queue)
|
||||
}
|
||||
}
|
||||
else
|
||||
{ /* Handle ADMIN commands */
|
||||
if (blr_handle_admin_stmt(router,
|
||||
slave,
|
||||
word,
|
||||
brkb))
|
||||
{
|
||||
MXS_FREE(query_text);
|
||||
return 1;
|
||||
}
|
||||
{
|
||||
/* Handle ADMIN commands */
|
||||
if (blr_handle_admin_stmt(router,
|
||||
slave,
|
||||
word,
|
||||
brkb))
|
||||
{
|
||||
MXS_FREE(query_text);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* - 3 - Handle unsuppored statements from client */
|
||||
@ -829,7 +831,8 @@ static uint8_t timestamp_def[] =
|
||||
0x00, 0x00, 0x03, 0xfe, 0x00, 0x00, 0x02, 0x00
|
||||
};
|
||||
static uint8_t timestamp_eof[] = { 0x05, 0x00, 0x00, 0x05,
|
||||
0xfe, 0x00, 0x00, 0x02, 0x00 };
|
||||
0xfe, 0x00, 0x00, 0x02, 0x00
|
||||
};
|
||||
|
||||
/**
|
||||
* Send a response to a "SELECT UNIX_TIMESTAMP()" request.
|
||||
@ -1206,8 +1209,8 @@ blr_slave_send_slave_status(ROUTER_INSTANCE *router,
|
||||
|
||||
/* Get the right GTID columns array */
|
||||
const char **gtid_status_columns = router->mariadb10_gtid ?
|
||||
mariadb10_gtid_status_columns :
|
||||
mysql_gtid_status_columns;
|
||||
mariadb10_gtid_status_columns :
|
||||
mysql_gtid_status_columns;
|
||||
/* Increment ncols with the right GTID columns */
|
||||
while (gtid_status_columns[gtid_cols++])
|
||||
{
|
||||
@ -1664,7 +1667,7 @@ blr_slave_send_slave_status(ROUTER_INSTANCE *router,
|
||||
* Send the response to the SQL command "SHOW SLAVE HOSTS"
|
||||
*
|
||||
* @param router The binlog router instance
|
||||
* @param slave The connected slave server
|
||||
* @param slave The connected slave server
|
||||
* @return Non-zero if data was sent
|
||||
*/
|
||||
static int
|
||||
@ -1898,10 +1901,10 @@ blr_slave_binlog_dump(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, GWBUF *queue
|
||||
binlognamelen > 0,
|
||||
requested_pos))
|
||||
{
|
||||
// ERROR
|
||||
slave->state = BLRS_ERRORED;
|
||||
dcb_close(slave->dcb);
|
||||
return 1;
|
||||
// ERROR
|
||||
slave->state = BLRS_ERRORED;
|
||||
dcb_close(slave->dcb);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -2602,7 +2605,7 @@ blr_slave_catchup(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, bool large)
|
||||
* 1) Same name and pos as current router file: aka Up To Date
|
||||
*/
|
||||
if (slave->binlog_pos == router->binlog_position &&
|
||||
blr_is_current_binlog(router, slave))
|
||||
blr_is_current_binlog(router, slave))
|
||||
{
|
||||
spinlock_acquire(&router->binlog_lock);
|
||||
spinlock_acquire(&slave->catch_lock);
|
||||
@ -3241,7 +3244,7 @@ blr_slave_send_disconnected_server(ROUTER_INSTANCE *router,
|
||||
* and close the connection to that server
|
||||
*
|
||||
* @param router The binlog router instance
|
||||
* @param slave The connected slave server
|
||||
* @param slave The connected slave server
|
||||
* @param server_id The slave server_id to disconnect
|
||||
* @return Non-zero if data was sent to the client
|
||||
*/
|
||||
@ -3262,7 +3265,7 @@ blr_slave_disconnect_server(ROUTER_INSTANCE *router,
|
||||
{
|
||||
/* don't examine slaves with state = 0 */
|
||||
if ((sptr->state == BLRS_REGISTERED ||
|
||||
sptr->state == BLRS_DUMPING) &&
|
||||
sptr->state == BLRS_DUMPING) &&
|
||||
sptr->serverid == server_id)
|
||||
{
|
||||
/* server_id found */
|
||||
@ -3752,7 +3755,7 @@ blr_start_slave(ROUTER_INSTANCE* router, ROUTER_SLAVE* slave)
|
||||
/* A new binlog file has been created and opened
|
||||
* by CHANGE MASTER TO: use it
|
||||
*/
|
||||
blr_file_append(router, router->binlog_name);
|
||||
blr_file_append(router, router->binlog_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3810,9 +3813,9 @@ blr_start_slave(ROUTER_INSTANCE* router, ROUTER_SLAVE* slave)
|
||||
*/
|
||||
static void
|
||||
blr_slave_send_error_packet(ROUTER_SLAVE *slave,
|
||||
char *msg,
|
||||
unsigned int err_num,
|
||||
char *status)
|
||||
char *msg,
|
||||
unsigned int err_num,
|
||||
char *status)
|
||||
{
|
||||
GWBUF *pkt;
|
||||
unsigned char *data;
|
||||
@ -3948,7 +3951,7 @@ int blr_handle_change_master(ROUTER_INSTANCE* router,
|
||||
* router->mariadb10_master_gtid is not set
|
||||
*/
|
||||
if (!router->mariadb10_master_gtid &&
|
||||
change_master.use_mariadb10_gtid)
|
||||
change_master.use_mariadb10_gtid)
|
||||
{
|
||||
snprintf(error,
|
||||
BINLOG_ERROR_MSG_LEN,
|
||||
@ -3978,11 +3981,11 @@ int blr_handle_change_master(ROUTER_INSTANCE* router,
|
||||
h_val > BLR_HEARTBEAT_MAX_INTERVAL)
|
||||
{
|
||||
snprintf(error,
|
||||
BINLOG_ERROR_MSG_LEN,
|
||||
"The requested value for the heartbeat period is "
|
||||
"either negative or exceeds the maximum allowed "
|
||||
"(%d seconds).",
|
||||
BLR_HEARTBEAT_MAX_INTERVAL);
|
||||
BINLOG_ERROR_MSG_LEN,
|
||||
"The requested value for the heartbeat period is "
|
||||
"either negative or exceeds the maximum allowed "
|
||||
"(%d seconds).",
|
||||
BLR_HEARTBEAT_MAX_INTERVAL);
|
||||
|
||||
blr_abort_change_master(router,
|
||||
current_master,
|
||||
@ -4053,7 +4056,7 @@ int blr_handle_change_master(ROUTER_INSTANCE* router,
|
||||
!change_master.ssl_key))
|
||||
{
|
||||
if (change_master.ssl_enabled &&
|
||||
atoi(change_master.ssl_enabled))
|
||||
atoi(change_master.ssl_enabled))
|
||||
{
|
||||
snprintf(error,
|
||||
BINLOG_ERROR_MSG_LEN,
|
||||
@ -4083,8 +4086,8 @@ int blr_handle_change_master(ROUTER_INSTANCE* router,
|
||||
* or empty if router->mariadb10_master_gtid is set.
|
||||
*/
|
||||
if (!blr_binlog_change_check(router,
|
||||
change_master,
|
||||
error) ||
|
||||
change_master,
|
||||
error) ||
|
||||
!blr_change_binlog_name(router,
|
||||
change_master.binlog_file,
|
||||
&master_logfile,
|
||||
@ -6299,10 +6302,10 @@ static bool blr_handle_simple_select_stmt(ROUTER_INSTANCE *router,
|
||||
else if (strcasecmp(word, "@@version_comment") == 0)
|
||||
{
|
||||
if (!router->saved_master.selectvercom)
|
||||
/**
|
||||
* This allows mysql client to get in when
|
||||
* @@version_comment is not available
|
||||
*/
|
||||
/**
|
||||
* This allows mysql client to get in when
|
||||
* @@version_comment is not available
|
||||
*/
|
||||
{
|
||||
blr_slave_send_ok(router, slave);
|
||||
return true;
|
||||
@ -6310,8 +6313,8 @@ static bool blr_handle_simple_select_stmt(ROUTER_INSTANCE *router,
|
||||
else
|
||||
{
|
||||
blr_slave_replay(router,
|
||||
slave,
|
||||
router->saved_master.selectvercom);
|
||||
slave,
|
||||
router->saved_master.selectvercom);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -6494,10 +6497,10 @@ static GWBUF *blr_build_fake_rotate_event(ROUTER_SLAVE *slave,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Add 1 byte to paylod for status indicator */
|
||||
/* Add 1 byte to paylod for status indicator */
|
||||
hdr.payload_len = len + 1;
|
||||
|
||||
/* Add sequence and increment it */
|
||||
/* Add sequence and increment it */
|
||||
hdr.seqno = slave->seqno++;
|
||||
|
||||
/* Set status indicator byte to OK */
|
||||
@ -6768,7 +6771,7 @@ static bool blr_slave_gtid_request(ROUTER_INSTANCE *router,
|
||||
blr_get_file_fullpath(slave->binlogfile,
|
||||
router->binlogdir,
|
||||
file_path,
|
||||
t_prefix[0] ? t_prefix: NULL);
|
||||
t_prefix[0] ? t_prefix : NULL);
|
||||
// File size is >=4 read: set pos.
|
||||
if (blr_slave_get_file_size(file_path) >= 4)
|
||||
{
|
||||
@ -6947,7 +6950,7 @@ static bool blr_handle_maxwell_stmt(ROUTER_INSTANCE *router,
|
||||
static const char maxwell_lower_case_tables_query[] = "select @@lower_case_table_names";
|
||||
|
||||
if (strcmp(blr_skip_leading_sql_comments(maxwell_stmt),
|
||||
MYSQL_CONNECTOR_SERVER_VARS_QUERY) == 0)
|
||||
MYSQL_CONNECTOR_SERVER_VARS_QUERY) == 0)
|
||||
{
|
||||
int rc = blr_slave_replay(router,
|
||||
slave,
|
||||
@ -7075,8 +7078,8 @@ static bool blr_handle_show_stmt(ROUTER_INSTANCE *router,
|
||||
errmsg,
|
||||
1198,
|
||||
NULL);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if (strcasecmp(word, "GLOBAL") == 0)
|
||||
{
|
||||
@ -7480,11 +7483,11 @@ static bool blr_handle_set_stmt(ROUTER_INSTANCE *router,
|
||||
* Set the GTID string, it could be an empty
|
||||
* in case of a fresh new setup.
|
||||
*/
|
||||
MXS_FREE(slave->mariadb_gtid);
|
||||
slave->mariadb_gtid = MXS_STRDUP_A(heading);
|
||||
MXS_FREE(slave->mariadb_gtid);
|
||||
slave->mariadb_gtid = MXS_STRDUP_A(heading);
|
||||
|
||||
blr_slave_send_ok(router, slave);
|
||||
return true;
|
||||
blr_slave_send_ok(router, slave);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -7894,7 +7897,7 @@ static bool blr_handle_admin_stmt(ROUTER_INSTANCE *router,
|
||||
|
||||
if (!router->mariadb10_master_gtid &&
|
||||
(strlen(router->prevbinlog) &&
|
||||
strcmp(router->prevbinlog, router->binlog_name) != 0))
|
||||
strcmp(router->prevbinlog, router->binlog_name) != 0))
|
||||
{
|
||||
if (blr_file_new_binlog(router, router->binlog_name))
|
||||
{
|
||||
@ -7985,7 +7988,7 @@ static void blr_slave_skip_empty_files(ROUTER_INSTANCE *router,
|
||||
blr_get_file_fullpath(binlog_file,
|
||||
router->binlogdir,
|
||||
file_path,
|
||||
t_prefix[0] ? t_prefix: NULL);
|
||||
t_prefix[0] ? t_prefix : NULL);
|
||||
|
||||
/**
|
||||
* Get the next file in sequence or next by GTID maps
|
||||
@ -8012,7 +8015,7 @@ static void blr_slave_skip_empty_files(ROUTER_INSTANCE *router,
|
||||
blr_get_file_fullpath(binlog_file,
|
||||
router->binlogdir,
|
||||
file_path,
|
||||
t_prefix[0] ? t_prefix: NULL);
|
||||
t_prefix[0] ? t_prefix : NULL);
|
||||
|
||||
skipped_files = true;
|
||||
}
|
||||
@ -8069,20 +8072,20 @@ blr_show_binary_logs(ROUTER_INSTANCE *router,
|
||||
char current_file[BINLOG_FNAMELEN];
|
||||
uint64_t current_pos = 0;
|
||||
static const char select_query[] = "SELECT binlog_file, "
|
||||
"MAX(end_pos) AS size, "
|
||||
"rep_domain, "
|
||||
"server_id "
|
||||
"MAX(end_pos) AS size, "
|
||||
"rep_domain, "
|
||||
"server_id "
|
||||
"FROM gtid_maps "
|
||||
"GROUP BY binlog_file "
|
||||
"GROUP BY binlog_file "
|
||||
"ORDER BY id ASC;";
|
||||
static const char select_query_full[] = "SELECT binlog_file, "
|
||||
"MAX(end_pos) AS size, "
|
||||
"rep_domain, "
|
||||
"server_id "
|
||||
"MAX(end_pos) AS size, "
|
||||
"rep_domain, "
|
||||
"server_id "
|
||||
"FROM gtid_maps "
|
||||
"GROUP BY rep_domain, "
|
||||
"server_id, "
|
||||
"binlog_file "
|
||||
"GROUP BY rep_domain, "
|
||||
"server_id, "
|
||||
"binlog_file "
|
||||
"ORDER BY id ASC;";
|
||||
int seqno;
|
||||
char *errmsg = NULL;
|
||||
@ -8186,8 +8189,8 @@ blr_show_binary_logs(ROUTER_INSTANCE *router,
|
||||
char t_prefix[BINLOG_FILE_EXTRA_INFO];
|
||||
sprintf(t_prefix,
|
||||
"%" PRIu32 "/%" PRIu32 "/",
|
||||
router->mariadb10_gtid_domain,
|
||||
router->orig_masterid);
|
||||
router->mariadb10_gtid_domain,
|
||||
router->orig_masterid);
|
||||
|
||||
// Add prefix before filename
|
||||
sprintf(last_filename,
|
||||
@ -8287,8 +8290,8 @@ static int binary_logs_select_cb(void *data,
|
||||
GWBUF *pkt;
|
||||
char file_path[PATH_MAX + 1];
|
||||
char filename[1 +
|
||||
strlen(values[0]) +
|
||||
BINLOG_FILE_EXTRA_INFO];
|
||||
strlen(values[0]) +
|
||||
BINLOG_FILE_EXTRA_INFO];
|
||||
char t_prefix[BINLOG_FILE_EXTRA_INFO] = "";
|
||||
|
||||
sprintf(t_prefix,
|
||||
@ -8412,7 +8415,7 @@ static int blr_slave_send_id_ro(ROUTER_INSTANCE *router,
|
||||
"0", // o = OFF
|
||||
seqno++)) != NULL)
|
||||
{
|
||||
/* Write packet to client */
|
||||
/* Write packet to client */
|
||||
MXS_SESSION_ROUTE_REPLY(slave->dcb->session, pkt);
|
||||
}
|
||||
|
||||
@ -8438,15 +8441,15 @@ static bool blr_handle_complex_select(ROUTER_INSTANCE *router,
|
||||
const char *coln)
|
||||
{
|
||||
/* Strip leading spaces */
|
||||
while(isspace(*coln))
|
||||
while (isspace(*coln))
|
||||
{
|
||||
coln++;
|
||||
}
|
||||
|
||||
if ((strcasecmp(col1, "@@server_id") == 0 ||
|
||||
strcasecmp(col1, "@@global.server_id") == 0) &&
|
||||
(strcasecmp(coln, "@@read_only") == 0 ||
|
||||
strcasecmp(coln, "@@global.read_only") == 0))
|
||||
strcasecmp(col1, "@@global.server_id") == 0) &&
|
||||
(strcasecmp(coln, "@@read_only") == 0 ||
|
||||
strcasecmp(coln, "@@global.read_only") == 0))
|
||||
{
|
||||
blr_slave_send_id_ro(router, slave);
|
||||
return true;
|
||||
@ -8567,7 +8570,7 @@ static const char *blr_purge_getfile(char *purge_command)
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
// Check for TO 'file'
|
||||
// Check for TO 'file'
|
||||
{
|
||||
if (strcasecmp(word, "TO") != 0)
|
||||
{
|
||||
@ -8620,24 +8623,24 @@ blr_purge_binary_logs(ROUTER_INSTANCE *router,
|
||||
size_t n_delete = 0;
|
||||
// Select first ROWID of user specifed file
|
||||
static const char find_file_tpl[] = "SELECT MIN(id) AS min_id, "
|
||||
"(rep_domain || '/' || "
|
||||
"server_id || '/' || "
|
||||
"binlog_file) AS file "
|
||||
"(rep_domain || '/' || "
|
||||
"server_id || '/' || "
|
||||
"binlog_file) AS file "
|
||||
"FROM gtid_maps "
|
||||
"WHERE binlog_file = '%s' "
|
||||
"WHERE binlog_file = '%s' "
|
||||
"GROUP BY binlog_file "
|
||||
"ORDER BY id ASC;";
|
||||
// SELECT files with ROWID < given one and DELETE
|
||||
static const char delete_list_tpl[] = "SELECT binlog_file, "
|
||||
"(rep_domain || '/' || "
|
||||
"server_id || '/' || "
|
||||
"binlog_file) AS file "
|
||||
"(rep_domain || '/' || "
|
||||
"server_id || '/' || "
|
||||
"binlog_file) AS file "
|
||||
"FROM gtid_maps "
|
||||
"WHERE id < %" PRIu64 " "
|
||||
"WHERE id < %" PRIu64 " "
|
||||
"GROUP BY file "
|
||||
"ORDER BY id ASC; "
|
||||
"DELETE FROM gtid_maps "
|
||||
"WHERE id < %" PRIu64 ";";
|
||||
"WHERE id < %" PRIu64 ";";
|
||||
static char sql_stmt[GTID_SQL_BUFFER_SIZE];
|
||||
BINARY_LOG_DATA_RESULT result;
|
||||
static const char *selected_file;
|
||||
@ -8696,10 +8699,10 @@ blr_purge_binary_logs(ROUTER_INSTANCE *router,
|
||||
|
||||
/* Purge all files with ROWID < result.rowid */
|
||||
if (sqlite3_exec(router->gtid_maps,
|
||||
sql_stmt,
|
||||
binary_logs_purge_cb,
|
||||
&result,
|
||||
&errmsg) != SQLITE_OK)
|
||||
sql_stmt,
|
||||
binary_logs_purge_cb,
|
||||
&result,
|
||||
&errmsg) != SQLITE_OK)
|
||||
{
|
||||
MXS_ERROR("Failed to select list of files to purge"
|
||||
"from GTID maps DB: %s, select [%s]",
|
||||
@ -8830,13 +8833,13 @@ static bool blr_check_connecting_slave(const ROUTER_INSTANCE *router,
|
||||
int err_code = BINLOG_FATAL_ERROR_READING;
|
||||
char *msg_detail = "";
|
||||
|
||||
switch(check)
|
||||
switch (check)
|
||||
{
|
||||
case BLR_SLAVE_CONNECTING: // (1)
|
||||
if (router->master_state == BLRM_UNCONFIGURED)
|
||||
{
|
||||
err_msg = "Binlog router is not yet configured"
|
||||
" for replication.";
|
||||
" for replication.";
|
||||
rv = false;
|
||||
}
|
||||
break;
|
||||
@ -8979,10 +8982,10 @@ static bool blr_binlog_change_check(const ROUTER_INSTANCE *router,
|
||||
}
|
||||
}
|
||||
else
|
||||
/**
|
||||
* If binlog file is set in CHANGE MASTER TO
|
||||
* and MASTER_USE_GTID option is on, then return an error.
|
||||
*/
|
||||
/**
|
||||
* If binlog file is set in CHANGE MASTER TO
|
||||
* and MASTER_USE_GTID option is on, then return an error.
|
||||
*/
|
||||
{
|
||||
/**
|
||||
* Check first MASTER_USE_GTID option:
|
||||
@ -9048,16 +9051,16 @@ static bool blr_change_binlog_name(ROUTER_INSTANCE *router,
|
||||
* - current router file
|
||||
* - empty if router->mariadb10_master_gtid is set.
|
||||
*/
|
||||
*new_logfile = blr_set_master_logfile(router,
|
||||
binlog_file,
|
||||
error);
|
||||
if (*new_logfile == NULL)
|
||||
{
|
||||
if (!router->mariadb10_master_gtid ||
|
||||
strlen(binlog_file) > 1)
|
||||
{
|
||||
/* Binlog name can not be changed */
|
||||
ret = false;
|
||||
*new_logfile = blr_set_master_logfile(router,
|
||||
binlog_file,
|
||||
error);
|
||||
if (*new_logfile == NULL)
|
||||
{
|
||||
if (!router->mariadb10_master_gtid ||
|
||||
strlen(binlog_file) > 1)
|
||||
{
|
||||
/* Binlog name can not be changed */
|
||||
ret = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -9065,9 +9068,9 @@ static bool blr_change_binlog_name(ROUTER_INSTANCE *router,
|
||||
// Blank the error message
|
||||
error[0] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -9116,25 +9119,25 @@ static bool blr_apply_changes(ROUTER_INSTANCE *router,
|
||||
/* MariaDB 10 GTID request */
|
||||
if (router->mariadb10_master_gtid)
|
||||
{
|
||||
if (change_master.use_mariadb10_gtid)
|
||||
{
|
||||
if (change_master.use_mariadb10_gtid)
|
||||
{
|
||||
/* MASTER_USE_GTID=Slave_pos is set */
|
||||
MXS_INFO("%s: MASTER_USE_GTID is [%s]",
|
||||
router->service->name,
|
||||
change_master.use_mariadb10_gtid);
|
||||
}
|
||||
}
|
||||
|
||||
/* Always log the current GTID value with CHANGE_MASTER TO */
|
||||
MXS_INFO("%s: CHANGE MASTER TO, current GTID value is [%s]",
|
||||
router->service->name,
|
||||
router->last_mariadb_gtid);
|
||||
/* Always log the current GTID value with CHANGE_MASTER TO */
|
||||
MXS_INFO("%s: CHANGE MASTER TO, current GTID value is [%s]",
|
||||
router->service->name,
|
||||
router->last_mariadb_gtid);
|
||||
|
||||
/* Always set empty filename at pos 4 with CHANGE_MASTER TO */
|
||||
strcpy(router->binlog_name, "");
|
||||
/* Always set empty filename at pos 4 with CHANGE_MASTER TO */
|
||||
strcpy(router->binlog_name, "");
|
||||
|
||||
router->current_pos = 4;
|
||||
router->binlog_position = 4;
|
||||
router->current_safe_event = 4;
|
||||
router->current_pos = 4;
|
||||
router->binlog_position = 4;
|
||||
router->current_safe_event = 4;
|
||||
}
|
||||
/* The new filename is not the current one */
|
||||
else if (strcmp(new_logfile, router->binlog_name) != 0 &&
|
||||
|
@ -262,7 +262,8 @@ printUsage(const char *progname)
|
||||
printVersion(progname);
|
||||
|
||||
printf("The MaxScale binlog check utility.\n\n");
|
||||
printf("Usage: %s [-f] [-M] [-d] [-V] [-H] [-K file] [-A algo] [-R pos] [-T pos] [<binlog file>]\n\n", progname);
|
||||
printf("Usage: %s [-f] [-M] [-d] [-V] [-H] [-K file] [-A algo] [-R pos] [-T pos] [<binlog file>]\n\n",
|
||||
progname);
|
||||
printf(" -f|--fix Fix binlog file, require write permissions (truncate)\n");
|
||||
printf(" -d|--debug Print debug messages\n");
|
||||
printf(" -M|--mariadb10 MariaDB 10 binlog compatibility\n");
|
||||
|
@ -773,8 +773,8 @@ int main(int argc, char **argv)
|
||||
inst->current_pos = 328;
|
||||
strcpy(inst->fileroot, "file");
|
||||
strcpy(query,
|
||||
"CHANGE MASTER TO MASTER_LOG_POS=1991, MASTER_USE_GTID=Slave_pos, "
|
||||
"MASTER_LOG_FILE=''");
|
||||
"CHANGE MASTER TO MASTER_LOG_POS=1991, MASTER_USE_GTID=Slave_pos, "
|
||||
"MASTER_LOG_FILE=''");
|
||||
|
||||
rc = blr_test_handle_change_master(inst, query, error_string);
|
||||
|
||||
@ -791,7 +791,7 @@ int main(int argc, char **argv)
|
||||
printf("Test %d PASSED, GTID set MASTER_USE_GTID=Slave_pos "
|
||||
"for [%s]: %s\n",
|
||||
tests,
|
||||
query,error_string);
|
||||
query, error_string);
|
||||
}
|
||||
|
||||
tests++;
|
||||
@ -799,8 +799,10 @@ int main(int argc, char **argv)
|
||||
/**
|
||||
* Verify SQL query initial comment skipping function works on a real use case.
|
||||
*/
|
||||
const char *mysql_connector_j_actual = blr_skip_leading_sql_comments("/* mysql-connector-java-5.1.39 ( Revision: 3289a357af6d09ecc1a10fd3c26e95183e5790ad ) */SELECT @@session.auto_increment_increment AS auto_increment_increment, @@character_set_client AS character_set_client, @@character_set_connection AS character_set_connection, @@character_set_results AS character_set_results, @@character_set_server AS character_set_server, @@init_connect AS init_connect, @@interactive_timeout AS interactive_timeout, @@license AS license, @@lower_case_table_names AS lower_case_table_names, @@max_allowed_packet AS max_allowed_packet, @@net_buffer_length AS net_buffer_length, @@net_write_timeout AS net_write_timeout, @@query_cache_size AS query_cache_size, @@query_cache_type AS query_cache_type, @@sql_mode AS sql_mode, @@system_time_zone AS system_time_zone, @@time_zone AS time_zone, @@tx_isolation AS tx_isolation, @@wait_timeout AS wait_timeout");
|
||||
const char *mysql_connector_j_expected = "SELECT @@session.auto_increment_increment AS auto_increment_increment, @@character_set_client AS character_set_client, @@character_set_connection AS character_set_connection, @@character_set_results AS character_set_results, @@character_set_server AS character_set_server, @@init_connect AS init_connect, @@interactive_timeout AS interactive_timeout, @@license AS license, @@lower_case_table_names AS lower_case_table_names, @@max_allowed_packet AS max_allowed_packet, @@net_buffer_length AS net_buffer_length, @@net_write_timeout AS net_write_timeout, @@query_cache_size AS query_cache_size, @@query_cache_type AS query_cache_type, @@sql_mode AS sql_mode, @@system_time_zone AS system_time_zone, @@time_zone AS time_zone, @@tx_isolation AS tx_isolation, @@wait_timeout AS wait_timeout";
|
||||
const char *mysql_connector_j_actual =
|
||||
blr_skip_leading_sql_comments("/* mysql-connector-java-5.1.39 ( Revision: 3289a357af6d09ecc1a10fd3c26e95183e5790ad ) */SELECT @@session.auto_increment_increment AS auto_increment_increment, @@character_set_client AS character_set_client, @@character_set_connection AS character_set_connection, @@character_set_results AS character_set_results, @@character_set_server AS character_set_server, @@init_connect AS init_connect, @@interactive_timeout AS interactive_timeout, @@license AS license, @@lower_case_table_names AS lower_case_table_names, @@max_allowed_packet AS max_allowed_packet, @@net_buffer_length AS net_buffer_length, @@net_write_timeout AS net_write_timeout, @@query_cache_size AS query_cache_size, @@query_cache_type AS query_cache_type, @@sql_mode AS sql_mode, @@system_time_zone AS system_time_zone, @@time_zone AS time_zone, @@tx_isolation AS tx_isolation, @@wait_timeout AS wait_timeout");
|
||||
const char *mysql_connector_j_expected =
|
||||
"SELECT @@session.auto_increment_increment AS auto_increment_increment, @@character_set_client AS character_set_client, @@character_set_connection AS character_set_connection, @@character_set_results AS character_set_results, @@character_set_server AS character_set_server, @@init_connect AS init_connect, @@interactive_timeout AS interactive_timeout, @@license AS license, @@lower_case_table_names AS lower_case_table_names, @@max_allowed_packet AS max_allowed_packet, @@net_buffer_length AS net_buffer_length, @@net_write_timeout AS net_write_timeout, @@query_cache_size AS query_cache_size, @@query_cache_type AS query_cache_type, @@sql_mode AS sql_mode, @@system_time_zone AS system_time_zone, @@time_zone AS time_zone, @@tx_isolation AS tx_isolation, @@wait_timeout AS wait_timeout";
|
||||
if (strcmp(mysql_connector_j_actual, mysql_connector_j_expected) == 0)
|
||||
{
|
||||
printf("Test %d PASSED\n", tests);
|
||||
|
@ -303,13 +303,9 @@ bool listfuncs_cb(const MODULECMD *cmd, void *data)
|
||||
for (int i = 0; i < cmd->arg_count_max; i++)
|
||||
{
|
||||
modulecmd_arg_type_t *type = &cmd->arg_types[i];
|
||||
|
||||
if (MODULECMD_GET_TYPE(type) != MODULECMD_ARG_OUTPUT)
|
||||
{
|
||||
dcb_printf(dcb, "%s%s",
|
||||
modulecmd_argtype_to_str(&cmd->arg_types[i]),
|
||||
i < cmd->arg_count_max - 1 ? " " : "");
|
||||
}
|
||||
dcb_printf(dcb, "%s%s",
|
||||
modulecmd_argtype_to_str(&cmd->arg_types[i]),
|
||||
i < cmd->arg_count_max - 1 ? " " : "");
|
||||
}
|
||||
|
||||
dcb_printf(dcb, "\n\n");
|
||||
@ -317,13 +313,9 @@ bool listfuncs_cb(const MODULECMD *cmd, void *data)
|
||||
for (int i = 0; i < cmd->arg_count_max; i++)
|
||||
{
|
||||
modulecmd_arg_type_t *type = &cmd->arg_types[i];
|
||||
|
||||
if (MODULECMD_GET_TYPE(type) != MODULECMD_ARG_OUTPUT)
|
||||
{
|
||||
dcb_printf(dcb, " %s - %s\n",
|
||||
modulecmd_argtype_to_str(&cmd->arg_types[i]),
|
||||
cmd->arg_types[i].description);
|
||||
}
|
||||
dcb_printf(dcb, " %s - %s\n",
|
||||
modulecmd_argtype_to_str(&cmd->arg_types[i]),
|
||||
cmd->arg_types[i].description);
|
||||
}
|
||||
|
||||
dcb_printf(dcb, "\n");
|
||||
@ -931,7 +923,7 @@ struct subcommand addoptions[] =
|
||||
{
|
||||
{
|
||||
"user", 2, 2, inet_add_admin_user,
|
||||
"Add an administrative account for using maxadmin over the network",
|
||||
"Add an administrative account for using maxadmin over the network",
|
||||
"Usage: add user USER PASSWORD\n"
|
||||
"\n"
|
||||
"Parameters:\n"
|
||||
@ -1664,12 +1656,6 @@ struct subcommand alteroptions[] =
|
||||
}
|
||||
};
|
||||
|
||||
static inline bool requires_output_dcb(const MODULECMD *cmd)
|
||||
{
|
||||
modulecmd_arg_type_t *type = &cmd->arg_types[0];
|
||||
return cmd->arg_count_max > 0 && MODULECMD_GET_TYPE(type) == MODULECMD_ARG_OUTPUT;
|
||||
}
|
||||
|
||||
static void callModuleCommand(DCB *dcb, char *domain, char *id, char *v3,
|
||||
char *v4, char *v5, char *v6, char *v7, char *v8, char *v9,
|
||||
char *v10, char *v11, char *v12)
|
||||
@ -1687,18 +1673,6 @@ static void callModuleCommand(DCB *dcb, char *domain, char *id, char *v3,
|
||||
|
||||
if (cmd)
|
||||
{
|
||||
if (requires_output_dcb(cmd))
|
||||
{
|
||||
/** The command requires a DCB for output, add the client DCB
|
||||
* as the first argument */
|
||||
for (int i = valuelen - 1; i > 0; i--)
|
||||
{
|
||||
values[i] = values[i - 1];
|
||||
}
|
||||
values[0] = dcb;
|
||||
numargs += numargs + 1 < valuelen - 1 ? 1 : 0;
|
||||
}
|
||||
|
||||
MODULECMD_ARG *arg = modulecmd_arg_parse(cmd, numargs, values);
|
||||
|
||||
if (arg)
|
||||
@ -1707,11 +1681,15 @@ static void callModuleCommand(DCB *dcb, char *domain, char *id, char *v3,
|
||||
|
||||
if (!modulecmd_call_command(cmd, arg, &output))
|
||||
{
|
||||
dcb_printf(dcb, "Error: %s\n", modulecmd_get_error());
|
||||
const char* err = modulecmd_get_error();
|
||||
dcb_printf(dcb, "Error: %s\n", *err ? err :
|
||||
"Call to module command failed, see log file for more details");
|
||||
}
|
||||
else if (output)
|
||||
{
|
||||
dcb_printf(dcb, "%s\n", json_dumps(output, JSON_INDENT(4)));
|
||||
char* js = json_dumps(output, JSON_INDENT(4));
|
||||
dcb_printf(dcb, "%s\n", js);
|
||||
MXS_FREE(js);
|
||||
}
|
||||
|
||||
json_decref(output);
|
||||
|
Reference in New Issue
Block a user