Fix use of zero-weight servers

The servers with a zero weight would be always used over ones that have a
weight. This means that the behavior was inverted and caused the
mxs2054_hybrid_cluster test to fail in 2.3.

Also fixed a typo in the deprecation message.
This commit is contained in:
Markus Mäkelä 2018-11-12 08:53:27 +02:00
parent f2688784cf
commit ae0e9b359d
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19
2 changed files with 9 additions and 6 deletions

View File

@ -1703,7 +1703,7 @@ static void service_calculate_weights(SERVICE* service)
if (*weightby && service->dbref)
{
// DEPRECATED in 2.3, remove in 2.4.
MXS_WARNING("Setting of server weigths (%s) has been deprecated"
MXS_WARNING("Setting of server weights (%s) has been deprecated"
" and will be removed in a later version of MaxScale.",
weightby);

View File

@ -79,7 +79,8 @@ SRWBackendVector::iterator best_score(SRWBackendVector& sBackends,
SRWBackendVector::iterator backend_cmp_router_conn(SRWBackendVector& sBackends)
{
static auto server_score = [](SERVER_REF* server) {
return server->server_weight ? (server->connections + 1) / server->server_weight : 0;
return server->server_weight ? (server->connections + 1) / server->server_weight :
std::numeric_limits<double>::max();
};
return best_score(sBackends, server_score);
@ -89,7 +90,8 @@ SRWBackendVector::iterator backend_cmp_router_conn(SRWBackendVector& sBackends)
SRWBackendVector::iterator backend_cmp_global_conn(SRWBackendVector& sBackends)
{
static auto server_score = [](SERVER_REF* server) {
return server->server_weight ? (server->server->stats.n_current + 1) / server->server_weight : 0;
return server->server_weight ? (server->server->stats.n_current + 1) / server->server_weight :
std::numeric_limits<double>::max();
};
return best_score(sBackends, server_score);
@ -99,7 +101,8 @@ SRWBackendVector::iterator backend_cmp_global_conn(SRWBackendVector& sBackends)
SRWBackendVector::iterator backend_cmp_behind_master(SRWBackendVector& sBackends)
{
static auto server_score = [](SERVER_REF* server) {
return server->server_weight ? server->server->rlag / server->server_weight : 0;
return server->server_weight ? server->server->rlag / server->server_weight :
std::numeric_limits<double>::max();
};
return best_score(sBackends, server_score);
@ -109,8 +112,8 @@ SRWBackendVector::iterator backend_cmp_behind_master(SRWBackendVector& sBackends
SRWBackendVector::iterator backend_cmp_current_load(SRWBackendVector& sBackends)
{
static auto server_score = [](SERVER_REF* server) {
return server->server_weight ? (server->server->stats.n_current_ops + 1)
/ server->server_weight : 0;
return server->server_weight ? (server->server->stats.n_current_ops + 1) / server->server_weight :
std::numeric_limits<double>::max();
};
return best_score(sBackends, server_score);