全程gdb调试
gdb /usr/local/mysql/bin/mysqld
b mysqld_main
run --defaults-file=/data/jdb/mysql/my.cnf.3306 --user=mysql
- 开启binlog会检查server_id
//If the binlog is enabled, one needs to provide a server-id
if (opt_bin_log && !(server_id_supplied) )
{
sql_print_error("You have enabled the binary log, but you haven't provided "
"the mandatory server-id. Please refer to the proper "
"server start-up parameters documentation");
unireg_abort(MYSQLD_ABORT_EXIT);
}
- 检查data目录下是否有auto.cnf
/*
Each server should have one UUID. We will create it automatically, if it
does not exist.
*/
if (init_server_auto_options())
{
sql_print_error("Initialization of the server's UUID failed because it could"
" not be read from the auto.cnf file. If this is a new"
" server, the initialization failed because it was not"
" possible to generate a new UUID.");
unireg_abort(MYSQLD_ABORT_EXIT);
}
- 将uuid加入sid_map()中
/*
Add server_uuid to the sid_map. This must be done after
server_uuid has been initialized in init_server_auto_options and
after the binary log (and sid_map file) has been initialized in
init_server_components().
No error message is needed: init_sid_map() prints a message.
Strictly speaking, this is not currently needed when
opt_bin_log==0, since the variables that gtid_state->init
initializes are not currently used in that case. But we call it
regardless to avoid possible future bugs if gtid_state ever
needs to do anything else.
*/
global_sid_lock->wrlock();
int gtid_ret= gtid_state->init();
global_sid_lock->unlock();
if (gtid_ret)
unireg_abort(MYSQLD_ABORT_EXIT);
- 初始化gtid_state对象
// Initialize executed_gtids from mysql.gtid_executed table.
if (gtid_state->read_gtid_executed_from_table() == -1)