From 92832c1ec4d1f6fc8d82cd8bfdebe5f6e17efb1a Mon Sep 17 00:00:00 2001 From: Niclas Antti Date: Mon, 24 Sep 2018 12:14:22 +0300 Subject: [PATCH] MXS-1777 Remove selection of servers with historically lower number of connections. Removed the almost equal comparison and subsequent selection based on historical number of connections. The effect of it was this: Select the server that has historically, weights or not, been slower. Tested this with 2.2 with maxscale on one server and mariadb:s on two servers with different network lags. The tests with historical selects were clearly slower. --- include/maxscale/server.hh | 13 +------------ .../modules/routing/readconnroute/readconnroute.cc | 12 ------------ 2 files changed, 1 insertion(+), 24 deletions(-) diff --git a/include/maxscale/server.hh b/include/maxscale/server.hh index 824bd97e2..43bc02007 100644 --- a/include/maxscale/server.hh +++ b/include/maxscale/server.hh @@ -21,18 +21,7 @@ namespace maxscale { + bool server_set_status(SERVER* server, int bit, std::string* errmsg_out = NULL); bool server_clear_status(SERVER* server, int bit, std::string* errmsg_out = NULL); - -/** Returns true if the two server "scores" are within 1/(see code) of each other. - * The epsilon needs tweaking, and might even need to be in config. This - * function is important for some compares, where one server might be only - * marginally better than others, in which case historical data could determine - * the outcome. - */ -inline bool almost_equal_server_scores(double lhs, double rhs) -{ - constexpr double div = 100; // within 1% of each other. - return std::abs((long)(lhs - rhs)) < std::abs((long)std::max(lhs, rhs)) * (1 / div); -} } diff --git a/server/modules/routing/readconnroute/readconnroute.cc b/server/modules/routing/readconnroute/readconnroute.cc index 7c4bb688b..e448ecdc9 100644 --- a/server/modules/routing/readconnroute/readconnroute.cc +++ b/server/modules/routing/readconnroute/readconnroute.cc @@ -377,18 +377,6 @@ static MXS_ROUTER_SESSION* newSession(MXS_ROUTER* instance, MXS_SESSION* session /* ref has a better score. */ candidate = ref; } - else if (mxs::almost_equal_server_scores(ref->server_weight * ref->connections, - candidate->server_weight * candidate->connections) - && ref->server->stats.n_connections < candidate->server->stats.n_connections) - { - /* The servers are about equally good, but ref has had fewer connections over time. - * TODO: On second thought, if the servers are currently about equally good, - * should selection not favor the one that has had more connections over time, - * since load balancing has previously found it to be better? Or perhaps - * this check has very little effect anyway. - */ - candidate = ref; - } } }