From a843aedb7c848c4fd850b3d0cc06f1de119fdccd Mon Sep 17 00:00:00 2001 From: Rahim Kanji Date: Fri, 17 Feb 2023 11:29:16 +0500 Subject: [PATCH] Removed sql_query_global_mutex from read_only_action method --- lib/MySQL_HostGroups_Manager.cpp | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/lib/MySQL_HostGroups_Manager.cpp b/lib/MySQL_HostGroups_Manager.cpp index 5a73157ec..7944e7055 100644 --- a/lib/MySQL_HostGroups_Manager.cpp +++ b/lib/MySQL_HostGroups_Manager.cpp @@ -4224,9 +4224,6 @@ void MySQL_HostGroups_Manager::read_only_action(char *hostname, int port, int re case 0: if (num_rows==0) { // the server has read_only=0 , but we can't find any writer, so we perform a swap - // NOTE: In order to avoid race conditions while 'reading' from 'mysql_servers' - // when 'read_only_action' is performed, we block 'ProxySQL_Admin' global SQL mutex. - pthread_mutex_lock(&GloAdmin->sql_query_global_mutex); GloAdmin->mysql_servers_wrlock(); if (GloMTH->variables.hostgroup_manager_verbose) { char *error2=NULL; @@ -4304,7 +4301,6 @@ void MySQL_HostGroups_Manager::read_only_action(char *hostname, int port, int re } GloAdmin->load_mysql_servers_to_runtime(); // LOAD MYSQL SERVERS TO RUNTIME GloAdmin->mysql_servers_wrunlock(); - pthread_mutex_unlock(&GloAdmin->sql_query_global_mutex); } else { // there is a server in writer hostgroup, let check the status of present and not present hosts bool act=false; @@ -4339,9 +4335,6 @@ void MySQL_HostGroups_Manager::read_only_action(char *hostname, int port, int re } wrunlock(); if (act==true) { // there are servers either missing, or with stats=OFFLINE_HARD - // NOTE: In order to avoid race conditions while 'reading' from 'mysql_servers' - // when 'read_only_action' is performed, we block 'ProxySQL_Admin' global SQL mutex. - pthread_mutex_lock(&GloAdmin->sql_query_global_mutex); GloAdmin->mysql_servers_wrlock(); if (GloMTH->variables.hostgroup_manager_verbose) { char *error2=NULL; @@ -4419,16 +4412,12 @@ void MySQL_HostGroups_Manager::read_only_action(char *hostname, int port, int re } GloAdmin->load_mysql_servers_to_runtime(); // LOAD MYSQL SERVERS TO RUNTIME GloAdmin->mysql_servers_wrunlock(); - pthread_mutex_unlock(&GloAdmin->sql_query_global_mutex); } } break; case 1: if (num_rows) { // the server has read_only=1 , but we find it as writer, so we perform a swap - // NOTE: In order to avoid race conditions while 'reading' from 'mysql_servers' - // when 'read_only_action' is performed, we block 'ProxySQL_Admin' global SQL mutex. - pthread_mutex_lock(&GloAdmin->sql_query_global_mutex); GloAdmin->mysql_servers_wrlock(); if (GloMTH->variables.hostgroup_manager_verbose) { char *error2=NULL; @@ -4500,7 +4489,6 @@ void MySQL_HostGroups_Manager::read_only_action(char *hostname, int port, int re } GloAdmin->load_mysql_servers_to_runtime(); // LOAD MYSQL SERVERS TO RUNTIME GloAdmin->mysql_servers_wrunlock(); - pthread_mutex_unlock(&GloAdmin->sql_query_global_mutex); } break; default: