Adding a mutex when Cluster is syncing mysql query rules

pull/3305/head
René Cannaò 5 years ago
parent 254ee51e8a
commit 894e72041d

@ -6873,6 +6873,7 @@ unsigned int ProxySQL_Admin::ProxySQL_Test___GenerateRandom_mysql_query_rules_fa
sqlite3_stmt *statement1=NULL;
rc=admindb->prepare_v2(a, &statement1);
ASSERT_SQLITE_OK(rc, admindb);
pthread_mutex_lock(&sql_query_global_mutex);
admindb->execute("DELETE FROM mysql_query_rules_fast_routing");
char * username_buf = (char *)malloc(32);
char * schemaname_buf = (char *)malloc(64);
@ -6914,6 +6915,7 @@ unsigned int ProxySQL_Admin::ProxySQL_Test___GenerateRandom_mysql_query_rules_fa
rc=(*proxy_sqlite3_reset)(statement1); ASSERT_SQLITE_OK(rc, admindb);
}
(*proxy_sqlite3_finalize)(statement1);
pthread_mutex_unlock(&GloAdmin->sql_query_global_mutex);
free(username_buf);
free(schemaname_buf);
return cnt;

@ -819,6 +819,7 @@ void ProxySQL_Cluster::pull_mysql_query_rules_from_peer() {
result2 = mysql_store_result(conn);
proxy_info("Cluster: Fetching MySQL Query Rules from peer %s:%d completed\n", hostname, port);
proxy_info("Cluster: Loading to runtime MySQL Query Rules from peer %s:%d\n", hostname, port);
pthread_mutex_lock(&GloAdmin->sql_query_global_mutex);
GloAdmin->admindb->execute("DELETE FROM mysql_query_rules");
GloAdmin->admindb->execute("DELETE FROM mysql_query_rules_fast_routing");
MYSQL_ROW row;
@ -913,6 +914,7 @@ void ProxySQL_Cluster::pull_mysql_query_rules_from_peer() {
} else {
proxy_info("Cluster: NOT saving to disk MySQL Query Rules from peer %s:%d\n", hostname, port);
}
pthread_mutex_unlock(&GloAdmin->sql_query_global_mutex);
metrics.p_counter_array[p_cluster_counter::pulled_mysql_query_rules_success]->Increment();
} else {
proxy_info("Cluster: Fetching MySQL Query Rules from peer %s:%d failed: %s\n", hostname, port, mysql_error(conn));

Loading…
Cancel
Save