Fix to MXS-494: Fixed readconnroute weight calculation

The calculation of weights used the actual amount of connections instead of
actual amount of connections + 1. This lead to the weight being effectively
ignored for servers with no connections.
This commit is contained in:
Markus Makela
2015-12-01 13:04:48 +02:00
parent 91eba965fc
commit 45abfeec2c

View File

@ -499,18 +499,18 @@ newSession(ROUTER *instance, SESSION *session)
{ {
candidate = inst->servers[i]; candidate = inst->servers[i];
} }
else if ((inst->servers[i]->current_connection_count else if (((inst->servers[i]->current_connection_count + 1)
* 1000) / inst->servers[i]->weight < * 1000) / inst->servers[i]->weight <
(candidate->current_connection_count * ((candidate->current_connection_count + 1) *
1000) / candidate->weight) 1000) / candidate->weight)
{ {
/* This running server has fewer /* This running server has fewer
connections, set it as a new candidate */ connections, set it as a new candidate */
candidate = inst->servers[i]; candidate = inst->servers[i];
} }
else if ((inst->servers[i]->current_connection_count else if (((inst->servers[i]->current_connection_count + 1)
* 1000) / inst->servers[i]->weight == * 1000) / inst->servers[i]->weight ==
(candidate->current_connection_count * ((candidate->current_connection_count + 1) *
1000) / candidate->weight && 1000) / candidate->weight &&
inst->servers[i]->server->stats.n_connections < inst->servers[i]->server->stats.n_connections <
candidate->server->stats.n_connections) candidate->server->stats.n_connections)