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

Function start_slave

sql/sql_repl.cc:3889–4077  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3887*/
3888
3889int start_slave(THD* thd , Master_info* mi, bool net_report)
3890{
3891 int slave_errno= 0;
3892 int thread_mask;
3893 char master_info_file_tmp[FN_REFLEN];
3894 char relay_log_info_file_tmp[FN_REFLEN];
3895 DBUG_ENTER("start_slave");
3896
3897 if (check_global_access(thd, PRIV_STMT_START_SLAVE))
3898 DBUG_RETURN(-1);
3899
3900 create_logfile_name_with_suffix(master_info_file_tmp,
3901 sizeof(master_info_file_tmp),
3902 master_info_file, 0,
3903 &mi->cmp_connection_name);
3904 create_logfile_name_with_suffix(relay_log_info_file_tmp,
3905 sizeof(relay_log_info_file_tmp),
3906 relay_log_info_file, 0,
3907 &mi->cmp_connection_name);
3908
3909 mi->lock_slave_threads();
3910 if (mi->killed)
3911 {
3912 /* connection was deleted while we waited for lock_slave_threads */
3913 mi->unlock_slave_threads();
3914 my_error(WARN_NO_MASTER_INFO, MYF(0), (int) mi->connection_name.length,
3915 mi->connection_name.str);
3916 DBUG_RETURN(-1);
3917 }
3918
3919 // Get a mask of _stopped_ threads
3920 init_thread_mask(&thread_mask,mi,1 /* inverse */);
3921
3922 if (thd->lex->mi.gtid_pos_str.str)
3923 {
3924 if (thread_mask != (SLAVE_IO|SLAVE_SQL))
3925 {
3926 slave_errno= ER_SLAVE_WAS_RUNNING;
3927 goto err;
3928 }
3929 if (thd->lex->slave_thd_opt)
3930 {
3931 slave_errno= ER_BAD_SLAVE_UNTIL_COND;
3932 goto err;
3933 }
3934 if (mi->using_gtid == Master_info::USE_GTID_NO)
3935 {
3936 slave_errno= ER_UNTIL_REQUIRES_USING_GTID;
3937 goto err;
3938 }
3939 }
3940
3941 /*
3942 Below we will start all stopped threads. But if the user wants to
3943 start only one thread, do as if the other thread was running (as we
3944 don't want to touch the other thread), so set the bit to 0 for the
3945 other thread
3946 */

Callers 2

start_all_slavesMethod · 0.85
sql_parse.ccFile · 0.85

Calls 13

check_global_accessFunction · 0.85
my_errorFunction · 0.85
init_thread_maskFunction · 0.85
init_master_infoFunction · 0.85
my_messageFunction · 0.85
fn_extFunction · 0.85
push_warningFunction · 0.85
start_slave_threadsFunction · 0.85
lock_slave_threadsMethod · 0.80
unlock_slave_threadsMethod · 0.80
clear_until_conditionMethod · 0.80

Tested by

no test coverage detected