| 1 |
# ==== Purpose ==== |
| 2 |
# |
| 3 |
# This script aims at testing that `LOCK INSTANCE FOR BACKUP` prevents stopping |
| 4 |
# the slave SQL thread - either by means of `STOP SLAVE` or `STOP SLAVE |
| 5 |
# SQL_THREAD`. |
| 6 |
# |
| 7 |
# ==== Implementation ==== |
| 8 |
# |
| 9 |
# TC1. Lock instance for backup and execute `STOP SLAVE` |
| 10 |
# ------------------------------------------------------ |
| 11 |
# 1) Execute `LOCK INSTANCE FOR BACKUP`. |
| 12 |
# 2) Execute `STOP SLAVE` and expect a |
| 13 |
# `ER_RPL_CANT_STOP_REPLICA_WHILE_LOCKED_BACKUP` error. |
| 14 |
# 3) Check that the slave hasn't stop. |
| 15 |
# 4) Unlock the instance. |
| 16 |
# |
| 17 |
# TC2. Lock instance for backup and execute `STOP SLAVE SQL_THREAD` |
| 18 |
# ----------------------------------------------------------------- |
| 19 |
# 1) Execute `LOCK INSTANCE FOR BACKUP`. |
| 20 |
# 2) Execute `STOP SLAVE SQL_THREAD` and expect a |
| 21 |
# `ER_RPL_CANT_STOP_REPLICA_WHILE_LOCKED_BACKUP` error. |
| 22 |
# 3) Check that the slave hasn't stop. |
| 23 |
# 4) Unlock the instance. |
| 24 |
# |
| 25 |
# ==== References ==== |
| 26 |
# |
| 27 |
# BUG#29386503 STOP SLAVE SQL_THREAD DEADLOCKS IF DONE WHILE HOLDING LOCK |
| 28 |
# INSTANCE FOR BACKUP |
| 29 |
# |
| 30 |
|
| 31 |
--source include/master-slave.inc |
| 32 |
--source include/have_binlog_format_row.inc |
| 33 |
--source include/have_debug.inc |
| 34 |
--source include/have_debug_sync.inc |
| 35 |
|
| 36 |
# Procedure that executes `LOCK INSTANCE FOR BACKUP` and then executes another |
| 37 |
# statement. |
| 38 |
# |
| 39 |
--write_file $MYSQLTEST_VARDIR/tmp/lock_instance_and_execute.inc PROCEDURE |
| 40 |
if ($statement == '') { |
| 41 |
--die !!!ERROR IN TEST: you must set $statement |
| 42 |
} |
| 43 |
|
| 44 |
--source include/rpl_connection_slave.inc |
| 45 |
CALL mtr.add_suppression("Cannot stop the replica SQL thread while the instance is locked for backup. Try running `UNLOCK INSTANCE` first."); |
| 46 |
|
| 47 |
# 1) Execute `LOCK INSTANCE FOR BACKUP`. |
| 48 |
LOCK INSTANCE FOR BACKUP; |
| 49 |
|
| 50 |
# 2) Execute `STOP SLAVE` and expect a |
| 51 |
# `ER_RPL_CANT_STOP_REPLICA_WHILE_LOCKED_BACKUP` error. |
| 52 |
--error ER_RPL_CANT_STOP_REPLICA_WHILE_LOCKED_BACKUP |
| 53 |
--eval $statement |
| 54 |
|
| 55 |
# 3) Check that the slave hasn't stop. |
| 56 |
--let $slave_param = Slave_SQL_Running |
| 57 |
--let $slave_param_value = Yes |
| 58 |
--source include/wait_for_slave_param.inc |
| 59 |
|
| 60 |
# 4) Unlock the instance. |
| 61 |
UNLOCK INSTANCE; |
| 62 |
|
| 63 |
#END OF |
| 64 |
PROCEDURE |
| 65 |
|
| 66 |
--echo # |
| 67 |
--echo # TC1. Lock instance for backup and execute `STOP SLAVE` |
| 68 |
--echo # |
| 69 |
--let $statement = STOP SLAVE |
| 70 |
--source $MYSQLTEST_VARDIR/tmp/lock_instance_and_execute.inc |
| 71 |
|
| 72 |
--echo # |
| 73 |
--echo # TC2. Lock instance for backup and execute `STOP SLAVE SQL_THREAD` |
| 74 |
--echo # |
| 75 |
--let $statement = STOP SLAVE SQL_THREAD |
| 76 |
--source $MYSQLTEST_VARDIR/tmp/lock_instance_and_execute.inc |
| 77 |
|
| 78 |
# Clean up |
| 79 |
--remove_file $MYSQLTEST_VARDIR/tmp/lock_instance_and_execute.inc |
| 80 |
--source include/rpl_end.inc |