From e1adc955ebaebc4ff36c8edeb68b0f18c35017f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Thu, 26 Aug 2021 17:06:17 +0200 Subject: [PATCH] Fixing some race condition in Cluster Similar to commit f8ce41305d6ca4f9198281789c19b9ecc017a56e --- lib/ProxySQL_Admin.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/ProxySQL_Admin.cpp b/lib/ProxySQL_Admin.cpp index f2ef64c4c..4389bc467 100644 --- a/lib/ProxySQL_Admin.cpp +++ b/lib/ProxySQL_Admin.cpp @@ -3255,9 +3255,15 @@ bool ProxySQL_Admin::GenericRefreshStatistics(const char *query_no_space, unsign mysql_thread___hostgroup_manager_verbose = old_hostgroup_manager_verbose; } if (runtime_proxysql_servers) { - mysql_servers_wrlock(); + //mysql_servers_wrlock(); + // before save_proxysql_servers_runtime_to_database() we release + // sql_query_global_mutex to prevent a possible deadlock due to + // a race condition + // save_proxysql_servers_runtime_to_database() calls ProxySQL_Cluster::dump_table_proxysql_servers() + pthread_mutex_unlock(&SPA->sql_query_global_mutex); save_proxysql_servers_runtime_to_database(true); - mysql_servers_wrunlock(); + pthread_mutex_lock(&SPA->sql_query_global_mutex); + //mysql_servers_wrunlock(); } if (runtime_mysql_users) { save_mysql_users_runtime_to_database(true);