mirror of
https://github.com/MariaDB/server.git
synced 2025-08-05 13:16:09 +03:00
This is actually an existing problem in the old binlog implementation, and this patch is applicable to old binlog also. The problem is that RESET MASTER can run concurrently with binlog dump threads / connected slaves. This will remove the binlog from under the feet of the reader, which can cause all sorts of strange behaviour. This patch fixes the problem by disallowing to run RESET MASTER when dump threads (or other RESET MASTER or SHOW BINARY LOGS) are running. An error is thrown in this case, user must stop slaves and/or kill dump threads to make the RESET MASTER go through. A slave that connects in the middle of RESET MASTER will wait for it to complete. Fix a lot of test cases to kill any lingering dump threads before doing RESET MASTER, mostly just by sourcing include/kill_binlog_dump_threads.inc. Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
72 lines
1.8 KiB
PHP
72 lines
1.8 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)
|
|
{
|
|
--error 0,ER_NO_SUCH_THREAD
|
|
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.
|
|
}
|
|
# This an attempt to get more info about a rare sporadic test failure where
|
|
# RESET MASTER still fails with ER_BINLOG_IN_USE after this has run.
|
|
--let $sanity_check= `SELECT COUNT(*) FROM information_schema.processlist WHERE command = 'Binlog Dump'`
|
|
if ($sanity_check > 0) {
|
|
SHOW FULL PROCESSLIST;
|
|
--echo ERROR: still $sanity_check dump thread(s) found!
|
|
--die ERROR: still $sanity_check dump thread(s) found
|
|
}
|
|
|
|
--enable_query_log
|
|
|
|
--let $include_filename= kill_binlog_dump_threads.inc
|
|
--source include/end_include_file.inc
|