Removed sql_query_global_mutex from read_only_action method

v2.2.0-sqliteserver_read_only
Rahim Kanji 3 years ago
parent 3a0804031c
commit a843aedb7c

@ -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:

Loading…
Cancel
Save