MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
show_rpl_debug_info.inc
1 # ==== Purpose ====
2 #
3 # Print status information for replication, typically used to debug
4 # test failures.
5 #
6 # The following is printed on the current connection:
7 #
8 # SELECT NOW(), @@SERVER_ID, @@SERVER_UUID
9 # SHOW SLAVE STATUS
10 # SHOW MASTER STATUS
11 # SHOW PROCESSLIST
12 # SHOW BINLOG EVENTS IN <binlog_name>
13 #
14 # Where <binlog_name> is the currently active binlog.
15 #
16 # Then, the same is printed from all connections configured by
17 # rpl_init.inc - i.e., on connection server_N, where
18 # 1 <= N <= $rpl_server_count
19 #
20 #
21 # ==== Usage ====
22 #
23 # [--let $rpl_only_current_connection= 1]
24 # --source include/show_rpl_debug_info.inc
25 #
26 # Parameters:
27 # $rpl_only_current_connection
28 # By default, debug info is printed from all connections, starting
29 # with the current connection. If this variable is set, debug
30 # info is printed only for the current connection.
31 #
32 #
33 # ==== Side effects ====
34 #
35 # Turns on enable_query_log, enable_result_log, enable_warnings,
36 # horizontal_results, and enable_abort_on_error.
37 #
38 # Prints non-deterministic output to the query log. This file should
39 # never be called in a test that does not fail.
40 
41 
42 --enable_query_log
43 --enable_result_log
44 --enable_warnings
45 --enable_connect_log
46 --disable_abort_on_error
47 --horizontal_results
48 
49 
50 --let $_rpl_old_con= $CURRENT_CONNECTION
51 --let $_rpl_is_first_server= 1
52 --let $_rpl_server= $rpl_server_count
53 if ($_rpl_server == '')
54 {
55  --let $_rpl_server= 0
56 }
57 --inc $_rpl_server
58 
59 --echo CURRENT_CONNECTION = '$_rpl_old_con'
60 
61 while ($_rpl_server)
62 {
63  if (!$_rpl_is_first_server)
64  {
65  --connection server_$_rpl_server
66  }
67 
68  --echo
69  --echo ############################## $CURRENT_CONNECTION ##############################
70  --echo
71  --echo **** SHOW WARNINGS on $CURRENT_CONNECTION ****
72  SHOW WARNINGS;
73  --echo
74  --echo **** SELECT replication-related variables on $CURRENT_CONNECTION ****
75  query_vertical SELECT NOW(), @@SERVER_ID, @@SERVER_UUID, @@PORT;
76  --echo
77  --echo **** GTID_* on $CURRENT_CONNECTION ****
78  query_vertical
79  SELECT @@GLOBAL.GTID_EXECUTED, @@GLOBAL.GTID_PURGED, @@GLOBAL.GTID_OWNED, @@SESSION.GTID_EXECUTED, @@SESSION.GTID_OWNED;
80  --echo
81  --echo **** SHOW SLAVE STATUS on $CURRENT_CONNECTION ****
82  query_vertical SHOW SLAVE STATUS;
83  --echo
84  --echo **** SHOW MASTER STATUS on $CURRENT_CONNECTION ****
85  query_vertical SHOW MASTER STATUS;
86  --echo
87  --echo **** SHOW SLAVE HOSTS on $CURRENT_CONNECTION ****
88  query_vertical SHOW SLAVE HOSTS;
89  --echo
90  --echo **** SHOW PROCESSLIST on $CURRENT_CONNECTION ****
91  SHOW PROCESSLIST;
92  --echo
93  --echo **** SHOW BINARY LOGS on $CURRENT_CONNECTION ****
94  SHOW BINARY LOGS;
95  --echo
96  --echo **** SHOW BINLOG EVENTS on $CURRENT_CONNECTION ****
97  let $binlog_name= query_get_value("SHOW MASTER STATUS", File, 1);
98  --echo binlog_name = '$binlog_name'
99  eval SHOW BINLOG EVENTS IN '$binlog_name';
100  --echo
101  --echo **** SHOW RELAYLOG EVENTS on $CURRENT_CONNECTION ****
102  let $relaylog_name= query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1);
103  --echo relaylog_name = '$relaylog_name'
104  eval SHOW RELAYLOG EVENTS IN '$relaylog_name';
105  --echo
106  --echo **** slave_relay_info on $CURRENT_CONNECTION ****
107  SELECT * FROM mysql.slave_relay_log_info;
108  --echo
109  --echo **** slave_master_info on $CURRENT_CONNECTION ****
110  SELECT * FROM mysql.slave_master_info;
111 
112  --let $_rpl_is_first_server= 0
113  --dec $_rpl_server
114  # Don't use same connection twice.
115  if (`SELECT 'server_$_rpl_server' = '$_rpl_old_con'`)
116  {
117  --dec $_rpl_server
118  if ($rpl_only_current_connection)
119  {
120  --let $_rpl_server= 0
121  }
122  }
123 }
124 
125 --echo rand_seed: '$rand_seed' _rand_state: '$_rand_state'
126 --echo extra debug info if any: '$extra_debug_info'
127 
128 --connection $_rpl_old_con
129 --enable_abort_on_error