From c7d90636b0809e926664fbb9501a679866a60117 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Tue, 9 Jul 2019 07:25:08 +0300 Subject: [PATCH] MXS-2594: Fix priority usage without node priorities The first node without a priority would be chosen as the candidate master and the rest would be ignored. The code must check if neither of the two nodes have priorities and if so must choose the better one. --- server/modules/monitor/galeramon/galeramon.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/server/modules/monitor/galeramon/galeramon.c b/server/modules/monitor/galeramon/galeramon.c index 78d96b2d1..fe2a89d15 100644 --- a/server/modules/monitor/galeramon/galeramon.c +++ b/server/modules/monitor/galeramon/galeramon.c @@ -697,9 +697,15 @@ static MXS_MONITORED_SERVER *get_candidate_master(MXS_MONITOR* mon) } } } - else if (moitor_servers->server->node_id >= 0 && - (!handle->use_priority || candidate_master == NULL)) + else if (moitor_servers->server->node_id >= 0) { + if (handle->use_priority && candidate_master && + server_get_parameter_nolock(moitor_servers->server, "priority", buf, sizeof(buf))) + { + // Current candidate has priority but this node doesn't, current candidate is better + continue; + } + // Server priorities are not in use or no candidate has been found if (min_id < 0 || moitor_servers->server->node_id < min_id) {