From 9b7ec7ee58483404dec54c765e61723d00fc0374 Mon Sep 17 00:00:00 2001 From: Esa Korhonen Date: Fri, 13 Apr 2018 17:08:05 +0300 Subject: [PATCH] MXS-1703 Add missing manual rejoin error messages Calling rejoin with a server which is already replicating now gives a proper error message. --- .../mariadbmon/cluster_manipulation.cc | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/server/modules/monitor/mariadbmon/cluster_manipulation.cc b/server/modules/monitor/mariadbmon/cluster_manipulation.cc index b5bbaf9bf..249af53b9 100644 --- a/server/modules/monitor/mariadbmon/cluster_manipulation.cc +++ b/server/modules/monitor/mariadbmon/cluster_manipulation.cc @@ -161,7 +161,7 @@ bool MariaDBMonitor::manual_rejoin(SERVER* rejoin_server, json_t** output) PRINT_MXS_JSON_ERROR(output, "Cluster master '%s' gtid info could not be updated.", m_master->name()); } - } + } // server_is_rejoin_suspect has added any error messages to the output, no need to print here } else { @@ -515,6 +515,24 @@ bool MariaDBMonitor::server_is_rejoin_suspect(MariaDBServer* rejoin_cand, MariaD is_suspect = true; } } + + if (output != NULL && !is_suspect) + { + /* User has requested a manual rejoin but with a server which has multiple slave connections or + * is already connected or trying to connect to the correct master. TODO: Slave IO stopped is + * not yet handled perfectly. */ + if (rejoin_cand->n_slaves_configured > 1) + { + const char MULTI_SLAVE[] = "Server '%s' has multiple slave connections, cannot rejoin."; + PRINT_MXS_JSON_ERROR(output, MULTI_SLAVE, rejoin_cand->name()); + } + else + { + const char CONNECTED[] = "Server '%s' is already connected or trying to connect to the " + "correct master server."; + PRINT_MXS_JSON_ERROR(output, CONNECTED, rejoin_cand->name()); + } + } } else if (output != NULL) {