~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to mysql-test/include/wait_for_slave_param.inc

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# ==== Purpose ====
 
2
#
 
3
# Waits until SHOW SLAVE STATUS has returned a specified value, or
 
4
# until a timeout is reached.
 
5
#
 
6
# ==== Usage ====
 
7
#
 
8
# let $slave_param= Slave_SQL_Running;
 
9
# let $slave_param_value= No;
 
10
# source include/slave_wait_param.inc;
 
11
#
 
12
# Parameters:
 
13
#
 
14
# $slave_param, $slave_param_value
 
15
#   This macro will wait until the column of the output of SHOW SLAVE
 
16
#   STATUS named $slave_param gets the value $slave_param_value.  See
 
17
#   the example above.
 
18
#
 
19
# $slave_param_comparison
 
20
#   By default, this file waits until $slave_param becomes equal to
 
21
#   $slave_param_value.  If you want to wait until $slave_param
 
22
#   becomes *unequal* to $slave_param_value, set this parameter to the
 
23
#   string '!=', like this:
 
24
#     let $slave_param_comparison= !=;
 
25
#
 
26
# $slave_timeout
 
27
#   The default timeout is 5 minutes. You can change the timeout by
 
28
#   setting $slave_timeout. The unit is tenths of seconds.
 
29
#
 
30
# $master_connection
 
31
#   If the timeout is reached, debug info is given by calling SHOW
 
32
#   SLAVE STATUS, SHOW PROCESSLIST, and SHOW BINLOG EVENTS.  Then, a
 
33
#   'connection master' is then issued, and more debug info is given
 
34
#   by calling SHOW MASTER STATUS, SHOW PROCESSLIST, and SHOW BINLOG
 
35
#   EVENTS.  If $master_connection is set, the latter three commands
 
36
#   will be issued on $master_connection instead of on the host named
 
37
#   'master'.  See also show_rpl_debug_info.inc
 
38
#
 
39
# $slave_error_message
 
40
#   If set, this is printed when a timeout occurs. This is primarily
 
41
#   intended to be used by other wait_for_slave_* macros, to indicate
 
42
#   what the purpose of the wait was. (A very similar error message is
 
43
#   given by default, but the wait_for_slave_* macros use this to give
 
44
#   an error message identical to that in previous versions, so that
 
45
#   errors are easier searchable in the pushbuild history.)
 
46
 
 
47
let $_slave_timeout_counter= $slave_timeout;
 
48
if (!$_slave_timeout_counter)
 
49
{
 
50
  let $_slave_timeout_counter= 3000;
 
51
}
 
52
 
 
53
let $_slave_param_comparison= $slave_param_comparison;
 
54
if (`SELECT '$_slave_param_comparison' = ''`)
 
55
{
 
56
  let $_slave_param_comparison= =;
 
57
}
 
58
 
 
59
let $_show_slave_status_value= query_get_value("SHOW SLAVE STATUS", $slave_param, 1);
 
60
while (`SELECT NOT('$_show_slave_status_value' $_slave_param_comparison '$slave_param_value') AND $_slave_timeout_counter > 0`)
 
61
{
 
62
  dec $_slave_timeout_counter;
 
63
  if ($_slave_timeout_counter)
 
64
  {
 
65
    sleep 0.1;
 
66
    let $_show_slave_status_value= query_get_value("SHOW SLAVE STATUS", $slave_param, 1);
 
67
  }
 
68
}
 
69
 
 
70
# This has to be outside the loop until BUG#41913 has been fixed
 
71
if (!$_slave_timeout_counter)
 
72
{
 
73
  --echo **** ERROR: timeout after $slave_timeout seconds while waiting for slave parameter $slave_param $_slave_param_comparison $slave_param_value ****
 
74
  if (`SELECT '$slave_error_message' != ''`)
 
75
  {
 
76
    --echo Message: $slave_error_message
 
77
  }
 
78
  --echo Current connection is '$CURRENT_CONNECTION'
 
79
  echo Note: the following output may have changed since the failure was detected;
 
80
  source include/show_rpl_debug_info.inc;
 
81
  exit;
 
82
}