MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
rpl_end.inc
1 # ==== Purpose ====
2 #
3 # Shut down replication initialized by include/rpl_init.inc.
4 #
5 # This syncs all servers, executes STOP SLAVE on all servers, executes
6 # CHANGE MASTER on all servers, and disconnects all connections
7 # configured by rpl_init.inc.
8 #
9 # It does not execute RESET MASTER or RESET SLAVE, because that would
10 # remove binlogs which are possibly useful debug information in case
11 # the test case later fails with a result mismatch. If you need that,
12 # source include/rpl_reset.inc before you source this file.
13 #
14 #
15 # ==== Usage ====
16 #
17 # [--let $rpl_only_running_threads= 1]
18 # [--let $rpl_debug= 1]
19 # --source include/rpl_end.inc
20 #
21 # Parameters:
22 # $rpl_only_running_threads
23 # If one or both of the IO and SQL threads is stopped, sync and
24 # stop only the threads that are running. See
25 # include/rpl_sync.inc and include/stop_slave.inc for details.
26 #
27 # $rpl_debug
28 # See include/rpl_init.inc
29 #
30 # Note:
31 # This script will fail if Last_SQL_Error or Last_IO_Error is
32 # nonempty. If you expect an error in the SQL thread, you should
33 # normally call this script as follows:
34 #
35 # --source include/wait_for_slave_sql_error.inc
36 # --source include/stop_slave_io.inc
37 # RESET SLAVE;
38 # --let $rpl_only_running_threads= 1
39 # --source include/rpl_end.inc
40 #
41 #
42 # ==== Side effects ====
43 #
44 # Changes the current connection to 'default'.
45 
46 
47 --let $include_filename= rpl_end.inc
48 --source include/begin_include_file.inc
49 
50 
51 if (!$rpl_inited)
52 {
53  --die ERROR IN TEST: rpl_end.inc was sourced when replication was not configured. Most likely, rpl_end.inc was sourced twice or rpl_init.inc has not been sourced.
54 }
55 
56 
57 if ($rpl_debug)
58 {
59  --echo ---- Check that no slave thread has an error ----
60 }
61 
62 --let $_rpl_server= $rpl_server_count
63 while ($_rpl_server)
64 {
65  --let $rpl_connection_name= server_$_rpl_server
66  --source include/rpl_connection.inc
67 
68  # Only check slave threads for error on hosts that were at some
69  # point configured as slave.
70  --let $_tmp= query_get_value(SHOW SLAVE STATUS, Master_Host, 1)
71  if ($_tmp != 'No such row')
72  {
73  --source include/check_slave_no_error.inc
74  }
75 
76  --dec $_rpl_server
77 }
78 
79 --source include/rpl_sync.inc
80 --source include/rpl_stop_slaves.inc
81 
82 # mtr configures server 2 to be a slave before it runs the test. We
83 # have to restore that state now, so we change topology to 1->2.
84 --let $rpl_topology= none
85 --source include/rpl_change_topology.inc
86 
87 
88 --connection default
89 --let $_rpl_server= $rpl_server_count
90 --let $_rpl_one= _1
91 while ($_rpl_server)
92 {
93  --disconnect server_$_rpl_server
94  --disconnect server_$_rpl_server$_rpl_one
95  --dec $_rpl_server
96 }
97 
98 --let $rpl_inited= 0
99 
100 # Do not restore connection, because we have disconnected it.
101 --let $skip_restore_connection= 1
102 --let $include_filename= rpl_end.inc
103 --source include/end_include_file.inc