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

Function handle_slave_sql

sql/slave.cc:5157–5736  ·  view source on GitHub ↗

Slave SQL thread entry point. @param arg Pointer to Relay_log_info object that holds information for the SQL thread. @return Always 0. */

Source from the content-addressed store, hash-verified

5155 @return Always 0.
5156*/
5157pthread_handler_t handle_slave_sql(void *arg)
5158{
5159 THD *thd; /* needs to be first for thread_stack */
5160 char saved_log_name[FN_REFLEN];
5161 char saved_master_log_name[FN_REFLEN];
5162 bool thd_initialized= 0;
5163 my_off_t UNINIT_VAR(saved_log_pos);
5164 my_off_t UNINIT_VAR(saved_master_log_pos);
5165 String saved_skip_gtid_pos;
5166 my_off_t saved_skip= 0;
5167 Master_info *mi= ((Master_info*)arg);
5168 Relay_log_info* rli = &mi->rli;
5169 my_bool wsrep_node_dropped __attribute__((unused)) = FALSE;
5170 const char *errmsg;
5171 rpl_group_info *serial_rgi;
5172 rpl_sql_thread_info sql_info(mi->rpl_filter);
5173
5174 // needs to call my_thread_init(), otherwise we get a coredump in DBUG_ stuff
5175 my_thread_init();
5176 my_thread_set_name("slave_sql");
5177 DBUG_ENTER("handle_slave_sql");
5178
5179#ifdef WITH_WSREP
5180 wsrep_restart_point:
5181#endif
5182
5183 serial_rgi= new rpl_group_info(rli);
5184 thd = new THD(next_thread_id()); // note that contructor of THD uses DBUG_ !
5185 thd->thread_stack= (void*) &thd; // Big stack, remember where our stack is
5186 thd->system_thread_info.rpl_sql_info= &sql_info;
5187
5188 DBUG_ASSERT(rli->inited);
5189 DBUG_ASSERT(rli->mi == mi);
5190
5191 /*
5192 Reset errors for a clean start (otherwise, if the master is idle, the SQL
5193 thread may execute no Query_log_event, so the error will remain even
5194 though there's no problem anymore). Do not reset the master timestamp
5195 (imagine the slave has caught everything, the STOP SLAVE and START SLAVE:
5196 as we are not sure that we are going to receive a query, we want to
5197 remember the last master timestamp (to say how many seconds behind we are
5198 now.
5199 But the master timestamp is reset by RESET SLAVE & CHANGE MASTER.
5200 */
5201 rli->clear_error();
5202
5203 mysql_mutex_lock(&rli->run_lock);
5204 DBUG_ASSERT(!rli->slave_running);
5205 errmsg= 0;
5206#ifndef DBUG_OFF
5207 rli->events_till_abort = abort_slave_event_count;
5208#endif
5209
5210 /*
5211 THD for the sql driver thd. In parallel replication this is the thread
5212 that reads things from the relay log and calls rpl_parallel::do_event()
5213 to execute queries.
5214

Callers

nothing calls this directly

Calls 15

my_thread_initFunction · 0.85
my_thread_set_nameFunction · 0.85
next_thread_idFunction · 0.85
init_slave_threadFunction · 0.85
init_relay_log_posFunction · 0.85
my_b_tellFunction · 0.85
rpl_append_gtid_stateFunction · 0.85
check_temp_dirFunction · 0.85
execute_init_commandFunction · 0.85

Tested by

no test coverage detected