MCPcopy Create free account
hub / github.com/MariaDB/server / init_slave

Function init_slave

sql/slave.cc:654–755  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

652/* Initialize slave structures */
653
654int init_slave()
655{
656 DBUG_ENTER("init_slave");
657 int error= 0;
658
659#ifdef HAVE_PSI_INTERFACE
660 init_slave_psi_keys();
661#endif
662
663 if (start_slave_deadlock_handler_thread())
664 return 1;
665
666 if (global_rpl_thread_pool.init(opt_slave_parallel_threads))
667 return 1;
668
669 slave_background_thread_gtid_loaded= false;
670 mysql_manager_submit(bg_rpl_load_gtid_slave_state, NULL);
671
672 // hijacking global_rpl_thread_pool cond here - it's only once on startup
673 mysql_mutex_lock(&global_rpl_thread_pool.LOCK_rpl_thread_pool);
674 while (!slave_background_thread_gtid_loaded)
675 mysql_cond_wait(&global_rpl_thread_pool.COND_rpl_thread_pool,
676 &global_rpl_thread_pool.LOCK_rpl_thread_pool);
677 mysql_mutex_unlock(&global_rpl_thread_pool.LOCK_rpl_thread_pool);
678
679 /*
680 This is called when mysqld starts. Before client connections are
681 accepted. However bootstrap may conflict with us if it does START SLAVE.
682 So it's safer to take the lock.
683 */
684
685 master_info_index= new Master_info_index;
686 if (!master_info_index || master_info_index->init_all_master_info())
687 {
688 sql_print_error("Failed to initialize multi master structures");
689 DBUG_RETURN(1);
690 }
691 if (!(active_mi= new Master_info(&default_master_connection_name,
692 relay_log_recovery)) ||
693 active_mi->error())
694 {
695 delete active_mi;
696 active_mi= 0;
697 sql_print_error("Failed to allocate memory for the Master Info structure");
698 goto err;
699 }
700
701 if (master_info_index->add_master_info(active_mi, FALSE))
702 {
703 delete active_mi;
704 active_mi= 0;
705 goto err;
706 }
707
708 /*
709 If master_host is not specified, try to read it from the master_info file.
710 If master_host is specified, create the master_info file if it doesn't
711 exists.

Callers 1

mysqld_mainFunction · 0.85

Calls 14

init_slave_psi_keysFunction · 0.85
mysql_manager_submitFunction · 0.85
init_master_infoFunction · 0.85
next_thread_idFunction · 0.85
start_slave_threadsFunction · 0.85
init_all_master_infoMethod · 0.80
add_master_infoMethod · 0.80
sql_print_errorFunction · 0.70
sql_print_informationFunction · 0.70
initMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected