YoushouldhavereceivedacopyoftheGNUGeneralPublicLicense alongwiththisprogram;ifnot,writetotheFreeSoftware
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
// If wsrep has not been inited we need to do it now if (!wsrep_inited &&
saved_wsrep_on &&
wsrep_provider &&
*wsrep_provider &&
strcasecmp(wsrep_provider, WSREP_NONE))
{ // wsrep_init() rewrites provide if it fails char* tmp= strdup(wsrep_provider);
mysql_mutex_unlock(&LOCK_global_system_variables);
if (new_wsrep_on)
{ if (!WSREP_PROVIDER_EXISTS)
{
my_message(ER_WRONG_ARGUMENTS, "WSREP (galera) can't be enabled " "if the wsrep_provider is unset or set to 'none'", MYF(0)); returntrue;
}
if (var->type == OPT_SESSION &&
!global_system_variables.wsrep_on)
{
my_message(ER_WRONG_ARGUMENTS, "Can't enable @@session.wsrep_on, " "while @@global.wsrep_on is disabled", MYF(0)); returntrue;
}
}
if (thd->in_active_multi_stmt_transaction())
{
my_error(ER_CANT_DO_THIS_DURING_AN_TRANSACTION, MYF(0)); returntrue;
}
// If both are same as WSREP_START_POSITION_ZERO just set local if (!strcmp(start_pos_buf, WSREP_START_POSITION_ZERO) &&
!strcmp(wsrep_start_position, WSREP_START_POSITION_ZERO)) goto set; else
WSREP_INFO("SST setting local position to %s current %s", start_pos_buf, wsrep_start_position);
if (sst) return (wsrep_sst_received (thd, uuid, seqno, NULL, 0));
WSREP_DEBUG("SST wsrep_start_position check for new position %s old %s",
start_pos_buf, wsrep_start_position);
// Verify the format. if (wsrep_start_position_verify(start_pos_buf)) returntrue;
// Give error if position is updated when wsrep is not enabled or // provider is not loaded. if ((!WSREP_ON || !Wsrep_server_state::instance().is_provider_loaded())
&& strcmp(start_pos_buf, WSREP_START_POSITION_ZERO))
{
push_warning(thd, Sql_condition::WARN_LEVEL_WARN,
ER_WRONG_VALUE_FOR_VAR, "Cannot set 'wsrep_start_position' because " "wsrep is switched off or provider is not loaded"); goto err;
}
bool wsrep_start_position_update (sys_var *self, THD* thd, enum_var_type type)
{ // Print a confirmation that wsrep_start_position has been updated.
WSREP_INFO ("wsrep_start_position set to '%s'", wsrep_start_position); returnfalse;
}
bool wsrep_start_position_init (constchar* val)
{ if (NULL == val || wsrep_start_position_verify (val))
{
WSREP_ERROR("Bad initial value for wsrep_start_position: %s",
(val ? val : "")); returntrue;
}
if (wsrep_set_local_position (NULL, val, strlen(val), false))
{
WSREP_ERROR("Failed to set initial wsep_start_position: %s", val); returntrue;
}
/* stop replication is heavy operation, and includes closing all client connections.ClosingclientsmayneedtogetLOCK_global_system_variables atleastinMariaDB.
/* provider status variables are allocated in provider library andneedtofreedhere,otherwiseadanglingreferenceto wsrep_status_varswouldremaininTHD
*/
wsrep_free_status(thd);
// we sure don't want to use old address with new provider
wsrep_cluster_address_init(NULL);
wsrep_provider_options_init(NULL); if (!rcode)
refresh_provider_options();
bool wsrep_reject_queries_update(sys_var *self, THD* thd, enum_var_type type)
{ switch (wsrep_reject_queries) { case WSREP_REJECT_NONE:
WSREP_INFO("Allowing client queries due to manual setting"); break; case WSREP_REJECT_ALL:
WSREP_INFO("Rejecting client queries due to manual setting"); break; case WSREP_REJECT_ALL_KILL: /* close all client connections, but this one */
wsrep_close_client_connections(FALSE, thd);
WSREP_INFO("Rejecting client queries and killing connections due to manual setting"); break; default:
WSREP_INFO("Unknown value for wsrep_reject_queries: %lu",
wsrep_reject_queries); returntrue;
} returnfalse;
}
bool wsrep_debug_update(sys_var *self, THD* thd, enum_var_type type)
{ // Give warnings if wsrep_debug is set and wsrep is disabled or // provider is not loaded, it will not have any effect if ((!WSREP_ON || !Wsrep_server_state::instance().is_provider_loaded())
&& wsrep_debug)
{
push_warning(thd, Sql_condition::WARN_LEVEL_WARN,
ER_WRONG_VALUE_FOR_VAR, "Setting 'wsrep_debug' has no effect because " "wsrep is switched off");
wsrep_debug= 0;
} else
Wsrep_server_state::instance().debug_log_level(wsrep_debug);
staticint wsrep_cluster_address_verify (constchar* cluster_address_str)
{ /* There is no predefined address format, it depends on provider. */ return0;
}
bool wsrep_cluster_address_update (sys_var *self, THD* thd, enum_var_type type)
{ if (!Wsrep_server_state::instance().is_provider_loaded())
{
WSREP_INFO("WSREP (galera) provider is not loaded, can't re(start) replication."); returnfalse;
}
/* stop replication is heavy operation, and includes closing all client connections.ClosingclientsmayneedtogetLOCK_global_system_variables atleastinMariaDB.
*/ char *tmp= my_strdup(PSI_INSTRUMENT_ME, wsrep_cluster_address, MYF(MY_WME));
WSREP_DEBUG("wsrep_cluster_address_update: %s", wsrep_cluster_address);
mysql_mutex_unlock(&LOCK_global_system_variables);
if (wsrep_slave_count_change > 0)
{
WSREP_DEBUG("Creating %d applier threads, total %ld", wsrep_slave_count_change, wsrep_slave_threads);
wsrep_thread_create_failed.store(false, std::memory_order_relaxed);
res= wsrep_create_appliers(wsrep_slave_count_change, true);
mysql_mutex_unlock(&LOCK_global_system_variables);
mysql_mutex_unlock(&LOCK_wsrep_slave_threads); // Thread creation and execution is asynchronous, therefore we need // wait them to be started or error produced while (wsrep_running_applier_threads != (ulong)wsrep_slave_threads &&
!wsrep_thread_create_failed.load(std::memory_order_relaxed))
{
my_sleep(1000);
}
mysql_mutex_lock(&LOCK_global_system_variables);
if (wsrep_thread_create_failed.load(std::memory_order_relaxed)) {
wsrep_slave_threads= wsrep_running_applier_threads; returntrue;
}
if (new_trx_fragment_size)
{ // Give error if wsrep_trx_fragment_size is set and wsrep is disabled or // provider is not loaded if (!WSREP(thd) || !Wsrep_server_state::instance().is_provider_loaded())
{
push_warning (thd, Sql_condition::WARN_LEVEL_WARN,
ER_WRONG_VALUE_FOR_VAR, "Cannot set 'wsrep_trx_fragment_size' to a value other than " "0 because wsrep is switched off."); returntrue;
}
if (!wsrep_provider_is_SR_capable())
{
push_warning (thd, Sql_condition::WARN_LEVEL_WARN,
ER_WRONG_VALUE_FOR_VAR, "Cannot set 'wsrep_trx_fragment_size' to a value other than " "0 because the wsrep_provider does not support streaming " "replication."); returntrue;
}
if (wsrep_protocol_version < 4)
{
push_warning (thd, Sql_condition::WARN_LEVEL_WARN,
ER_WRONG_VALUE_FOR_VAR, "Cannot set 'wsrep_trx_fragment_size' to a value other than " "0 because cluster is not yet operating in Galera 4 mode."); returntrue;
}
if (!ha_table_exists(thd, &WSREP_LEX_SCHEMA, &WSREP_LEX_STREAMING))
{
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_WRONG_VALUE_FOR_VAR, "Cannot set 'wsrep_trx_fragment_size' to a value other than " "0 because streaming table %s.%s does not exists.",
WSREP_LEX_SCHEMA.str, WSREP_LEX_STREAMING.str); returntrue;
}
}
bool wsrep_trx_fragment_unit_check (sys_var *self, THD* thd, set_var* var)
{
uint new_trx_fragment_unit= (uint)var->save_result.ulonglong_value; // Do not allow setting fragment unit anything else than // default if galera is not enabled and streaming replication // table does not exists. if (thd->variables.wsrep_trx_fragment_size ||
new_trx_fragment_unit != WSREP_FRAG_BYTES)
{ // Give error if wsrep_trx_fragment_unit is set and wsrep is disabled or // provider is not loaded if (!WSREP_ON || !Wsrep_server_state::instance().is_provider_loaded())
{
push_warning (thd, Sql_condition::WARN_LEVEL_WARN,
ER_WRONG_VALUE_FOR_VAR, "Cannot set 'wsrep_trx_fragment_unit' because " "wsrep is switched off"); returntrue;
}
if (!ha_table_exists(thd, &WSREP_LEX_SCHEMA, &WSREP_LEX_STREAMING))
{
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_WRONG_VALUE_FOR_VAR, "Cannot set 'wsrep_trx_fragment_unit' " "because streaming table %s.%s does not exists.",
WSREP_LEX_SCHEMA.str, WSREP_LEX_STREAMING.str); returntrue;
}
} returnfalse;
}
int wsrep_show_status (THD *thd, SHOW_VAR *var, void *,
system_status_var *, enum_var_type)
{ /* Note that we should allow show status like 'wsrep%' even
when WSREP(thd) is false. */ if (WSREP_ON)
{
export_wsrep_status_to_mysql(thd);
var->type= SHOW_ARRAY;
var->value= (char *) &mysql_status_vars;
} else
{
var->type= SHOW_CHAR;
var->value= (char*) "0";
} return0;
}
if (!WSREP_ON)
{
my_message(ER_WRONG_ARGUMENTS, "WSREP (galera) not started", MYF(0)); returntrue;
}
if (new_slave_threads &&
Wsrep_server_state::instance().state() == wsrep::server_state::s_disconnected)
{
push_warning(thd, Sql_condition::WARN_LEVEL_WARN,
ER_WRONG_VALUE_FOR_VAR, "Cannot set 'wsrep_slave_threads' because " "wsrep is disconnected"); returntrue;
}
// Default 0 is always allowed if (max_rows == 0) returnfalse;
// Note that we allow changing this even when WSREP is not on if (thd->wsrep_trx().active())
{
my_message(ER_WRONG_ARGUMENTS, "WSREP transaction is active", MYF(0)); returntrue;
} returnfalse;
}
/** Function is used to check if user given sst temporary directory isvalid.Functionallowsnullptroremptystringi.e.nodirectory given.Ifsomethingrealisgivenitmustbeanpaththatexists, shortenough,pathmustbeadirectoryanditmustnotbe sameasdatadir.Ifproperpathwasnotgivenactualused parametervalueremainsasnullptr.Ifproperpathwasgiven
it is copied to wsrep_sst_tmp_dir_real and used on SST. */ void wsrep_sst_tmp_dir_check(void)
{ if (wsrep_sst_tmp_dir == nullptr || strlen(wsrep_sst_tmp_dir) == 0) return; // DEFAULT is ok
if (strlen(wsrep_sst_tmp_dir) >= FN_REFLEN)
{
WSREP_ERROR("Option --wsrep-sst-tmp-dir value %s is too long", wsrep_sst_tmp_dir); return;
}
struct stat statinfo; int ret = stat(wsrep_sst_tmp_dir, &statinfo);
if (!ret)
{ /* path exists, ok */
} else { /* path does not exist */
WSREP_WARN("SST temporary path %s does not exists, path not used.",
wsrep_sst_tmp_dir); return;
}
if (!S_ISDIR(statinfo.st_mode))
{
WSREP_WARN("SST temporary path %s is not a directory, path not used.",
wsrep_sst_tmp_dir); return;
}
/* If path is almost same, do not allow it. */ struct stat datadir_stat; if (stat(mysql_real_data_home_ptr, &datadir_stat) == 0)
{ if (statinfo.st_dev == datadir_stat.st_dev &&
statinfo.st_ino == datadir_stat.st_ino)
{
WSREP_WARN("SST temporary path %s is same prefix as datadir %s, path not used.",
wsrep_sst_tmp_dir, mysql_real_data_home_ptr); return;
}
}
wsrep_sst_tmp_dir_real= my_strdup(PSI_INSTRUMENT_ME, wsrep_sst_tmp_dir, MYF(0)); if (wsrep_sst_tmp_dir_real)
WSREP_INFO("SST temporary path set to %s", wsrep_sst_tmp_dir_real);
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.5 Sekunden
(vorverarbeitet am 2026-10-08)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.