104
107
"Waiting to reconnect after a failed binlog dump request",
105
108
"Slave I/O thread killed while retrying master dump",
106
109
"Reconnecting after a failed binlog dump request",
107
"failed dump request, reconnecting to try again, log '%s' at postion %s",
110
"failed dump request, reconnecting to try again, log '%s' at position %s",
108
111
"COM_BINLOG_DUMP",
109
112
"Slave I/O thread killed during or after reconnect"
407
410
int error,force_all = (thread_mask & SLAVE_FORCE_ALL);
408
411
pthread_mutex_t *sql_lock = &mi->rli.run_lock, *io_lock = &mi->run_lock;
413
if (thread_mask & (SLAVE_SQL|SLAVE_FORCE_ALL))
415
DBUG_PRINT("info",("Terminating SQL thread"));
416
mi->rli.abort_slave=1;
417
if ((error=terminate_slave_thread(mi->rli.sql_thd, sql_lock,
419
&mi->rli.slave_running,
410
424
if (thread_mask & (SLAVE_IO|SLAVE_FORCE_ALL))
412
426
DBUG_PRINT("info",("Terminating IO thread"));
595
598
DBUG_PRINT("sleep",("Waiting for slave thread to start"));
596
599
const char* old_msg = thd->enter_cond(start_cond,cond_lock,
597
600
"Waiting for slave thread to start");
598
pthread_cond_wait(start_cond,cond_lock);
601
pthread_cond_wait(start_cond, cond_lock);
599
602
thd->exit_cond(old_msg);
600
603
pthread_mutex_lock(cond_lock); // re-acquire it as exit_cond() released
607
pthread_mutex_unlock(start_lock);
602
608
DBUG_RETURN(thd->killed_errno());
739
746
DBUG_ASSERT(rli->slave_running == 1);// tracking buffer overrun
740
747
if (abort_loop || thd->killed || rli->abort_slave)
750
The transaction should always be binlogged if OPTION_KEEP_LOG is set
751
(it implies that something can not be rolled back). And such case
752
should be regarded similarly as modifing a non-transactional table
753
because retrying of the transaction will lead to an error or inconsistency
755
Example: OPTION_KEEP_LOG is set if a temporary table is created or dropped.
742
757
if (rli->abort_slave && rli->is_in_group() &&
743
thd->transaction.all.modified_non_trans_table)
758
(thd->transaction.all.modified_non_trans_table ||
759
(thd->options & OPTION_KEEP_LOG)))
746
762
If we are in an unsafe situation (stopping could corrupt replication),
981
997
unavailable (very old master not supporting UNIX_TIMESTAMP()?).
984
DBUG_SYNC_POINT("debug_lock.before_get_UNIX_TIMESTAMP", 10);
1000
DBUG_EXECUTE_IF("dbug.before_get_UNIX_TIMESTAMP",
1004
"wait_for signal.get_unix_timestamp";
1005
DBUG_ASSERT(opt_debug_sync_timeout > 0);
1006
DBUG_ASSERT(!debug_sync_set_action(current_thd,
1007
STRING_WITH_LEN(act)));
985
1010
master_res= NULL;
986
1011
if (!mysql_real_query(mysql, STRING_WITH_LEN("SELECT UNIX_TIMESTAMP()")) &&
987
1012
(master_res= mysql_store_result(mysql)) &&
1020
1045
Note: we could have put a @@SERVER_ID in the previous SELECT
1021
1046
UNIX_TIMESTAMP() instead, but this would not have worked on 3.23 masters.
1023
DBUG_SYNC_POINT("debug_lock.before_get_SERVER_ID", 10);
1048
DBUG_EXECUTE_IF("dbug.before_get_SERVER_ID",
1052
"wait_for signal.get_server_id";
1053
DBUG_ASSERT(opt_debug_sync_timeout > 0);
1054
DBUG_ASSERT(!debug_sync_set_action(current_thd,
1055
STRING_WITH_LEN(act)));
1024
1057
master_res= NULL;
1025
1058
master_row= NULL;
1026
1059
if (!mysql_real_query(mysql,
3002
3049
do not want to wait for next event in this case.
3004
3051
pthread_mutex_lock(&rli->data_lock);
3052
if (rli->slave_skip_counter)
3054
strmake(saved_log_name, rli->group_relay_log_name, FN_REFLEN - 1);
3055
strmake(saved_master_log_name, rli->group_master_log_name, FN_REFLEN - 1);
3056
saved_log_pos= rli->group_relay_log_pos;
3057
saved_master_log_pos= rli->group_master_log_pos;
3058
saved_skip= rli->slave_skip_counter;
3005
3060
if (rli->until_condition != Relay_log_info::UNTIL_NONE &&
3006
rli->is_until_satisfied(rli->group_master_log_pos))
3061
rli->is_until_satisfied(thd, NULL))
3009
3064
sql_print_information("Slave SQL thread stopped because it reached its"
3020
3075
thd_proc_info(thd, "Reading event from the relay log");
3021
3076
DBUG_ASSERT(rli->sql_thd == thd);
3022
3077
THD_CHECK_SENTRY(thd);
3079
if (saved_skip && rli->slave_skip_counter == 0)
3081
sql_print_information("'SQL_SLAVE_SKIP_COUNTER=%ld' executed at "
3082
"relay_log_file='%s', relay_log_pos='%ld', master_log_name='%s', "
3083
"master_log_pos='%ld' and new position at "
3084
"relay_log_file='%s', relay_log_pos='%ld', master_log_name='%s', "
3085
"master_log_pos='%ld' ",
3086
(ulong) saved_skip, saved_log_name, (ulong) saved_log_pos,
3087
saved_master_log_name, (ulong) saved_master_log_pos,
3088
rli->group_relay_log_name, (ulong) rli->group_relay_log_pos,
3089
rli->group_master_log_name, (ulong) rli->group_master_log_pos);
3023
3093
if (exec_relay_log_event(thd,rli))
3025
3095
DBUG_PRINT("info", ("exec_relay_log_event() failed"));
4295
4365
DBUG_ASSERT(rli->cur_log_fd == -1);
4298
Read pointer has to be at the start since we are the only
4300
We must keep the LOCK_log to read the 4 first bytes, as this is a hot
4301
log (same as when we call read_log_event() above: for a hot log we
4368
When the SQL thread is [stopped and] (re)started the
4369
following may happen:
4371
1. Log was hot at stop time and remains hot at restart
4373
SQL thread reads again from hot_log (SQL thread was
4374
reading from the active log when it was stopped and the
4375
very same log is still active on SQL thread restart).
4377
In this case, my_b_seek is performed on cur_log, while
4378
cur_log points to relay_log.get_log_file();
4380
2. Log was hot at stop time but got cold before restart
4382
The log was hot when SQL thread stopped, but it is not
4383
anymore when the SQL thread restarts.
4385
In this case, the SQL thread reopens the log, using
4386
cache_buf, ie, cur_log points to &cache_buf, and thence
4387
its coordinates are reset.
4389
3. Log was already cold at stop time
4391
The log was not hot when the SQL thread stopped, and, of
4392
course, it will not be hot when it restarts.
4394
In this case, the SQL thread opens the cold log again,
4395
using cache_buf, ie, cur_log points to &cache_buf, and
4396
thence its coordinates are reset.
4398
4. Log was hot at stop time, DBA changes to previous cold
4399
log and restarts SQL thread
4401
The log was hot when the SQL thread was stopped, but the
4402
user changed the coordinates of the SQL thread to
4403
restart from a previous cold log.
4405
In this case, at start time, cur_log points to a cold
4406
log, opened using &cache_buf as cache, and coordinates
4407
are reset. However, as it moves on to the next logs, it
4408
will eventually reach the hot log. If the hot log is the
4409
same at the time the SQL thread was stopped, then
4410
coordinates were not reset - the cur_log will point to
4411
relay_log.get_log_file(), and not a freshly opened
4412
IO_CACHE through cache_buf. For this reason we need to
4413
deploy a my_b_seek before calling check_binlog_magic at
4414
this point of the code (see: BUG#55263 for more
4418
- We must keep the LOCK_log to read the 4 first bytes, as
4419
this is a hot log (same as when we call read_log_event()
4420
above: for a hot log we take the mutex).
4422
- Because of scenario #4 above, we need to have a
4423
my_b_seek here. Otherwise, we might hit the assertion
4424
inside check_binlog_magic.
4427
my_b_seek(cur_log, (my_off_t) 0);
4304
4428
if (check_binlog_magic(cur_log,&errmsg))
4306
4430
if (!hot_log) pthread_mutex_unlock(log_lock);