YoushouldhavereceivedacopyoftheGNUGeneralPublicLicense alongwiththisprogram;ifnot,writetotheFreeSoftware
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */
if (access(fname,F_OK))
{ if (abort_if_no_master_info_file)
{
mysql_mutex_unlock(&mi->data_lock);
DBUG_RETURN(0);
} /* ifsomeoneremovedthefilefromunderneathourfeet,justclose theolddescriptorandre-createtheoldfile
*/ if (fd >= 0)
mysql_file_close(fd, MYF(MY_WME)); if ((fd= mysql_file_open(key_file_master_info,
fname, O_CREAT|O_RDWR|O_BINARY, MYF(MY_WME))) < 0 )
{
sql_print_error("Failed to create a new master info file (\
file '%s', errno %d)", fname, my_errno); goto err;
} if (init_io_cache(&mi->file, fd, IO_SIZE*2, READ_CACHE, 0L,0,
MYF(MY_WME)))
{
sql_print_error("Failed to create a cache on master info file (\
file '%s')", fname); goto err;
}
mi->fd = fd;
mi->clear_in_memory_info(false);
} else// file exists
{ if (fd >= 0)
reinit_io_cache(&mi->file, READ_CACHE, 0L,0,0); else
{ if ((fd= mysql_file_open(key_file_master_info,
fname, O_RDWR|O_BINARY, MYF(MY_WME))) < 0 )
{
sql_print_error("Failed to open the existing master info file (\
file '%s', errno %d)", fname, my_errno); goto err;
} if (init_io_cache(&mi->file, fd, IO_SIZE*2, READ_CACHE, 0L, 0, MYF(MY_WME)))
{
sql_print_error("Failed to create a cache on master info file (\
file '%s')", fname); goto err;
}
}
mi->fd = fd; if (mi->load_from_file()) goto errwithmsg;
#ifndef HAVE_OPENSSL if (mi->master_ssl)
sql_print_warning("SSL information in the master info file " "('%s') are ignored because this MySQL slave was " "compiled without SSL support.", fname); #endif/* HAVE_OPENSSL */
}
DBUG_PRINT("master_info",("log_file_name: %s position: %ld",
mi->master_log_name,
(ulong) mi->master_log_pos));
mi->rli.mi= mi; if (mi->rli.init(slave_info_fname)) goto err;
mi->inited = 1;
mi->rli.is_relay_log_recovery= FALSE; // now change cache READ -> WRITE - must do this before flush_master_info
reinit_io_cache(&mi->file, WRITE_CACHE, 0L, 0, 1); if (unlikely((error= MY_TEST(flush_master_info(mi, TRUE, TRUE)))))
sql_print_error("Failed to flush master info file");
mysql_mutex_unlock(&mi->data_lock);
DBUG_RETURN(error);
/* Ensure that we are not in reset_slave while this is done */
mi->lock_slave_threads();
terminate_slave_threads(mi,SLAVE_FORCE_ALL); /* We use 2 here instead of 1 just to make it easier when debugging */
mi->killed= 2;
end_master_info(mi);
end_relay_log_info(&mi->rli);
mi->unlock_slave_threads(); delete mi;
p= strmake(res_file_name, info_file, length); /* If not empty suffix and there is place left for some part of the suffix */ if (suffix->length != 0 && p <= res_file_name + length -1)
{ constchar *info_file_end= info_file + (p - res_file_name); constchar *ext= append ? info_file_end : fn_ext2(info_file);
size_t res_length, ext_pos, from_length;
uint errors;
/* Create null terminated string */
from_length= strmake(buff, suffix->str, suffix->length) - buff; /* Convert to characters usable in a file name */
res_length= strconvert(system_charset_info, buff, from_length,
&my_charset_filename, res, sizeof(res), &errors);
ext_pos= (size_t) (ext - info_file);
length-= (suffix->length - ext_pos); /* Leave place for extension */
p= res_file_name + ext_pos;
*p++= '-'; /* Add separator */
p= strmake(p, res, MY_MIN((size_t) (length - (p - res_file_name)),
res_length)); /* Add back extension. We have checked above that there is space for it */
strmov(p, ext);
}
}
dst_filter->get_do_db(&tmp); if (tmp.is_empty())
{
src_filter->get_do_db(&tmp); if (!tmp.is_empty())
dst_filter->set_do_db(tmp.ptr());
}
dst_filter->get_do_table(&tmp); if (tmp.is_empty())
{
src_filter->get_do_table(&tmp); if (!tmp.is_empty())
dst_filter->set_do_table(tmp.ptr());
}
dst_filter->get_ignore_db(&tmp); if (tmp.is_empty())
{
src_filter->get_ignore_db(&tmp); if (!tmp.is_empty())
dst_filter->set_ignore_db(tmp.ptr());
}
dst_filter->get_ignore_table(&tmp); if (tmp.is_empty())
{
src_filter->get_ignore_table(&tmp); if (!tmp.is_empty())
dst_filter->set_ignore_table(tmp.ptr());
}
dst_filter->get_wild_do_table(&tmp); if (tmp.is_empty())
{
src_filter->get_wild_do_table(&tmp); if (!tmp.is_empty())
dst_filter->set_wild_do_table(tmp.ptr());
}
dst_filter->get_wild_ignore_table(&tmp); if (tmp.is_empty())
{
src_filter->get_wild_ignore_table(&tmp); if (!tmp.is_empty())
dst_filter->set_wild_ignore_table(tmp.ptr());
}
dst_filter->get_rewrite_db(&tmp); if (tmp.is_empty())
{
src_filter->get_rewrite_db(&tmp); if (!tmp.is_empty())
dst_filter->set_rewrite_db(tmp.ptr());
}
}
/* Load All Master_info from master.info.index File *RETURN: *0-AllSuccess *1-AllFail *2-SomeSuccess,SomeFail
*/
bool Master_info_index::init_all_master_info()
{ int thread_mask; int err_num= 0, succ_num= 0; // The number of success read Master_info
Info_file::String_value<MAX_CONNECTION_NAME+1> sign;
File index_file_nr;
THD *thd;
DBUG_ENTER("init_all_master_info");
mi->lock_slave_threads(); if (init_master_info(mi, buf_master_info_file, buf_relay_log_info_file, 0, thread_mask))
{
err_num++;
sql_print_error("Initialized Master_info from '%s' failed",
buf_master_info_file); if (!master_info_index->get_master_info(&connection_name,
Sql_condition::WARN_LEVEL_NOTE))
{ /* Master_info is not in HASH; Add it */ if (master_info_index->add_master_info(mi, FALSE)) goto error;
succ_num++;
mi->unlock_slave_threads();
} else
{ /* Master_info already in HASH */
sql_print_error(ER_DEFAULT(ER_CONNECTION_ALREADY_EXISTS),
(int) connection_name.length, connection_name.str,
(int) connection_name.length, connection_name.str);
mi->unlock_slave_threads(); delete mi;
} continue;
} else
{ /* Initialization of Master_info succeeded. Add it to HASH */ if (global_system_variables.log_warnings > 1)
sql_print_information("Initialized Master_info from '%s'",
buf_master_info_file); if (master_info_index->get_master_info(&connection_name,
Sql_condition::WARN_LEVEL_NOTE))
{ /* Master_info was already registered */
sql_print_error(ER_DEFAULT(ER_CONNECTION_ALREADY_EXISTS),
(int) connection_name.length, connection_name.str,
(int) connection_name.length, connection_name.str);
mi->unlock_slave_threads(); delete mi; continue;
}
/* Master_info was not registered; add it */ if (master_info_index->add_master_info(mi, FALSE)) goto error;
succ_num++;
if (!opt_skip_slave_start)
{ if (start_slave_threads(current_thd, 1/* need mutex */, 1/* wait for start*/,
mi,
buf_master_info_file,
buf_relay_log_info_file,
SLAVE_IO | SLAVE_SQL))
{
sql_print_error("Failed to create slave threads for connection '%.*s'",
(int) connection_name.length,
connection_name.str); continue;
} if (global_system_variables.log_warnings)
sql_print_information("Started replication for '%.*s'",
(int) connection_name.length,
connection_name.str);
}
mi->unlock_slave_threads();
}
}
thd->reset_globals(); delete thd;
if (!err_num) // No Error on read Master_info
{ if (global_system_variables.log_warnings > 2)
sql_print_information("Reading of all Master_info entries succeeded");
DBUG_RETURN(0);
}
if (succ_num) // Have some Error and some Success
sql_print_warning("Reading of some Master_info entries failed"); else
sql_print_error("Reading of all Master_info entries failed!");
DBUG_RETURN(1);
void Master_info::release()
{
mysql_mutex_lock(&sleep_lock); if (!--users && killed)
{ /* Signal ~Master_info that it's ok to now free it */
mysql_cond_signal(&sleep_cond);
}
mysql_mutex_unlock(&sleep_lock);
}
/* Get full host and port name */ if ((mi= master_info_index->get_master_info(name_arg,
Sql_condition::WARN_LEVEL_NOTE)))
{ if (!host)
host= mi->host; if (!port)
port= mi->port;
} if (!host || !port)
DBUG_RETURN(FALSE); // Not comparable yet
for (uint i= 0; i < master_info_hash.records; ++i)
{
Master_info *tmp_mi;
tmp_mi= (Master_info *) my_hash_element(&master_info_hash, i); if (tmp_mi == mi) continue; // Current connection if (!strcasecmp(host, tmp_mi->host) && port == tmp_mi->port)
{
my_error(ER_CONNECTION_ALREADY_EXISTS, MYF(0),
(int) name_arg->length,
name_arg->str,
(int) tmp_mi->connection_name.length,
tmp_mi->connection_name.str);
DBUG_RETURN(TRUE);
}
}
DBUG_RETURN(FALSE);
}
/* Add a Master_info class to Hash Table */ bool Master_info_index::add_master_info(Master_info *mi, bool write_to_file)
{ /* Wehavetoprotectagainstshutdowntoensurewearenotcalling my_hash_insert()whilemy_hash_free()isinprogress
*/ if (unlikely(abort_loop) ||
!my_hash_insert(&master_info_hash, (uchar*) mi))
{ if (global_system_variables.log_warnings > 2)
sql_print_information("Added new Master_info '%.*s' to hash table",
(int) mi->connection_name.length,
mi->connection_name.str); if (write_to_file) return write_master_name_to_index_file(&mi->connection_name, 1); returnFALSE;
}
/* Impossible error (EOM) ? */
sql_print_error("Adding new entry '%.*s' to master_info failed",
(int) mi->connection_name.length,
mi->connection_name.str); returnTRUE;
}
if (!do_list_empty && !ignore_list_empty)
{
sql_print_error("Both DO_DOMAIN_IDS & IGNORE_DOMAIN_IDS lists can't be " "non-empty at the same time"); returntrue;
}
if (!using_gtid &&
(!do_list_empty || !ignore_list_empty))
{
sql_print_error("DO_DOMAIN_IDS or IGNORE_DOMAIN_IDS lists can't be " "non-empty in non-GTID mode (MASTER_USE_GTID=no)"); returntrue;
}
if (do_ids)
update_change_master_ids(do_ids, &m_domain_ids[DO_DOMAIN_IDS]);
if (ignore_ids)
update_change_master_ids(ignore_ids, &m_domain_ids[IGNORE_DOMAIN_IDS]);
m_filter= false;
returnfalse;
}
void Domain_id_filter::store_ids(Field ***field)
{ for (int i= DO_DOMAIN_IDS; i <= IGNORE_DOMAIN_IDS; i ++)
{
field_store_ids(*((*field)++), &m_domain_ids[i]);
}
}
if (unlikely(error))
{
result= true; break;
} /* Restart from first element as master_info_hash may have changed */
i= 0; continue;
}
mysql_mutex_unlock(&LOCK_active_mi);
DBUG_RETURN(result);
}
/* Ifserver'sdefaultcharsetisnotsupported(likeutf16,utf32)asclient charset,thensetclientcharsetto'latin1'(defaultclientcharset).
*/ if (is_supported_parser_charset(default_charset_info))
mysql_options(mysql, MYSQL_SET_CHARSET_NAME, default_charset_info->cs_name.str); else
{
sql_print_information("'%s' can not be used as client character set. " "'%s' will be used as default client character set " "while connecting to master.",
default_charset_info->cs_name.str,
default_client_charset_info->cs_name.str);
mysql_options(mysql, MYSQL_SET_CHARSET_NAME,
default_client_charset_info->cs_name.str);
}
/* Set MYSQL_PLUGIN_DIR in case master asks for an external authentication plugin */ if (opt_plugin_dir_ptr && *opt_plugin_dir_ptr)
mysql_options(mysql, MYSQL_PLUGIN_DIR, opt_plugin_dir_ptr);
}
#endif/* HAVE_REPLICATION */
Messung V0.5 in Prozent
¤ 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.0.32Bemerkung:
(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.