| 1305 | */ |
| 1306 | |
| 1307 | int start_slave_threads(THD *thd, |
| 1308 | bool need_slave_mutex, bool wait_for_start, |
| 1309 | Master_info* mi, const char* master_info_fname, |
| 1310 | const char* slave_info_fname, int thread_mask) |
| 1311 | { |
| 1312 | mysql_mutex_t *lock_io=0, *lock_sql=0, *lock_cond_io=0, *lock_cond_sql=0; |
| 1313 | mysql_cond_t* cond_io=0, *cond_sql=0; |
| 1314 | int error=0; |
| 1315 | const char *errmsg; |
| 1316 | DBUG_ENTER("start_slave_threads"); |
| 1317 | |
| 1318 | if (need_slave_mutex) |
| 1319 | { |
| 1320 | lock_io = &mi->run_lock; |
| 1321 | lock_sql = &mi->rli.run_lock; |
| 1322 | } |
| 1323 | if (wait_for_start) |
| 1324 | { |
| 1325 | cond_io = &mi->start_cond; |
| 1326 | cond_sql = &mi->rli.start_cond; |
| 1327 | lock_cond_io = &mi->run_lock; |
| 1328 | lock_cond_sql = &mi->rli.run_lock; |
| 1329 | } |
| 1330 | |
| 1331 | /* |
| 1332 | If we are using GTID and both SQL and IO threads are stopped, then get |
| 1333 | rid of all relay logs. |
| 1334 | |
| 1335 | Relay logs are not very useful when using GTID, except as a buffer |
| 1336 | between the fetch in the IO thread and the apply in SQL thread. However |
| 1337 | while one of the threads is running, they are in use and cannot be |
| 1338 | removed. |
| 1339 | */ |
| 1340 | if (mi->using_gtid != Master_info::USE_GTID_NO && |
| 1341 | !mi->slave_running && !mi->rli.slave_running) |
| 1342 | { |
| 1343 | /* |
| 1344 | purge_relay_logs() clears the mi->rli.group_master_log_pos. |
| 1345 | So save and restore them, like we do in CHANGE MASTER. |
| 1346 | (We are not going to use them for GTID, but it might be worth to |
| 1347 | keep them in case connection with GTID fails and user wants to go |
| 1348 | back and continue with previous old-style replication coordinates). |
| 1349 | */ |
| 1350 | mi->master_log_pos = MY_MAX(BIN_LOG_HEADER_SIZE, |
| 1351 | mi->rli.group_master_log_pos); |
| 1352 | strmake(mi->master_log_name, mi->rli.group_master_log_name, |
| 1353 | sizeof(mi->master_log_name)-1); |
| 1354 | purge_relay_logs(&mi->rli, thd, 0, &errmsg); |
| 1355 | mi->rli.group_master_log_pos= mi->master_log_pos; |
| 1356 | strmake(mi->rli.group_master_log_name, mi->master_log_name, |
| 1357 | sizeof(mi->rli.group_master_log_name)-1); |
| 1358 | |
| 1359 | error= rpl_load_gtid_state(&mi->gtid_current_pos, mi->using_gtid == |
| 1360 | Master_info::USE_GTID_CURRENT_POS); |
| 1361 | mi->events_queued_since_last_gtid= 0; |
| 1362 | mi->gtid_reconnect_event_skip_count= 0; |
| 1363 | |
| 1364 | mi->rli.restart_gtid_pos.reset(); |
no test coverage detected