From 117f89a409f1b4d0feceed1de67c0c4815129aa5 Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Mon, 28 Jan 2019 10:30:28 +0200 Subject: [PATCH] MXS-2273 Deal with master being drained at RWS connect If a master is found but it is being drained, the connection attempt is rejected if the master failure mode is fail_instantly. In that case the logged message makes it plain that it is the draining that is the reason for the connection attempt to fail. --- .../readwritesplit/rwsplit_select_backends.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/server/modules/routing/readwritesplit/rwsplit_select_backends.cc b/server/modules/routing/readwritesplit/rwsplit_select_backends.cc index ffecdde48..bb055c608 100644 --- a/server/modules/routing/readwritesplit/rwsplit_select_backends.cc +++ b/server/modules/routing/readwritesplit/rwsplit_select_backends.cc @@ -374,9 +374,18 @@ bool RWSplit::select_connect_backend_servers(MXS_SESSION* session, RWBackend* master = get_root_master(backends); const Config& cnf {config()}; - if (!master && cnf.master_failure_mode == RW_FAIL_INSTANTLY) + if ((!master || !master->can_connect()) && cnf.master_failure_mode == RW_FAIL_INSTANTLY) { - MXS_ERROR("Couldn't find suitable Master from %lu candidates.", backends.size()); + if (!master) + { + MXS_ERROR("Couldn't find suitable Master from %lu candidates.", backends.size()); + } + else + { + MXS_ERROR("Master exists (%s), but it is being drained and cannot be used.", + master->server()->address); + } + return false; }