MXS-2011 Store current CHANGE MASTER config in router
This commit is contained in:
@ -788,6 +788,7 @@ struct ROUTER_INSTANCE: public MXS_ROUTER
|
|||||||
enum binlog_storage_type storage_type;/*< Enables hierachical binlog file storage */
|
enum binlog_storage_type storage_type;/*< Enables hierachical binlog file storage */
|
||||||
char *set_slave_hostname; /*< Send custom Hostname to Master */
|
char *set_slave_hostname; /*< Send custom Hostname to Master */
|
||||||
ROUTER_INSTANCE *next;
|
ROUTER_INSTANCE *next;
|
||||||
|
ChangeMasterConfig config; /*< Current config. */
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Master Semi-Sync capability */
|
/** Master Semi-Sync capability */
|
||||||
|
@ -164,7 +164,8 @@ static int blr_apply_change_master(ROUTER_INSTANCE* router,
|
|||||||
char* error);
|
char* error);
|
||||||
static int blr_handle_change_master(ROUTER_INSTANCE* router,
|
static int blr_handle_change_master(ROUTER_INSTANCE* router,
|
||||||
char *command,
|
char *command,
|
||||||
char *error);
|
char *error,
|
||||||
|
ChangeMasterConfig* pNew_config);
|
||||||
static int blr_set_master_hostname(ROUTER_INSTANCE *router, const char *hostname);
|
static int blr_set_master_hostname(ROUTER_INSTANCE *router, const char *hostname);
|
||||||
static int blr_set_master_hostname(ROUTER_INSTANCE *router, const std::string& hostname);
|
static int blr_set_master_hostname(ROUTER_INSTANCE *router, const std::string& hostname);
|
||||||
static int blr_set_master_port(ROUTER_INSTANCE *router, int port);
|
static int blr_set_master_port(ROUTER_INSTANCE *router, int port);
|
||||||
@ -4405,13 +4406,15 @@ static char* get_connection_name(char* command, std::string* pConnection_name)
|
|||||||
* @param command The change master SQL command
|
* @param command The change master SQL command
|
||||||
* @param error The error message, preallocated
|
* @param error The error message, preallocated
|
||||||
* BINLOG_ERROR_MSG_LEN + 1 bytes
|
* BINLOG_ERROR_MSG_LEN + 1 bytes
|
||||||
|
* @pNew_config [out] The new config.
|
||||||
* @return 0 on success,
|
* @return 0 on success,
|
||||||
* 1 on success with new binlog, -1 on failure
|
* 1 on success with new binlog, -1 on failure
|
||||||
*/
|
*/
|
||||||
static
|
static
|
||||||
int blr_handle_change_master(ROUTER_INSTANCE* router,
|
int blr_handle_change_master(ROUTER_INSTANCE* router,
|
||||||
char *command,
|
char *command,
|
||||||
char *error)
|
char *error,
|
||||||
|
ChangeMasterConfig* pNew_config)
|
||||||
{
|
{
|
||||||
std::string connection_name;
|
std::string connection_name;
|
||||||
command = get_connection_name(command, &connection_name);
|
command = get_connection_name(command, &connection_name);
|
||||||
@ -4438,13 +4441,12 @@ int blr_handle_change_master(ROUTER_INSTANCE* router,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ChangeMasterConfig new_config;
|
if (!new_options.validate(router, error, pNew_config))
|
||||||
if (!new_options.validate(router, error, &new_config))
|
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return blr_apply_change_master(router, new_config, error);
|
return blr_apply_change_master(router, *pNew_config, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -5496,7 +5498,8 @@ blr_test_handle_change_master(ROUTER_INSTANCE* router,
|
|||||||
char *command,
|
char *command,
|
||||||
char *error)
|
char *error)
|
||||||
{
|
{
|
||||||
return blr_handle_change_master(router, bypass_change_master(command), error);
|
ChangeMasterConfig config;
|
||||||
|
return blr_handle_change_master(router, bypass_change_master(command), error, &config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -8036,10 +8039,10 @@ static bool blr_handle_admin_stmt(ROUTER_INSTANCE *router,
|
|||||||
int rc;
|
int rc;
|
||||||
char error_string[BINLOG_ERROR_MSG_LEN + 1 + BINLOG_ERROR_MSG_LEN + 1] = "";
|
char error_string[BINLOG_ERROR_MSG_LEN + 1 + BINLOG_ERROR_MSG_LEN + 1] = "";
|
||||||
MasterServerConfig current_master;
|
MasterServerConfig current_master;
|
||||||
|
|
||||||
blr_master_get_config(router, ¤t_master);
|
blr_master_get_config(router, ¤t_master);
|
||||||
|
|
||||||
rc = blr_handle_change_master(router, brkb, error_string);
|
ChangeMasterConfig new_config;
|
||||||
|
rc = blr_handle_change_master(router, brkb, error_string, &new_config);
|
||||||
|
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
{
|
{
|
||||||
@ -8059,7 +8062,7 @@ static bool blr_handle_admin_stmt(ROUTER_INSTANCE *router,
|
|||||||
/* Write/Update master config into master.ini file */
|
/* Write/Update master config into master.ini file */
|
||||||
ret = blr_file_write_master_config(router, error);
|
ret = blr_file_write_master_config(router, error);
|
||||||
|
|
||||||
if (ret)
|
if (ret != 0)
|
||||||
{
|
{
|
||||||
/* file operation failure: restore config */
|
/* file operation failure: restore config */
|
||||||
spinlock_acquire(&router->lock);
|
spinlock_acquire(&router->lock);
|
||||||
@ -8085,6 +8088,7 @@ static bool blr_handle_admin_stmt(ROUTER_INSTANCE *router,
|
|||||||
|
|
||||||
/* Mark as active the master server struct */
|
/* Mark as active the master server struct */
|
||||||
spinlock_acquire(&router->lock);
|
spinlock_acquire(&router->lock);
|
||||||
|
router->config = new_config;
|
||||||
if (!router->service->dbref->server->is_active)
|
if (!router->service->dbref->server->is_active)
|
||||||
{
|
{
|
||||||
router->service->dbref->server->is_active = true;
|
router->service->dbref->server->is_active = true;
|
||||||
|
Reference in New Issue
Block a user