~ubuntu-branches/ubuntu/natty/mysql-5.1/natty-proposed

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-02-22 08:30:45 UTC
  • mfrom: (1.4.1)
  • Revision ID: package-import@ubuntu.com-20120222083045-2rd53r4bnyx7qus4
Tags: 5.1.61-0ubuntu0.11.04.1
* SECURITY UPDATE: Update to 5.1.61 to fix multiple security issues
  (LP: #937869)
  - http://www.oracle.com/technetwork/topics/security/cpujan2012-366304.html
  - CVE-2011-2262
  - CVE-2012-0075
  - CVE-2012-0112
  - CVE-2012-0113
  - CVE-2012-0114
  - CVE-2012-0115
  - CVE-2012-0116
  - CVE-2012-0117
  - CVE-2012-0118
  - CVE-2012-0119
  - CVE-2012-0120
  - CVE-2012-0484
  - CVE-2012-0485
  - CVE-2012-0486
  - CVE-2012-0487
  - CVE-2012-0488
  - CVE-2012-0489
  - CVE-2012-0490
  - CVE-2012-0491
  - CVE-2012-0492
  - CVE-2012-0493
  - CVE-2012-0494
  - CVE-2012-0495
  - CVE-2012-0496

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
# Waits until SHOW SLAVE STATUS has returned a specified value, or
4
4
# until a timeout is reached.
5
5
#
 
6
#
6
7
# ==== Usage ====
7
8
#
8
 
# let $slave_param= Slave_SQL_Running;
9
 
# let $slave_param_value= No;
10
 
# source include/slave_wait_param.inc;
 
9
# --let $slave_param= Slave_SQL_Running
 
10
# --let $slave_param_value= No
 
11
# [--let $slave_param_comparison= [ < | <= | >= | > | = | != ]]
 
12
# [--let $slave_timeout= NUMBER]
 
13
# [--let $slave_error_param= [Slave_SQL_Errno | Slave_IO_Errno]]
 
14
# [--let $rpl_debug= 1]
 
15
# --source include/slave_wait_param.inc
11
16
#
12
17
# Parameters:
13
18
#
21
26
#   $slave_param_value.  If you want to wait until $slave_param
22
27
#   becomes *unequal* to $slave_param_value, set this parameter to the
23
28
#   string '!=', like this:
24
 
#     let $slave_param_comparison= !=;
 
29
#     --let $slave_param_comparison= !=
25
30
#
26
31
# $slave_timeout
27
32
#   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;
 
33
#   setting $slave_timeout. The unit is seconds.
 
34
#
 
35
# $slave_error_param
 
36
#   If set, this script will check if the column of the output from
 
37
#   SHOW SLAVE STATUS named $slave_error_param is nonzero.  If it is,
 
38
#   this script will faile immediately.  Typically, this should be set
 
39
#   to Last_IO_Errno or Last_SQL_Errno.
 
40
#
 
41
# $rpl_debug
 
42
#   See include/rpl_init.inc
 
43
 
 
44
 
 
45
--let $include_filename= wait_for_slave_param.inc [$slave_param]
 
46
--source include/begin_include_file.inc
 
47
 
 
48
 
 
49
let $_slave_timeout= $slave_timeout;
 
50
if (!$_slave_timeout)
 
51
{
 
52
  let $_slave_timeout= 300;
 
53
}
 
54
 
 
55
if (`SELECT '$slave_error_param' = ''`)
 
56
{
 
57
  --let $slave_error_param= 1
51
58
}
52
59
 
53
60
let $_slave_param_comparison= $slave_param_comparison;
56
63
  let $_slave_param_comparison= =;
57
64
}
58
65
 
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 ($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
 
  die;
82
 
}
 
66
if ($rpl_debug)
 
67
{
 
68
  --echo Waiting until '$slave_param' $_slave_param_comparison '$slave_param_value' [timeout='$_slave_timeout', \$slave_error_param='$slave_error_param']
 
69
}
 
70
 
 
71
--let $_slave_check_configured= query_get_value("SHOW SLAVE STATUS", Slave_IO_Running, 1)
 
72
 
 
73
if (`SELECT '$_slave_check_configured' = 'No such row'`)
 
74
{
 
75
  --echo **** ERROR: SHOW SLAVE STATUS returned empty result set. Slave not configured. ****
 
76
  --source include/show_rpl_debug_info.inc
 
77
  --die SHOW SLAVE STATUS returned empty result set. Slave not configured.
 
78
}
 
79
 
 
80
# mysqltest doesn't provide any better way to multiply by 10
 
81
--let $_wait_for_slave_param_zero= 0
 
82
--let $_slave_timeout_counter= $_slave_timeout$zero
 
83
--let $_slave_continue= 1
 
84
while ($_slave_continue)
 
85
{
 
86
  --let $_show_slave_status_value= query_get_value("SHOW SLAVE STATUS", $slave_param, 1)
 
87
 
 
88
  # Check if an error condition is reached.
 
89
  if (!$slave_error_param)
 
90
  {
 
91
    --let $_show_slave_status_error_value= query_get_value("SHOW SLAVE STATUS", $slave_error_param, 1)
 
92
    if ($_show_slave_status_error_value)
 
93
    {
 
94
      --echo **** ERROR: $slave_error_param = '$_show_slave_status_error_value' while waiting for slave parameter $slave_param $_slave_param_comparison $slave_param_value ****
 
95
      --source include/show_rpl_debug_info.inc
 
96
      --die Error condition reached in include/wait_for_slave_param.inc
 
97
    }
 
98
  }
 
99
 
 
100
  # Check if the termination condition is reached.
 
101
  --let $_slave_continue= `SELECT NOT('$_show_slave_status_value' $_slave_param_comparison '$slave_param_value')`
 
102
 
 
103
  # Decrease timer, and check if the timeout is reached.
 
104
  if ($_slave_continue)
 
105
  {
 
106
    --dec $_slave_timeout_counter
 
107
    if (!$_slave_timeout_counter)
 
108
    {
 
109
      --echo **** ERROR: timeout after $_slave_timeout seconds while waiting for slave parameter $slave_param $_slave_param_comparison $slave_param_value ****
 
110
      --source include/show_rpl_debug_info.inc
 
111
      --die Timeout in include/wait_for_slave_param.inc
 
112
    }
 
113
    --sleep  0.1
 
114
  }
 
115
}
 
116
 
 
117
 
 
118
--let $include_filename= wait_for_slave_param.inc [$slave_param]
 
119
--source include/end_include_file.inc