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()
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--disable_abort_on_error
46--horizontal_results
47
48
49--let $_rpl_old_con= $CURRENT_CONNECTION
50--let $_rpl_is_first_server= 1
51--let $_rpl_server= $rpl_server_count
52--inc $_rpl_server
53
54
55while ($_rpl_server)
56{
57  if (!$_rpl_is_first_server)
58  {
59    --connection server_$_rpl_server
60  }
61
62  --echo
63  --echo ############################## $CURRENT_CONNECTION ##############################
64  --echo
65  --echo **** SHOW WARNINGS on $CURRENT_CONNECTION ****
66  SHOW WARNINGS;
67  --echo
68  --echo **** SELECT replication-related variables on $CURRENT_CONNECTION ****
69  SELECT NOW(), @@SERVER_ID;
70  --echo
71  --echo **** SHOW SLAVE STATUS on $CURRENT_CONNECTION ****
72  query_vertical SHOW SLAVE STATUS;
73  --echo
74  --echo **** SHOW MASTER STATUS on $CURRENT_CONNECTION ****
75  query_vertical SHOW MASTER STATUS;
76  --echo
77  --echo **** SHOW SLAVE HOSTS on $CURRENT_CONNECTION ****
78  query_vertical SHOW SLAVE HOSTS;
79  --echo
80  --echo **** SHOW PROCESSLIST on $CURRENT_CONNECTION ****
81  SHOW PROCESSLIST;
82  --echo
83  --echo **** SHOW BINARY LOGS on $CURRENT_CONNECTION ****
84  SHOW BINARY LOGS;
85  --echo
86  --echo **** SHOW BINLOG EVENTS on $CURRENT_CONNECTION ****
87  let $binlog_name= query_get_value("SHOW MASTER STATUS", File, 1);
88  --echo binlog_name = '$binlog_name'
89  eval SHOW BINLOG EVENTS IN '$binlog_name';
90  --echo
91  --echo **** SHOW RELAYLOG EVENTS on $CURRENT_CONNECTION ****
92  let $relaylog_name= query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1);
93  --echo relaylog_name = '$relaylog_name'
94  eval SHOW RELAYLOG EVENTS IN '$relaylog_name';
95
96
97  --let $_rpl_is_first_server= 0
98  --dec $_rpl_server
99  # Don't use same connection twice.
100  if (`SELECT 'server_$_rpl_server' = '$_rpl_old_con'`)
101  {
102    --dec $_rpl_server
103    if ($rpl_only_current_connection)
104    {
105      --let $_rpl_server= 0
106    }
107  }
108}
109
110--connection $_rpl_old_con
111--enable_abort_on_error
112