Debian Codegraph @

mysql-test/suite/rpl/t/rpl_stop_slave_blocks_lock_for_backup.test

raw
1 # ==== Purpose ====
2 #
3 # This script aims at testing that `LOCK INSTANCE FOR BACKUP` doesn't acquire
4 # the BACKUP lock while the server is stopping the slave SQL thread - either by
5 # means of `STOP SLAVE` or `STOP SLAVE SQL_THREAD`.
6 #
7 # ==== Implementation ====
8 #
9 # TC1. Lock instance for backup while `STOP SLAVE` executes
10 # ---------------------------------------------------------
11 # 1) Open two different connections, A and B to the slave node and set
12 # `stop_replica_dont_release_backup_lock` debug sync point in both.
13 # 2) Through connection A, send a `STOP SLAVE` statement to the server that,
14 # after acquiring the BACKUP lock, will wait for a
15 # `tried_to_lock_instance_for_backup` signal in the
16 # `stop_replica_dont_release_backup_lock` sync point.
17 # 3) Through connection B, execute a `LOCK INSTANCE FOR BACKUP` statement and
18 # expect a `ER_LOCK_WAIT_TIMEOUT` error.
19 # 4) Through connection B, send the `tried_to_lock_instance_for_backup` signal.
20 # 5) Through connection A, reap the result of the sent statement.
21 # 6) Check that the slave stopped and re-start it.
22 #
23 # TC2. Lock instance for backup while `STOP SLAVE SQL_THREAD` executes
24 # --------------------------------------------------------------------
25 # 1) Open two different connections, A and B to the slave node and set
26 # `stop_replica_dont_release_backup_lock` debug sync point in both.
27 # 2) Through connection A, send a `STOP SLAVE SQL_THREAD` statement to the
28 # server that, after acquiring the BACKUP lock, will wait for a
29 # `tried_to_lock_instance_for_backup` signal in the
30 # `stop_replica_dont_release_backup_lock` sync point.
31 # 3) Through connection B, execute a `LOCK INSTANCE FOR BACKUP` statement and
32 # expect a `ER_LOCK_WAIT_TIMEOUT` error.
33 # 4) Through connection B, send the `tried_to_lock_instance_for_backup` signal.
34 # 5) Through connection A, reap the result of the sent statement.
35 # 6) Check that the slave stopped and re-start it.
36 #
37 # ==== References ====
38 #
39 # BUG#29386503 STOP SLAVE SQL_THREAD DEADLOCKS IF DONE WHILE HOLDING LOCK
40 # INSTANCE FOR BACKUP
41 #
42
43 --source include/master-slave.inc
44 --source include/have_debug.inc
45 --source include/have_debug_sync.inc
46 --source include/have_binlog_format_row.inc
47
48 # Procedure that executes `LOCK INSTANCE FOR BACKUP` while another statement is
49 # being executed.
50 #
51 --write_file $MYSQLTEST_VARDIR/tmp/lock_instance_while_executing.inc PROCEDURE
52 if ($statement == '') {
53 --die !!!ERROR IN TEST: you must set $statement
54 }
55
56 # 1) Open two different connections, A and B to the slave node and set
57 # `stop_replica_dont_release_backup_lock` debug sync point in both.
58 --source include/rpl_connection_slave.inc
59 SET DEBUG = "+d,stop_replica_dont_release_backup_lock";
60 --source include/rpl_connection_slave1.inc
61 CALL mtr.add_suppression("Lock wait timeout exceeded; try restarting transaction");
62 SET DEBUG = "+d,stop_replica_dont_release_backup_lock";
63
64 # 2) Through connection A, send $statement to the server that, after acquiring
65 # the BACKUP lock, will wait for a `tried_to_lock_instance_for_backup`
66 # signal in the `stop_replica_dont_release_backup_lock` sync point.
67 --source include/rpl_connection_slave.inc
68 --send_eval $statement
69
70 # 3) Through connection B, execute a `LOCK INSTANCE FOR BACKUP` statement and
71 # expect a `ER_LOCK_WAIT_TIMEOUT` error.
72 --source include/rpl_connection_slave1.inc
73 SET DEBUG_SYNC = "now WAIT_FOR replica_acquired_backup_lock";
74 --error ER_LOCK_WAIT_TIMEOUT
75 LOCK INSTANCE FOR BACKUP;
76
77 # 4) Through connection B, send the `tried_to_lock_instance_for_backup` signal.
78 SET DEBUG_SYNC = "now SIGNAL tried_to_lock_instance_for_backup";
79
80 # 5) Through connection A, reap the result of the sent statement.
81 --source include/rpl_connection_slave.inc
82 --reap
83
84 # 6) Check that the slave stopped and re-start it.
85 START SLAVE;
86
87 --source include/rpl_connection_slave.inc
88 SET DEBUG = "-d,stop_replica_dont_release_backup_lock";
89 --source include/rpl_connection_slave1.inc
90 SET DEBUG = "-d,stop_replica_dont_release_backup_lock";
91 #END OF
92 PROCEDURE
93
94 --echo #
95 --echo # TC1. Lock instance for backup while `STOP SLAVE` executes
96 --echo #
97 --let $statement = STOP SLAVE
98 --source $MYSQLTEST_VARDIR/tmp/lock_instance_while_executing.inc
99
100 --echo #
101 --echo # TC2. Lock instance for backup while `STOP SLAVE SQL_THREAD` executes
102 --echo #
103 --let $statement = STOP SLAVE SQL_THREAD
104 --source $MYSQLTEST_VARDIR/tmp/lock_instance_while_executing.inc
105
106 # Clean up
107 --remove_file $MYSQLTEST_VARDIR/tmp/lock_instance_while_executing.inc
108 --source include/rpl_end.inc