From 76e855dc1d69324161ba45c5ccb52f3013e163dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Fri, 13 Mar 2020 11:23:01 +0200 Subject: [PATCH] MXS-2919: Don't use slaves with unknown lag If a limit on the replication lag is configured, servers with unmeasured replication lag should not be used. The code in question did use them even when a limit was set as the value used for undefined lag was -1 which always measured lower than the limit. --- server/modules/routing/readwritesplit/readwritesplit.hh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/modules/routing/readwritesplit/readwritesplit.hh b/server/modules/routing/readwritesplit/readwritesplit.hh index 2ea1eb036..cde124550 100644 --- a/server/modules/routing/readwritesplit/readwritesplit.hh +++ b/server/modules/routing/readwritesplit/readwritesplit.hh @@ -472,5 +472,6 @@ std::string extract_error(GWBUF* buffer); */ static inline bool rpl_lag_is_ok(mxs::RWBackend* backend, int max_rlag) { - return max_rlag == SERVER::RLAG_UNDEFINED || backend->server()->rlag <= max_rlag; + auto rlag = backend->server()->rlag; + return max_rlag == SERVER::RLAG_UNDEFINED || (rlag != SERVER::RLAG_UNDEFINED && rlag <= max_rlag); }