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,49 +516,20 @@ blr_file_create(ROUTER_INSTANCE *router, char *file)
|
||||
router->storage_type == BLR_BINLOG_STORAGE_TREE)
|
||||
{
|
||||
char prefix[BINLOG_FILE_EXTRA_INFO];
|
||||
// Add prefix
|
||||
sprintf(prefix,
|
||||
"%" PRIu32 "/",
|
||||
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 "/",
|
||||
"%" PRIu32 "/%" PRIu32 "/",
|
||||
router->mariadb10_gtid_domain,
|
||||
router->orig_masterid);
|
||||
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)
|
||||
{
|
||||
int mkdir_rval;
|
||||
mkdir_rval = mkdir(path, 0700);
|
||||
if (mkdir_rval == -1)
|
||||
if (!mxs_mkdir_all(path, 0700))
|
||||
{
|
||||
MXS_ERROR("Service %s, Failed to create binlog"
|
||||
" directory tree (domain_id/server_id) '%s': [%d] %s",
|
||||
" directory tree '%s': [%d] %s",
|
||||
router->service->name,
|
||||
path,
|
||||
errno,
|
||||
@ -566,7 +537,6 @@ blr_file_create(ROUTER_INSTANCE *router, char *file)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set final file name full path
|
||||
strcat(path, file);
|
||||
|
@ -2821,18 +2821,41 @@ 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->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_LATIN1;
|
||||
const char *command = router->mariadb10_master_gtid ?
|
||||
const char *command = router->mariadb10_compat ?
|
||||
"SELECT @@GLOBAL.gtid_domain_id" :
|
||||
"SET NAMES latin1";
|
||||
blr_register_send_command(router, command, state);
|
||||
}
|
||||
break;
|
||||
case BLRM_MARIADB10_GTID_DOMAIN: // MariaDB10 Only
|
||||
// Next state is BLRM_MARIADB10_REQUEST_GTID
|
||||
{
|
||||
// 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;
|
||||
case BLRM_MARIADB10_REQUEST_GTID: // MariaDB10 Only
|
||||
// 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 (slave->mariadb10_compat &&
|
||||
router->mariadb10_master_gtid)
|
||||
router->mariadb10_gtid)
|
||||
{
|
||||
char heading[40];
|
||||
char gtid_domain[40];
|
||||
sprintf(gtid_domain,
|
||||
"%lu",
|
||||
(unsigned long)router->mariadb10_gtid_domain);
|
||||
"%" PRIu32 "",
|
||||
router->mariadb10_gtid_domain);
|
||||
strcpy(heading, word);
|
||||
|
||||
blr_slave_send_var_value(router,
|
||||
@ -6847,10 +6847,39 @@ static bool blr_slave_gtid_request(ROUTER_INSTANCE *router,
|
||||
* The binlog file could be different due to:
|
||||
* a rotate event or other non GTID events written
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// 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*/
|
||||
memcpy(&slave->f_info, &f_gtid, sizeof(MARIADB_GTID_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
|
||||
* 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.
|
||||
*/
|
||||
while (!blr_compare_binlogs(router,
|
||||
f_tree,
|
||||
router_curr_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))
|
||||
{
|
||||
// Log skipped file
|
||||
|
Reference in New Issue
Block a user