From 654b5f1958b67d6158f93184a58b09765036d149 Mon Sep 17 00:00:00 2001 From: Esa Korhonen Date: Wed, 16 May 2018 10:44:59 +0300 Subject: [PATCH] MXS-1865 Wrong permissions on backends no longer cause monitor start to fail The logic was weird, as the permission checking function assumes a disconnected server as fine. The checking is now done when starting the main loop and lacking grants print errors but does not stop the monitor. --- .../modules/monitor/mariadbmon/mariadbmon.cc | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/server/modules/monitor/mariadbmon/mariadbmon.cc b/server/modules/monitor/mariadbmon/mariadbmon.cc index 86e47b3dd..8852b9fb4 100644 --- a/server/modules/monitor/mariadbmon/mariadbmon.cc +++ b/server/modules/monitor/mariadbmon/mariadbmon.cc @@ -160,20 +160,12 @@ bool MariaDBMonitor::start(const MXS_CONFIG_PARAMETER* params) error = true; } - if (!error && !check_monitor_permissions(m_monitor_base, "SHOW SLAVE STATUS")) + if (!error && (thread_start(&m_thread, monitorMain, this, 0) == NULL)) { + MXS_ERROR("Failed to start monitor thread for monitor '%s'.", m_monitor_base->name); error = true; } - if (!error) - { - if (thread_start(&m_thread, monitorMain, this, 0) == NULL) - { - MXS_ERROR("Failed to start monitor thread for monitor '%s'.", m_monitor_base->name); - error = true; - } - } - if (error) { MXS_ERROR("Failed to start monitor. See earlier errors for more information."); @@ -339,6 +331,16 @@ void MariaDBMonitor::main_loop() check_maxscale_schema_replication(); } + /* Check monitor permissions. Failure won't cause the monitor to stop. Afterwards, close connections so + * that update_server() reconnects and checks server version. TODO: check permissions when checking + * server version. */ + check_monitor_permissions(m_monitor_base, "SHOW SLAVE STATUS"); + for (auto iter = m_servers.begin(); iter != m_servers.end(); iter++) + { + mysql_close((*iter)->m_server_base->con); + (*iter)->m_server_base->con = NULL; + } + while (m_keep_running) { timespec loop_start;