MXS-1266: blr_slave_gtid_request() the file in slave registration request is checked whether it exists or not
MXS-1266: blr_slave_gtid_request() the file in slave registration request is checked whether it exists or not and GTID file info could e set instead. Also addded: blr_handle_simple_select_stmt(): only mariadb10_gtid_domain is checked for SELECT @@GLOBAL.gtid_domain_id slave request blr_start_master_registration(): only router->mariadb10_compat is checked before sending SELECT @@GLOBAL.gtid_domain_id to master blr_file_create calls mxs_mkdir_all()
This commit is contained in:
@ -516,55 +516,25 @@ blr_file_create(ROUTER_INSTANCE *router, char *file)
|
|||||||
router->storage_type == BLR_BINLOG_STORAGE_TREE)
|
router->storage_type == BLR_BINLOG_STORAGE_TREE)
|
||||||
{
|
{
|
||||||
char prefix[BINLOG_FILE_EXTRA_INFO];
|
char prefix[BINLOG_FILE_EXTRA_INFO];
|
||||||
|
// Add prefix
|
||||||
sprintf(prefix,
|
sprintf(prefix,
|
||||||
"%" PRIu32 "/",
|
"%" PRIu32 "/%" PRIu32 "/",
|
||||||
router->mariadb10_gtid_domain);
|
router->mariadb10_gtid_domain,
|
||||||
|
|
||||||
// Add domain_id
|
|
||||||
strcat(path, prefix);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* - 1 - Check and create $domain_id dir
|
|
||||||
*/
|
|
||||||
if (access(path, R_OK) == -1)
|
|
||||||
{
|
|
||||||
int mkdir_rval;
|
|
||||||
mkdir_rval = mkdir(path, 0700);
|
|
||||||
if (mkdir_rval == -1)
|
|
||||||
{
|
|
||||||
MXS_ERROR("Service %s, Failed to create binlog"
|
|
||||||
" directory tree (domain_id) '%s': [%d] %s",
|
|
||||||
router->service->name,
|
|
||||||
path,
|
|
||||||
errno,
|
|
||||||
mxs_strerror(errno));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add server_id
|
|
||||||
sprintf(prefix,
|
|
||||||
"%" PRIu32 "/",
|
|
||||||
router->orig_masterid);
|
router->orig_masterid);
|
||||||
strcat(path, prefix);
|
strcat(path, prefix);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* - 2 - Check and create $server_id dir under $domain_id
|
* Check and create $domain_id/$server_id dir
|
||||||
*/
|
*/
|
||||||
if (access(path, R_OK) == -1)
|
if (!mxs_mkdir_all(path, 0700))
|
||||||
{
|
{
|
||||||
int mkdir_rval;
|
MXS_ERROR("Service %s, Failed to create binlog"
|
||||||
mkdir_rval = mkdir(path, 0700);
|
" directory tree '%s': [%d] %s",
|
||||||
if (mkdir_rval == -1)
|
router->service->name,
|
||||||
{
|
path,
|
||||||
MXS_ERROR("Service %s, Failed to create binlog"
|
errno,
|
||||||
" directory tree (domain_id/server_id) '%s': [%d] %s",
|
mxs_strerror(errno));
|
||||||
router->service->name,
|
return 0;
|
||||||
path,
|
|
||||||
errno,
|
|
||||||
mxs_strerror(errno));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2821,18 +2821,41 @@ static void blr_start_master_registration(ROUTER_INSTANCE *router, GWBUF *buf)
|
|||||||
buf);
|
buf);
|
||||||
// Next state is BLRM_MARIADB10_GTID_DOMAIN or BLRM_LATIN1
|
// Next state is BLRM_MARIADB10_GTID_DOMAIN or BLRM_LATIN1
|
||||||
{
|
{
|
||||||
unsigned int state = router->mariadb10_master_gtid ?
|
/**
|
||||||
|
* Always request "gtid_domain_id" to Master server
|
||||||
|
* if MariaDB 10 Compatibilty is On
|
||||||
|
*/
|
||||||
|
unsigned int state = router->mariadb10_compat ?
|
||||||
BLRM_MARIADB10_GTID_DOMAIN :
|
BLRM_MARIADB10_GTID_DOMAIN :
|
||||||
BLRM_LATIN1;
|
BLRM_LATIN1;
|
||||||
const char *command = router->mariadb10_master_gtid ?
|
const char *command = router->mariadb10_compat ?
|
||||||
"SELECT @@GLOBAL.gtid_domain_id" :
|
"SELECT @@GLOBAL.gtid_domain_id" :
|
||||||
"SET NAMES latin1";
|
"SET NAMES latin1";
|
||||||
blr_register_send_command(router, command, state);
|
blr_register_send_command(router, command, state);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BLRM_MARIADB10_GTID_DOMAIN: // MariaDB10 Only
|
case BLRM_MARIADB10_GTID_DOMAIN: // MariaDB10 Only
|
||||||
// Next state is BLRM_MARIADB10_REQUEST_GTID
|
{
|
||||||
blr_register_mariadb_gtid_request(router, buf);
|
// Extract GTID domain
|
||||||
|
char *val = blr_extract_column(buf, 1);
|
||||||
|
// Store the Master GTID domain
|
||||||
|
router->mariadb10_gtid_domain = atol(val);
|
||||||
|
MXS_FREE(val);
|
||||||
|
// Don't save the server response
|
||||||
|
gwbuf_free(buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Next state is BLRM_MARIADB10_REQUEST_GTID or BLRM_LATIN1
|
||||||
|
if (!router->mariadb10_master_gtid)
|
||||||
|
{
|
||||||
|
blr_register_send_command(router,
|
||||||
|
"SET NAMES latin1",
|
||||||
|
BLRM_LATIN1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
blr_register_mariadb_gtid_request(router, buf);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case BLRM_MARIADB10_REQUEST_GTID: // MariaDB10 Only
|
case BLRM_MARIADB10_REQUEST_GTID: // MariaDB10 Only
|
||||||
// Don't save GTID request
|
// Don't save GTID request
|
||||||
|
@ -6521,13 +6521,13 @@ static bool blr_handle_simple_select_stmt(ROUTER_INSTANCE *router,
|
|||||||
{
|
{
|
||||||
/* If not mariadb10 mastergtid an error message will be returned */
|
/* If not mariadb10 mastergtid an error message will be returned */
|
||||||
if (slave->mariadb10_compat &&
|
if (slave->mariadb10_compat &&
|
||||||
router->mariadb10_master_gtid)
|
router->mariadb10_gtid)
|
||||||
{
|
{
|
||||||
char heading[40];
|
char heading[40];
|
||||||
char gtid_domain[40];
|
char gtid_domain[40];
|
||||||
sprintf(gtid_domain,
|
sprintf(gtid_domain,
|
||||||
"%lu",
|
"%" PRIu32 "",
|
||||||
(unsigned long)router->mariadb10_gtid_domain);
|
router->mariadb10_gtid_domain);
|
||||||
strcpy(heading, word);
|
strcpy(heading, word);
|
||||||
|
|
||||||
blr_slave_send_var_value(router,
|
blr_slave_send_var_value(router,
|
||||||
@ -6842,14 +6842,43 @@ static bool blr_slave_gtid_request(ROUTER_INSTANCE *router,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The requested binlog file is not the GTID info file.
|
* The requested binlog file is not the GTID info file.
|
||||||
* The binlog file could be different due to:
|
* The binlog file could be different due to:
|
||||||
* a rotate event or other non GTID events written
|
* a rotate event or other non GTID events written
|
||||||
* after that GTID.
|
* after that GTID.
|
||||||
* Events are sent from requested file@pos
|
* If file exists events will be sent from requested file@pos
|
||||||
*/
|
* otherwise file & pos = GTID info file.
|
||||||
slave->binlog_pos = req_pos;
|
*/
|
||||||
|
|
||||||
|
// Add tree prefix
|
||||||
|
char t_prefix[BINLOG_FILE_EXTRA_INFO] = "";
|
||||||
|
char file_path[PATH_MAX + 1] = "";
|
||||||
|
if (router->storage_type == BLR_BINLOG_STORAGE_TREE)
|
||||||
|
{
|
||||||
|
sprintf(t_prefix,
|
||||||
|
"%" PRIu32 "/%" PRIu32 "/",
|
||||||
|
f_gtid.gtid_elms.domain_id,
|
||||||
|
f_gtid.gtid_elms.server_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get binlog filename full-path
|
||||||
|
blr_get_file_fullpath(slave->binlogfile,
|
||||||
|
router->binlogdir,
|
||||||
|
file_path,
|
||||||
|
t_prefix[0] ? t_prefix: NULL);
|
||||||
|
if (blr_slave_get_file_size(file_path) != 0)
|
||||||
|
{
|
||||||
|
slave->binlog_pos = req_pos;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Set binlog file to the GTID one */
|
||||||
|
strcpy(slave->binlogfile, f_gtid.file);
|
||||||
|
|
||||||
|
/* Set pos to GTID next event pos */
|
||||||
|
slave->binlog_pos = f_gtid.end;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set GTID details in f_info*/
|
/* Set GTID details in f_info*/
|
||||||
@ -8020,14 +8049,14 @@ static void blr_slave_skip_empty_files(ROUTER_INSTANCE *router,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the next file in sequence or next by GTID maps
|
* Get the next file in sequence or next by GTID maps
|
||||||
* if current file has 4 bytes size.
|
* if current file has 4 bytes size or it doesn't exist at all.
|
||||||
* Stop if the new file is the current binlog file.
|
* Stop if the new file is the current binlog file.
|
||||||
*/
|
*/
|
||||||
while (!blr_compare_binlogs(router,
|
while (!blr_compare_binlogs(router,
|
||||||
f_tree,
|
f_tree,
|
||||||
router_curr_file,
|
router_curr_file,
|
||||||
binlog_file) &&
|
binlog_file) &&
|
||||||
blr_slave_get_file_size(file_path) == 4 &&
|
blr_slave_get_file_size(file_path) <= 4 &&
|
||||||
blr_file_next_exists(router, slave, next_file))
|
blr_file_next_exists(router, slave, next_file))
|
||||||
{
|
{
|
||||||
// Log skipped file
|
// Log skipped file
|
||||||
|
Reference in New Issue
Block a user