mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Performance improvements to test if WSREP if active
This commit is contained in:
@ -1291,7 +1291,7 @@ bool do_command(THD *thd)
|
||||
Aborted by background rollbacker thread.
|
||||
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();
|
||||
WSREP_LOG_THD(thd, "enter found BF aborted");
|
||||
@ -1368,6 +1368,7 @@ out:
|
||||
if (packet_length != packet_error)
|
||||
{
|
||||
/* there was a command to process, and before_command() has been called */
|
||||
if (unlikely(wsrep_service_started))
|
||||
wsrep_after_command_after_result(thd);
|
||||
}
|
||||
#endif /* WITH_WSREP */
|
||||
@ -1659,14 +1660,20 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
{
|
||||
thd->status_var.com_other++;
|
||||
#ifdef WITH_WSREP
|
||||
if (unlikely(wsrep_service_started))
|
||||
{
|
||||
wsrep_after_command_ignore_result(thd);
|
||||
wsrep_close(thd);
|
||||
}
|
||||
#endif /* WITH_WSREP */
|
||||
thd->change_user();
|
||||
thd->clear_error(); // if errors from rollback
|
||||
#ifdef WITH_WSREP
|
||||
if (unlikely(wsrep_service_started))
|
||||
{
|
||||
wsrep_open(thd);
|
||||
wsrep_before_command(thd);
|
||||
}
|
||||
#endif /* WITH_WSREP */
|
||||
/* Restore original charset from client authentication packet.*/
|
||||
if(thd->org_charset)
|
||||
@ -1680,13 +1687,19 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
status_var_increment(thd->status_var.com_other);
|
||||
|
||||
#ifdef WITH_WSREP
|
||||
if (unlikely(wsrep_service_started))
|
||||
{
|
||||
wsrep_after_command_ignore_result(thd);
|
||||
wsrep_close(thd);
|
||||
}
|
||||
#endif /* WITH_WSREP */
|
||||
thd->change_user();
|
||||
#ifdef WITH_WSREP
|
||||
if (unlikely(wsrep_service_started))
|
||||
{
|
||||
wsrep_open(thd);
|
||||
wsrep_before_command(thd);
|
||||
}
|
||||
#endif /* WITH_WSREP */
|
||||
thd->clear_error(); // if errors from rollback
|
||||
|
||||
@ -2376,7 +2389,14 @@ com_multi_end:
|
||||
}
|
||||
|
||||
dispatch_end:
|
||||
do_end_of_statement= true;
|
||||
#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
|
||||
*/
|
||||
@ -2411,11 +2431,10 @@ dispatch_end:
|
||||
do_end_of_statement= thd_is_connection_alive(thd);
|
||||
mysql_mutex_unlock(&thd->LOCK_thd_kill);
|
||||
}
|
||||
else
|
||||
do_end_of_statement= true;
|
||||
|
||||
}
|
||||
#endif /* WITH_WSREP */
|
||||
|
||||
|
||||
if (do_end_of_statement)
|
||||
{
|
||||
DBUG_ASSERT(thd->derived_tables == NULL &&
|
||||
|
@ -99,6 +99,7 @@ my_bool wsrep_desync; // De(re)synchronize the node fr
|
||||
my_bool wsrep_strict_ddl; // Reject DDL to
|
||||
// effected tables not
|
||||
// supporting Galera replication
|
||||
bool wsrep_service_started; // If Galera was initialized
|
||||
long wsrep_slave_threads; // No. of slave appliers threads
|
||||
ulong wsrep_retry_autocommit; // Retry aborted autocommit trx
|
||||
ulong wsrep_max_ws_size; // Max allowed ws (RBR buffer) size
|
||||
@ -831,10 +832,6 @@ int wsrep_init()
|
||||
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)
|
||||
{
|
||||
WSREP_ERROR("Option --log-slave-updates is required if "
|
||||
@ -866,6 +863,11 @@ int wsrep_init()
|
||||
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_capabilities_export(Wsrep_server_state::instance().provider().capabilities(),
|
||||
&wsrep_provider_capabilities);
|
||||
@ -1162,7 +1164,9 @@ bool wsrep_start_replication()
|
||||
|
||||
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);
|
||||
ret= (thd->variables.wsrep_sync_wait & mask) &&
|
||||
thd->wsrep_client_thread &&
|
||||
@ -1174,6 +1178,7 @@ bool wsrep_must_sync_wait (THD* thd, uint mask)
|
||||
wsrep::transaction::s_replaying &&
|
||||
thd->wsrep_cs().sync_wait_gtid().is_undefined();
|
||||
mysql_mutex_unlock(&thd->LOCK_thd_data);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -186,6 +186,7 @@ void wsrep_recover_sr_from_storage(THD *);
|
||||
|
||||
// Other wsrep global variables
|
||||
extern my_bool wsrep_inited; // whether wsrep is initialized ?
|
||||
extern bool wsrep_service_started;
|
||||
|
||||
extern "C" void wsrep_fire_rollbacker(THD *thd);
|
||||
extern "C" uint32 wsrep_thd_wsrep_rand(THD *thd);
|
||||
|
Reference in New Issue
Block a user