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

Function stop_slave

sql/sql_repl.cc:4095–4143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4093*/
4094
4095int stop_slave(THD* thd, Master_info* mi, bool net_report )
4096{
4097 int slave_errno;
4098 DBUG_ENTER("stop_slave");
4099 DBUG_PRINT("enter",("Connection: %s", mi->connection_name.str));
4100
4101 if (check_global_access(thd, PRIV_STMT_STOP_SLAVE))
4102 DBUG_RETURN(-1);
4103 THD_STAGE_INFO(thd, stage_killing_slave);
4104 int thread_mask;
4105 mi->lock_slave_threads();
4106 /*
4107 Get a mask of _running_ threads.
4108 We don't have to test for mi->killed as the thread_mask will take care
4109 of checking if threads exists
4110 */
4111 init_thread_mask(&thread_mask,mi,0 /* not inverse*/);
4112 /*
4113 Below we will stop all running threads.
4114 But if the user wants to stop only one thread, do as if the other thread
4115 was stopped (as we don't want to touch the other thread), so set the
4116 bit to 0 for the other thread
4117 */
4118 if (thd->lex->slave_thd_opt)
4119 thread_mask &= thd->lex->slave_thd_opt;
4120
4121 if (thread_mask)
4122 {
4123 slave_errno= terminate_slave_threads(mi,thread_mask, 0 /* get lock */);
4124 }
4125 else
4126 {
4127 //no error if both threads are already stopped, only a warning
4128 slave_errno= 0;
4129 push_warning(thd, Sql_condition::WARN_LEVEL_NOTE, ER_SLAVE_WAS_NOT_RUNNING,
4130 ER_THD(thd, ER_SLAVE_WAS_NOT_RUNNING));
4131 }
4132
4133 mi->unlock_slave_threads();
4134
4135 if (slave_errno)
4136 {
4137 if (net_report)
4138 my_message(slave_errno, ER_THD(thd, slave_errno), MYF(0));
4139 DBUG_RETURN(1);
4140 }
4141
4142 DBUG_RETURN(0);
4143}
4144
4145
4146/**

Callers 2

stop_all_slavesMethod · 0.85
sql_parse.ccFile · 0.85

Calls 7

check_global_accessFunction · 0.85
init_thread_maskFunction · 0.85
terminate_slave_threadsFunction · 0.85
push_warningFunction · 0.85
my_messageFunction · 0.85
lock_slave_threadsMethod · 0.80
unlock_slave_threadsMethod · 0.80

Tested by

no test coverage detected