Use server weights when choosing the candidate master
With this change, if two master servers both have equal depths but different weights, the one with the higher weight is used. If the depths and weights are equal, the first master listed in the configuration is used.
This commit is contained in:
@ -30,6 +30,11 @@ running|A server that is up and running. All servers that MariaDB MaxScale can c
|
||||
|
||||
If no `router_options` parameter is configured in the service definition, the router will use the default value of `running`. This means that it will load balance connections across all running servers defined in the `servers` parameter of the service.
|
||||
|
||||
When a connection is being created and the candidate server is being chosen, the
|
||||
list of servers is processed in from first entry to last. This means that if two
|
||||
servers with equal weight and status are found, the one that's listed first in
|
||||
the _servers_ parameter for the service is chosen.
|
||||
|
||||
## Limitations
|
||||
|
||||
For a list of readconnroute limitations, please read the [Limitations](../About/Limitations.md) document.
|
||||
|
@ -1015,12 +1015,18 @@ static BACKEND *get_root_master(BACKEND **servers)
|
||||
{
|
||||
if (servers[i] && (servers[i]->server->status & (SERVER_MASTER | SERVER_MAINT)) == SERVER_MASTER)
|
||||
{
|
||||
if (master_host && servers[i]->server->depth < master_host->server->depth)
|
||||
if (master_host == NULL)
|
||||
{
|
||||
master_host = servers[i];
|
||||
}
|
||||
else if (master_host == NULL)
|
||||
else if (servers[i]->server->depth < master_host->server->depth ||
|
||||
(servers[i]->server->depth == master_host->server->depth &&
|
||||
servers[i]->weight > master_host->weight))
|
||||
{
|
||||
/**
|
||||
* This master has a lower depth than the candidate master or
|
||||
* the depths are equal but this master has a higher weight
|
||||
*/
|
||||
master_host = servers[i];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user