Debian Codegraph @

mysql-test/suite/clone/include/clone_connection_end.inc

raw
1 ## Create connection to clone instance optionally restarting instance with
2 ## monitoring process.
3
4 # These variables can to be set before sourcing this file. Currently we used
5 # to test both with and without monitoring process.
6 #
7 # 1. Need to restart mysqld with monitoring process
8 # --let inst_monitor = 1
9 #
10 # 2. Number of connections to be dropped from the instance
11 # --let clone_connections = <number of connections> 1/2/3 ...
12 # Connections have the name as clone_conn_<number>
13 # e.g. clone_conn_1, clone_conn_2, clone_conn_3 etc.
14 #
15 # 3. This script should be used in pair with clone_connection_begin.inc
16 # --source clone_connection_begin.inc
17 # ...
18 # --source clone_connection_end.inc
19
20 if (!$clone_user) {
21 --let $clone_user = 'root'
22 }
23
24 if (!$clone_connections) {
25 --let $clone_connections = 1
26 }
27
28 # A. Drop the connections
29 --connection clone_conn_1
30 # In case server is restarted, we need to reconnect
31 --enable_reconnect
32 --source include/wait_until_connected_again.inc
33 --disable_reconnect
34
35 # Get Server ID
36 --let $SERVER_ID= `SELECT @@server_id`
37
38 --let $conn_nummber = 1
39
40 # If not the default instance, keep first connection.
41 if ($SERVER_ID != 1) {
42 --let $conn_nummber =2
43
44 --echo Uninstall clone plugin on recipient server
45 UNINSTALL PLUGIN clone;
46 }
47
48 while ($conn_nummber <= $clone_connections)
49 {
50 --let $conn_name = clone_conn_$conn_nummber
51 --disconnect $conn_name
52 --inc $conn_nummber
53 }
54
55 # B. Check if we need monitoring process. Taken from mysqld_safe.test
56 if ($inst_monitor) {
57
58 # Reconnect default if we shut down default server.
59 if ($SERVER_ID == 1) {
60 --connection default
61 }
62
63 # 1. Shutdown the server
64 --disable_query_log
65 --enable_query_log
66 --exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.$SERVER_ID.expect
67 --shutdown_server
68 --source include/wait_until_disconnected.inc
69
70 # 2. Restart mysqld having $SERVER_ID
71 --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.$SERVER_ID.expect
72 --source include/wait_until_disconnected.inc
73 --enable_reconnect
74 --source include/wait_until_connected_again.inc
75 --disable_reconnect
76 }
77
78 # Now disconnect the skipped connection
79 if ($SERVER_ID != 1) {
80 --disconnect clone_conn_1
81 }
82
83 # Switch to default connection
84 --connection default