3 # Issues STOP SLAVE on the current connection. Then waits until both
4 # the IO and SQL threads have stopped, or until a timeout is reached.
6 # Please use this instead of 'STOP SLAVE', to reduce the risk of races
9 # This will fail if the slave IO or SQL thread has an error. If you
10 # expect an error in the IO thread, use
11 # include/wait_for_slave_io_error.inc and include/stop_slave_sql.inc.
16 # [--let $rpl_only_running_threads= 1]
17 # [--let $slave_timeout= NUMBER]
18 # [--let $rpl_debug= 1]
19 # --source include/stop_slave.inc
22 # $rpl_only_running_threads
23 # By default, this script executes STOP SLAVE unconditionally.
24 # This generates a warnings if one or both slave threads are
25 # already stopped. If $rpl_only_running_threads is set, this
26 # script checks which slave threads are running, and issues either
27 # STOP SLAVE, STOP SLAVE SQL_THREAD, STOP SLAVE IO_THREAD, or
31 # See include/wait_for_slave_param.inc
34 # See include/rpl_init.inc
37 --let $include_filename= stop_slave.inc
38 --source include/begin_include_file.inc
47 if ($rpl_only_running_threads)
49 --let $_slave_sql_running= query_get_value(SHOW SLAVE
STATUS, Slave_SQL_Running, 1)
50 --let $_slave_io_running= query_get_value(SHOW SLAVE
STATUS, Slave_IO_Running, 1)
53 --echo Stop SQL: $_slave_sql_running; Stop IO: $_slave_io_running
56 --let $_slave_running_bits= `SELECT IF(
'$_slave_io_running' =
'Yes', 1, 0) + IF(
'$_slave_sql_running' =
'Yes', 2, 0)`
57 if ($_slave_running_bits)
59 --dec $_slave_running_bits
60 # $_slave_running_bits=1: io thread running
61 if (!$_slave_running_bits)
63 --source include/stop_slave_io.inc
65 --dec $_slave_running_bits
66 # $_slave_running_bits=2: sql thread running
67 if (!$_slave_running_bits)
69 --source include/stop_slave_sql.inc
71 --dec $_slave_running_bits
72 # $_slave_running_bits=2: both threads running
73 if (!$_slave_running_bits)
76 --source include/wait_for_slave_to_stop.inc
80 if (!$rpl_only_running_threads)
83 --source include/wait_for_slave_to_stop.inc
87 --let $include_filename= stop_slave.inc
88 --source include/end_include_file.inc