| 1341 | */ |
| 1342 | |
| 1343 | static int |
| 1344 | check_slave_start_position(binlog_send_info *info, const char **errormsg, |
| 1345 | rpl_gtid *error_gtid) |
| 1346 | { |
| 1347 | uint32 i; |
| 1348 | int err; |
| 1349 | slave_connection_state::entry **delete_list= NULL; |
| 1350 | uint32 delete_idx= 0; |
| 1351 | slave_connection_state *st= &info->gtid_state; |
| 1352 | |
| 1353 | if (rpl_load_gtid_slave_state(info->thd)) |
| 1354 | { |
| 1355 | *errormsg= "Failed to load replication slave GTID state"; |
| 1356 | err= ER_CANNOT_LOAD_SLAVE_GTID_STATE; |
| 1357 | goto end; |
| 1358 | } |
| 1359 | |
| 1360 | for (i= 0; i < st->hash.records; ++i) |
| 1361 | { |
| 1362 | slave_connection_state::entry *slave_gtid_entry= |
| 1363 | (slave_connection_state::entry *)my_hash_element(&st->hash, i); |
| 1364 | rpl_gtid *slave_gtid= &slave_gtid_entry->gtid; |
| 1365 | rpl_gtid master_gtid; |
| 1366 | rpl_gtid master_replication_gtid; |
| 1367 | rpl_gtid start_gtid; |
| 1368 | bool start_at_own_slave_pos= |
| 1369 | rpl_global_gtid_slave_state->domain_to_gtid(slave_gtid->domain_id, |
| 1370 | &master_replication_gtid) && |
| 1371 | slave_gtid->server_id == master_replication_gtid.server_id && |
| 1372 | slave_gtid->seq_no == master_replication_gtid.seq_no; |
| 1373 | |
| 1374 | if (mysql_bin_log.find_in_binlog_state(slave_gtid->domain_id, |
| 1375 | slave_gtid->server_id, |
| 1376 | &master_gtid) && |
| 1377 | master_gtid.seq_no >= slave_gtid->seq_no) |
| 1378 | { |
| 1379 | /* |
| 1380 | If connecting slave requests to start at the GTID we last applied when |
| 1381 | we were ourselves a slave, then this GTID may not exist in our binlog |
| 1382 | (in case of --log-slave-updates=0). So set the flag to disable the |
| 1383 | error about missing GTID in the binlog in this case. |
| 1384 | */ |
| 1385 | if (start_at_own_slave_pos) |
| 1386 | slave_gtid_entry->flags|= slave_connection_state::START_OWN_SLAVE_POS; |
| 1387 | continue; |
| 1388 | } |
| 1389 | |
| 1390 | if (!start_at_own_slave_pos) |
| 1391 | { |
| 1392 | rpl_gtid domain_gtid; |
| 1393 | slave_connection_state *until_gtid_state= info->until_gtid_state; |
| 1394 | rpl_gtid *until_gtid; |
| 1395 | |
| 1396 | if (!mysql_bin_log.lookup_domain_in_binlog_state(slave_gtid->domain_id, |
| 1397 | &domain_gtid)) |
| 1398 | { |
| 1399 | /* |
| 1400 | We do not have anything in this domain, neither in the binlog nor |
no test coverage detected