mariadb/mysql-test/include/kill_binlog_dump_threads.inc
unknown 5cb486d159 MDEV-26: Global transaction ID.
Fix problems related to reconnect. When we need to reconnect (ie. explict
stop/start of just the IO thread by user, or automatic reconnect due to
loosing network connection with the master), it is a bit complex to correctly
resume at the right point without causing duplicate or missing events in the
relay log. The previous code had multiple problems in this regard.

With this patch, the problem is solved as follows. The IO thread keeps track
(in memory) of which GTID was last queued to the relay log. If it needs to
reconnect, it resumes at that GTID position. It also counts number of events
received within the last, possibly partial, event group, and skips the same
number of events after a reconnect, so that events already enqueued before the
reconnect are not duplicated.

(There is no need to keep any persistent state; whenever we restart slave
threads after both of them being stopped (such as after server restart), we
erase the relay logs and start over from the last GTID applied by SQL thread.
But while the SQL thread is running, this patch is needed to get correct relay
log).
2013-06-05 14:32:47 +02:00

62 lines
1.4 KiB
PHP

# ==== Purpose ====
#
# Terminate all binlog dump threads on a master.
#
# This is sometimes useful, as normally such dump threads can hang
# around for some time before they notice that the slave has disconnected.
#
# Note that if there are active slave connections, they might try to
# reconnect as their dump threads are killed, which may not lead to the
# desired results.
#
#
# ==== Usage ====
#
# [--let $kill_timeout= NUMBER]
# --source include/stop_slavekill_binlog_dump_threads.inc
#
# Parameters:
# $kill_timeout
# Maximum number of seconds to wait for dump threads to disappear.
--let $include_filename= kill_binlog_dump_threads.inc
--source include/begin_include_file.inc
--disable_query_log
let $wait_counter= 300;
if ($kill_timeout)
{
let $wait_counter= `SELECT $kill_timeout * 10`;
}
let $success= 0;
while ($wait_counter)
{
dec $wait_counter;
let $_tid= `SELECT id FROM information_schema.processlist WHERE command = 'Binlog Dump' LIMIT 1`;
if ($_tid)
{
eval KILL QUERY $_tid;
}
if (!$_tid)
{
let $wait_counter= 0;
let $success= 1;
}
if (!$success)
{
real_sleep 0.1;
}
}
if (!$success)
{
SHOW FULL PROCESSLIST;
--die Timeout while waiting for binlog dump threads to disappear.
}
--enable_query_log
--let $include_filename= kill_binlog_dump_threads.inc
--source include/end_include_file.inc