Commit 9f61aa4f authored by Denis Protivensky's avatar Denis Protivensky Committed by Julius Goryavsky

MDEV-34822 pre-fix: Make wsrep_ready flag read lock-free

It's read for every command execution, and during slave replication
for every applied event.

It's also planned to be used during write set applying, so it means
mostly every server thread is going to compete for the mutex covering
this variable, especially considering how rarely it changes.
Converting wsrep_ready to atomic relaxes the things.
Signed-off-by: default avatarJulius Goryavsky <julius.goryavsky@mariadb.com>
parent 024e9512
...@@ -269,8 +269,8 @@ static char provider_vendor[256]= { 0, }; ...@@ -269,8 +269,8 @@ static char provider_vendor[256]= { 0, };
* Wsrep status variables. LOCK_status must be locked When modifying * Wsrep status variables. LOCK_status must be locked When modifying
* these variables, * these variables,
*/ */
std::atomic<bool> wsrep_ready(false);
my_bool wsrep_connected = FALSE; my_bool wsrep_connected = FALSE;
my_bool wsrep_ready = FALSE;
const char* wsrep_cluster_state_uuid= cluster_uuid_str; const char* wsrep_cluster_state_uuid= cluster_uuid_str;
long long wsrep_cluster_conf_id = WSREP_SEQNO_UNDEFINED; long long wsrep_cluster_conf_id = WSREP_SEQNO_UNDEFINED;
const char* wsrep_cluster_status = "Disconnected"; const char* wsrep_cluster_status = "Disconnected";
...@@ -565,10 +565,7 @@ void wsrep_verify_SE_checkpoint(const wsrep_uuid_t& uuid, ...@@ -565,10 +565,7 @@ void wsrep_verify_SE_checkpoint(const wsrep_uuid_t& uuid,
*/ */
my_bool wsrep_ready_get (void) my_bool wsrep_ready_get (void)
{ {
if (mysql_mutex_lock (&LOCK_wsrep_ready)) abort(); return wsrep_ready;
my_bool ret= wsrep_ready;
mysql_mutex_unlock (&LOCK_wsrep_ready);
return ret;
} }
int wsrep_show_ready(THD *thd, SHOW_VAR *var, void *buff, int wsrep_show_ready(THD *thd, SHOW_VAR *var, void *buff,
...@@ -3452,6 +3449,10 @@ bool wsrep_consistency_check(THD *thd) ...@@ -3452,6 +3449,10 @@ bool wsrep_consistency_check(THD *thd)
// Wait until wsrep has reached ready state // Wait until wsrep has reached ready state
void wsrep_wait_ready(THD *thd) void wsrep_wait_ready(THD *thd)
{ {
// First check not locking the mutex.
if (wsrep_ready)
return;
mysql_mutex_lock(&LOCK_wsrep_ready); mysql_mutex_lock(&LOCK_wsrep_ready);
while(!wsrep_ready) while(!wsrep_ready)
{ {
......
...@@ -135,7 +135,6 @@ extern const char *wsrep_SR_store_types[]; ...@@ -135,7 +135,6 @@ extern const char *wsrep_SR_store_types[];
// MySQL status variables // MySQL status variables
extern my_bool wsrep_connected; extern my_bool wsrep_connected;
extern my_bool wsrep_ready;
extern const char* wsrep_cluster_state_uuid; extern const char* wsrep_cluster_state_uuid;
extern long long wsrep_cluster_conf_id; extern long long wsrep_cluster_conf_id;
extern const char* wsrep_cluster_status; extern const char* wsrep_cluster_status;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment