mirror of
https://github.com/MariaDB/server.git
synced 2025-07-04 01:23:45 +03:00
Problem : The basic problem is the way the thread sleeps in mysql-5.5 and also in mysql-5.1 when we execute a stop slave on windows platform. On windows platform if the stop slave is executed after the master dies, we have this long wait before the stop slave return a value. This is because there is a sleep of the thread. The sleep is uninterruptable in the two above version, which was fixed by Davi patch for the BUG#11765860 for mysql-trunk. Backporting his patch for mysql-5.5 fixes the problem. Solution : A new pair of mutex and condition variable is introduced to synchronize thread sleep and finalization. A new mutex is required because the slave threads are terminated while holding the slave thread locks (run_lock), which can not be relinquished during termination as this would affect the lock order. mysql-test/suite/rpl/r/rpl_start_stop_slave.result: The result file associated with the test added. mysql-test/suite/rpl/t/rpl_start_stop_slave.test: A test to check the new functionality. sql/rpl_mi.cc: The constructor using the new mutex and condition variables for the master_info. sql/rpl_mi.h: The condition variable and mutex have been added for the master_info. sql/rpl_rli.cc: The constructor using the new mutex and condition variables for the realy_log_info. sql/rpl_rli.h: The condition variable and mutex have been added for the relay_log_info. sql/slave.cc: Use a timed wait on a condition variable to implement a interruptible sleep. The wait is registered with the THD object so that the thread will be woken up if killed.
45 lines
1.4 KiB
Plaintext
45 lines
1.4 KiB
Plaintext
#
|
|
#BUG#11752315 : STOP SLAVE UNABLE TO COMPLETE WHEN SLAVE THREAD IS TRYING
|
|
# TO RECONNECT TO
|
|
#
|
|
# ==== Purpose ====
|
|
#
|
|
#Tests that the slave does not go to a sleep for a long duration after the
|
|
#master is killed and we do a START_SLAVE and STOP_SLAVE.
|
|
#
|
|
# ==== Method ====
|
|
#
|
|
#This is a new functionality of having an interruptable sleep of the slave.
|
|
#We find the thread id for the slave thread. On finding the thread ID of the
|
|
#slave thread we kill the slave thread. A successful kill in less than 60 sec
|
|
#should serve the purpose of checking the functionality.
|
|
#
|
|
|
|
--source include/have_log_bin.inc
|
|
--source include/master-slave.inc
|
|
|
|
connection slave;
|
|
--let $connection_id=`SELECT id FROM information_schema.processlist where state LIKE 'Waiting for master to send event'`
|
|
|
|
set @time_before_kill := (select CURRENT_TIMESTAMP);
|
|
|
|
--echo [Time before the query]
|
|
--echo [Connection ID of the slave I/O thread found]
|
|
|
|
--replace_regex /kill [0-9]*/kill <connection_id>/
|
|
--eval kill $connection_id
|
|
|
|
set @time_after_kill := (select CURRENT_TIMESTAMP);
|
|
|
|
--echo [Time after the query]
|
|
|
|
if(`select TIMESTAMPDIFF(SECOND,@time_after_kill, @time_before_kill) > 60`)
|
|
{
|
|
--echo # assert : The difference between the timestamps 'time_after_kill' and 'time_before_kill' should be less than 60sec.
|
|
--die
|
|
}
|
|
|
|
--echo [Killing of the slave IO thread was successful]
|
|
# End of test
|
|
--source include/rpl_end.inc
|