Commit b1fabf6c authored by Monty's avatar Monty

Performance improvements to test if WSREP if active

parent 93281221
...@@ -1291,7 +1291,7 @@ bool do_command(THD *thd) ...@@ -1291,7 +1291,7 @@ bool do_command(THD *thd)
Aborted by background rollbacker thread. Aborted by background rollbacker thread.
Handle error here and jump straight to out Handle error here and jump straight to out
*/ */
if (wsrep_before_command(thd)) if (unlikely(wsrep_service_started) && wsrep_before_command(thd))
{ {
thd->store_globals(); thd->store_globals();
WSREP_LOG_THD(thd, "enter found BF aborted"); WSREP_LOG_THD(thd, "enter found BF aborted");
...@@ -1368,6 +1368,7 @@ bool do_command(THD *thd) ...@@ -1368,6 +1368,7 @@ bool do_command(THD *thd)
if (packet_length != packet_error) if (packet_length != packet_error)
{ {
/* there was a command to process, and before_command() has been called */ /* there was a command to process, and before_command() has been called */
if (unlikely(wsrep_service_started))
wsrep_after_command_after_result(thd); wsrep_after_command_after_result(thd);
} }
#endif /* WITH_WSREP */ #endif /* WITH_WSREP */
...@@ -1659,14 +1660,20 @@ bool dispatch_command(enum enum_server_command command, THD *thd, ...@@ -1659,14 +1660,20 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
{ {
thd->status_var.com_other++; thd->status_var.com_other++;
#ifdef WITH_WSREP #ifdef WITH_WSREP
if (unlikely(wsrep_service_started))
{
wsrep_after_command_ignore_result(thd); wsrep_after_command_ignore_result(thd);
wsrep_close(thd); wsrep_close(thd);
}
#endif /* WITH_WSREP */ #endif /* WITH_WSREP */
thd->change_user(); thd->change_user();
thd->clear_error(); // if errors from rollback thd->clear_error(); // if errors from rollback
#ifdef WITH_WSREP #ifdef WITH_WSREP
if (unlikely(wsrep_service_started))
{
wsrep_open(thd); wsrep_open(thd);
wsrep_before_command(thd); wsrep_before_command(thd);
}
#endif /* WITH_WSREP */ #endif /* WITH_WSREP */
/* Restore original charset from client authentication packet.*/ /* Restore original charset from client authentication packet.*/
if(thd->org_charset) if(thd->org_charset)
...@@ -1680,13 +1687,19 @@ bool dispatch_command(enum enum_server_command command, THD *thd, ...@@ -1680,13 +1687,19 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
status_var_increment(thd->status_var.com_other); status_var_increment(thd->status_var.com_other);
#ifdef WITH_WSREP #ifdef WITH_WSREP
if (unlikely(wsrep_service_started))
{
wsrep_after_command_ignore_result(thd); wsrep_after_command_ignore_result(thd);
wsrep_close(thd); wsrep_close(thd);
}
#endif /* WITH_WSREP */ #endif /* WITH_WSREP */
thd->change_user(); thd->change_user();
#ifdef WITH_WSREP #ifdef WITH_WSREP
if (unlikely(wsrep_service_started))
{
wsrep_open(thd); wsrep_open(thd);
wsrep_before_command(thd); wsrep_before_command(thd);
}
#endif /* WITH_WSREP */ #endif /* WITH_WSREP */
thd->clear_error(); // if errors from rollback thd->clear_error(); // if errors from rollback
...@@ -2376,7 +2389,14 @@ bool dispatch_command(enum enum_server_command command, THD *thd, ...@@ -2376,7 +2389,14 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
} }
dispatch_end: dispatch_end:
do_end_of_statement= true;
#ifdef WITH_WSREP #ifdef WITH_WSREP
/*
Next test should really be WSREP(thd), but that causes a failure when doing
'set WSREP_ON=0'
*/
if (unlikely(wsrep_service_started))
{
/* /*
BF aborted before sending response back to client BF aborted before sending response back to client
*/ */
...@@ -2411,11 +2431,10 @@ bool dispatch_command(enum enum_server_command command, THD *thd, ...@@ -2411,11 +2431,10 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
do_end_of_statement= thd_is_connection_alive(thd); do_end_of_statement= thd_is_connection_alive(thd);
mysql_mutex_unlock(&thd->LOCK_thd_kill); mysql_mutex_unlock(&thd->LOCK_thd_kill);
} }
else }
do_end_of_statement= true;
#endif /* WITH_WSREP */ #endif /* WITH_WSREP */
if (do_end_of_statement) if (do_end_of_statement)
{ {
DBUG_ASSERT(thd->derived_tables == NULL && DBUG_ASSERT(thd->derived_tables == NULL &&
......
...@@ -99,6 +99,7 @@ my_bool wsrep_desync; // De(re)synchronize the node fr ...@@ -99,6 +99,7 @@ my_bool wsrep_desync; // De(re)synchronize the node fr
my_bool wsrep_strict_ddl; // Reject DDL to my_bool wsrep_strict_ddl; // Reject DDL to
// effected tables not // effected tables not
// supporting Galera replication // supporting Galera replication
bool wsrep_service_started; // If Galera was initialized
long wsrep_slave_threads; // No. of slave appliers threads long wsrep_slave_threads; // No. of slave appliers threads
ulong wsrep_retry_autocommit; // Retry aborted autocommit trx ulong wsrep_retry_autocommit; // Retry aborted autocommit trx
ulong wsrep_max_ws_size; // Max allowed ws (RBR buffer) size ulong wsrep_max_ws_size; // Max allowed ws (RBR buffer) size
...@@ -831,10 +832,6 @@ int wsrep_init() ...@@ -831,10 +832,6 @@ int wsrep_init()
return err; return err;
} }
global_system_variables.wsrep_on= 1;
WSREP_ON_= wsrep_provider && strcmp(wsrep_provider, WSREP_NONE);
if (wsrep_gtid_mode && opt_bin_log && !opt_log_slave_updates) if (wsrep_gtid_mode && opt_bin_log && !opt_log_slave_updates)
{ {
WSREP_ERROR("Option --log-slave-updates is required if " WSREP_ERROR("Option --log-slave-updates is required if "
...@@ -866,6 +863,11 @@ int wsrep_init() ...@@ -866,6 +863,11 @@ int wsrep_init()
return 1; return 1;
} }
/* Now WSREP is fully initialized */
global_system_variables.wsrep_on= 1;
WSREP_ON_= wsrep_provider && strcmp(wsrep_provider, WSREP_NONE);
wsrep_service_started= 1;
wsrep_init_provider_status_variables(); wsrep_init_provider_status_variables();
wsrep_capabilities_export(Wsrep_server_state::instance().provider().capabilities(), wsrep_capabilities_export(Wsrep_server_state::instance().provider().capabilities(),
&wsrep_provider_capabilities); &wsrep_provider_capabilities);
...@@ -1162,7 +1164,9 @@ bool wsrep_start_replication() ...@@ -1162,7 +1164,9 @@ bool wsrep_start_replication()
bool wsrep_must_sync_wait (THD* thd, uint mask) bool wsrep_must_sync_wait (THD* thd, uint mask)
{ {
bool ret; bool ret= 0;
if (thd->variables.wsrep_on)
{
mysql_mutex_lock(&thd->LOCK_thd_data); mysql_mutex_lock(&thd->LOCK_thd_data);
ret= (thd->variables.wsrep_sync_wait & mask) && ret= (thd->variables.wsrep_sync_wait & mask) &&
thd->wsrep_client_thread && thd->wsrep_client_thread &&
...@@ -1174,6 +1178,7 @@ bool wsrep_must_sync_wait (THD* thd, uint mask) ...@@ -1174,6 +1178,7 @@ bool wsrep_must_sync_wait (THD* thd, uint mask)
wsrep::transaction::s_replaying && wsrep::transaction::s_replaying &&
thd->wsrep_cs().sync_wait_gtid().is_undefined(); thd->wsrep_cs().sync_wait_gtid().is_undefined();
mysql_mutex_unlock(&thd->LOCK_thd_data); mysql_mutex_unlock(&thd->LOCK_thd_data);
}
return ret; return ret;
} }
......
...@@ -186,6 +186,7 @@ void wsrep_recover_sr_from_storage(THD *); ...@@ -186,6 +186,7 @@ void wsrep_recover_sr_from_storage(THD *);
// Other wsrep global variables // Other wsrep global variables
extern my_bool wsrep_inited; // whether wsrep is initialized ? extern my_bool wsrep_inited; // whether wsrep is initialized ?
extern bool wsrep_service_started;
extern "C" void wsrep_fire_rollbacker(THD *thd); extern "C" void wsrep_fire_rollbacker(THD *thd);
extern "C" uint32 wsrep_thd_wsrep_rand(THD *thd); extern "C" uint32 wsrep_thd_wsrep_rand(THD *thd);
......
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