MXS-1743: Fix usage of both master and slave types
The use of `router_options=master,slave` was not working as expected. This was mostly caused by the master bit checks using a bitwise AND instead of comparing equality. In addition to this, the master would not be considered a valid candidate if both slaves and masters were available.
This commit is contained in:
@ -334,7 +334,7 @@ newSession(MXS_ROUTER *instance, MXS_SESSION *session)
|
|||||||
{
|
{
|
||||||
if (master_host)
|
if (master_host)
|
||||||
{
|
{
|
||||||
if (ref == master_host && (inst->bitvalue & SERVER_SLAVE))
|
if (ref == master_host && (inst->bitvalue & (SERVER_SLAVE | SERVER_MASTER)) == SERVER_SLAVE)
|
||||||
{
|
{
|
||||||
/* Skip root master here, as it could also be slave of an external server that
|
/* Skip root master here, as it could also be slave of an external server that
|
||||||
* is not in the configuration. Intermediate masters (Relay Servers) are also
|
* is not in the configuration. Intermediate masters (Relay Servers) are also
|
||||||
@ -353,16 +353,13 @@ newSession(MXS_ROUTER *instance, MXS_SESSION *session)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else if (inst->bitvalue == SERVER_MASTER)
|
||||||
{
|
{
|
||||||
/* Master_host is NULL, no master server. If requested router_option is 'master'
|
/* Master_host is NULL, no master server. If requested router_option is 'master'
|
||||||
* candidate wll be NULL.
|
* candidate will be NULL.
|
||||||
*/
|
*/
|
||||||
if (inst->bitvalue & SERVER_MASTER)
|
candidate = NULL;
|
||||||
{
|
break;
|
||||||
candidate = NULL;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If no candidate set, set first running server as our initial candidate server */
|
/* If no candidate set, set first running server as our initial candidate server */
|
||||||
@ -548,7 +545,7 @@ static inline bool connection_is_valid(ROUTER_INSTANCE* inst, ROUTER_CLIENT_SES*
|
|||||||
if (SERVER_IS_RUNNING(router_cli_ses->backend->server) &&
|
if (SERVER_IS_RUNNING(router_cli_ses->backend->server) &&
|
||||||
(router_cli_ses->backend->server->status & inst->bitmask & inst->bitvalue))
|
(router_cli_ses->backend->server->status & inst->bitmask & inst->bitvalue))
|
||||||
{
|
{
|
||||||
if ((inst->bitvalue & SERVER_MASTER) && router_cli_ses->backend->active)
|
if ((inst->bitvalue == SERVER_MASTER) && router_cli_ses->backend->active)
|
||||||
{
|
{
|
||||||
// If we're using an active master server, verify that it is still a master
|
// If we're using an active master server, verify that it is still a master
|
||||||
rval = router_cli_ses->backend == get_root_master(inst->service->dbref);
|
rval = router_cli_ses->backend == get_root_master(inst->service->dbref);
|
||||||
|
Reference in New Issue
Block a user