show_rpl_debug_info.inc 2.42 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
# ==== Purpose ====
#
# Print status information for replication, typically used to debug
# test failures.
#
# First, the following is printed on slave:
#
#   SHOW SLAVE STATUS
#   SHOW PROCESSLIST
#   SHOW BINLOG EVENTS IN <binlog_name>
#
# Where <binlog_name> is the currently active binlog.
#
# Then, the following is printed on master:
#
#   SHOW MASTER STATUS
#   SHOW PROCESSLIST
#   SHOW BINLOG EVENTS IN <sql_binlog_name>
#   SHOW BINLOG EVENTS IN <io_binlog_name>
#
# Where <sql_binlog_name> is the binlog name that the slave sql thread
# is currently reading from and <io_binlog_name> is the binlog that
# the slave IO thread is currently reading from.
#
# ==== Usage ====
#
# [let $master_connection= <connection>;]
# source include/show_rpl_debug_info.inc;
#
# If $master_connection is set, debug info will be retrieved from the
# connection named $master_connection.  Otherwise, it will be
# retrieved from the 'master' connection if the current connection is
# 'slave'.

let $_con= $CURRENT_CONNECTION;
--echo
--echo [on $_con]
--echo
39
SELECT NOW();
40 41 42 43 44 45 46 47 48 49 50
--echo **** SHOW SLAVE STATUS on $_con ****
query_vertical SHOW SLAVE STATUS;
--echo
--echo **** SHOW PROCESSLIST on $_con ****
SHOW PROCESSLIST;
--echo
--echo **** SHOW BINLOG EVENTS on $_con ****
let $binlog_name= query_get_value("SHOW MASTER STATUS", File, 1);
eval SHOW BINLOG EVENTS IN '$binlog_name';

let $_master_con= $master_connection;
51
if (!$_master_con)
52 53 54 55 56
{
  if (`SELECT '$_con' = 'slave'`)
  {
    let $_master_con= master;
  }
57
  if (!$_master_con)
58 59 60 61 62 63 64
  {
    --echo Unable to determine master connection. No debug info printed for master.
    --echo Please fix the test case by setting $master_connection before sourcing
    --echo show_rpl_debug_info.inc.
  }
}

65
if ($_master_con)
66 67 68 69 70 71 72 73
{

  let $master_binlog_name_io= query_get_value("SHOW SLAVE STATUS", Master_Log_File, 1);
  let $master_binlog_name_sql= query_get_value("SHOW SLAVE STATUS", Relay_Master_Log_File, 1);
  --echo
  --echo [on $_master_con]
  connection $_master_con;
  --echo
74
  SELECT NOW();
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
  --echo **** SHOW MASTER STATUS on $_master_con ****
  query_vertical SHOW MASTER STATUS;
  --echo
  --echo **** SHOW PROCESSLIST on $_master_con ****
  SHOW PROCESSLIST;
  --echo
  --echo **** SHOW BINLOG EVENTS on $_master_con ****
  eval SHOW BINLOG EVENTS IN '$master_binlog_name_sql';
  if (`SELECT '$master_binlog_name_io' != '$master_binlog_name_sql'`)
  {
    eval SHOW BINLOG EVENTS IN '$master_binlog_name_io';
  }

  connection $_con;
}