~ubuntu-branches/ubuntu/precise/mysql-5.5/precise-201203300109

« back to all changes in this revision

Viewing changes to mysql-test/suite/rpl/t/rpl_binlog_index.test

  • Committer: Package Import Robot
  • Author(s): Clint Byrum
  • Date: 2012-02-14 23:59:22 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20120214235922-cux5uek1e5l0hje9
Tags: 5.5.20-0ubuntu1
* New upstream release.
* d/mysql-server-5.5.mysql.upstart: Fix stop on to make sure mysql is
  fully stopped before shutdown commences. (LP: #688541) Also simplify
  start on as it is redundant.
* d/control: Depend on upstart version which has apparmor profile load
  script to prevent failure on upgrade from lucid to precise.
  (LP: #907465)
* d/apparmor-profile: need to allow /run since that is the true path
  of /var/run files. (LP: #917542)
* d/control: mysql-server-5.5 has files in it that used to be owned
  by libmysqlclient-dev, so it must break/replace it. (LP: #912487)
* d/rules, d/control: 5.5.20 Fixes segfault on tests with gcc 4.6,
  change compiler back to system default.
* d/rules: Turn off embedded libedit/readline.(Closes: #659566)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# ==== Purpose ====
 
2
#
 
3
# Test that server can work fine after moving binlog or relay log
 
4
# files to another directory and setting binlog or relay log paths to
 
5
# the new path.
 
6
 
7
# ==== Method ====
 
8
#
 
9
# Start replication, and then shutdown the master, move the binary
 
10
# logs and the log index file to a another directory and then restart
 
11
# the server with option to set the new binlog directory. After master
 
12
# restarted successfully, do the similar on slave to check the relay
 
13
# log of slave.
 
14
#
 
15
# ==== Reference ====
 
16
#
 
17
# BUG#12133 master.index file keeps mysqld from starting if bin log has been moved
 
18
# BUG#42576 Relay logs in relay-log.info&localhost-relay-bin.index not processed after move
 
19
 
 
20
source include/master-slave.inc;
 
21
# There is no need to run this test case on all binlog format
 
22
source include/have_binlog_format_row.inc;
 
23
 
 
24
# Since this test relies heavily on filesystem operations (like
 
25
# moving files around, backslashes and so forth) we avoid messing
 
26
# around with windows access violations for not cluttering the 
 
27
# test case any further. It is prepared to support windows, but
 
28
# it is not 100% compliant.
 
29
--source include/not_windows.inc
 
30
 
 
31
connection master;
 
32
--let $master_datadir= `select @@datadir`
 
33
connection slave;
 
34
--let $slave_datadir= `select @@datadir`
 
35
connection master;
 
36
--let $dirname= `select uuid()`
 
37
--let $tmpdir= $MYSQLTEST_VARDIR/tmp/$dirname
 
38
--mkdir $tmpdir
 
39
 
 
40
CREATE TABLE t1 (a INT);
 
41
# flush to generate one more binlog file.
 
42
FLUSH BINARY LOGS;
 
43
INSERT INTO t1 VALUES (1);
 
44
 
 
45
sync_slave_with_master;
 
46
 
 
47
#
 
48
# Test on master
 
49
#
 
50
connection master;
 
51
--echo # Shutdown master
 
52
--let $rpl_server_number=1
 
53
source include/rpl_stop_server.inc;
 
54
 
 
55
--echo # Move the master binlog files and the index file to a new place
 
56
--move_file $master_datadir/master-bin.000001 $tmpdir/master-bin.000001
 
57
--move_file $master_datadir/master-bin.000002 $tmpdir/master-bin.000002
 
58
--move_file $master_datadir/master-bin.index  $tmpdir/master-bin.index
 
59
 
 
60
--echo # Restart master with log-bin option set to the new path
 
61
--let $rpl_server_parameters=--log-bin=$tmpdir/master-bin
 
62
--let $keep_include_silent=1
 
63
source include/rpl_start_server.inc;
 
64
--let $keep_include_silent=0
 
65
 
 
66
--echo # Master has restarted successfully
 
67
 
 
68
#
 
69
# Test master can handle old format with directory path in index file
 
70
#
 
71
--let $is_windows= `select convert(@@version_compile_os using latin1) in ('Win32', 'Win64', 'Windows')`
 
72
 
 
73
# write_var_to_file.inc will call SELECT INTO DUMPFILE, which has to be
 
74
# done before shutdown the server
 
75
--echo # Create the master-bin.index file with the old format
 
76
--let $write_to_file= $master_datadir/master-bin.index
 
77
if ($is_windows)
 
78
{
 
79
  --let $write_var= .\\\\master-bin.000001\n.\\\\master-bin.000002\n.\\\\master-bin.000003\n
 
80
}
 
81
if (!$is_windows)
 
82
{
 
83
  --let $write_var= ./master-bin.000001\n./master-bin.000002\n./master-bin.000003\n
 
84
}
 
85
--disable_query_log
 
86
source include/write_var_to_file.inc;
 
87
--enable_query_log
 
88
 
 
89
--echo # Shutdown master
 
90
--let $rpl_server_number=1
 
91
source include/rpl_stop_server.inc;
 
92
 
 
93
--echo # Move back the master binlog files
 
94
--move_file $tmpdir/master-bin.000001 $master_datadir/master-bin.000001
 
95
--move_file $tmpdir/master-bin.000002 $master_datadir/master-bin.000002
 
96
--move_file $tmpdir/master-bin.000003 $master_datadir/master-bin.000003
 
97
 
 
98
--echo # Remove the unneeded master-bin.index file
 
99
--remove_file $tmpdir/master-bin.index
 
100
 
 
101
--echo # Restart master with log-bin option set to default
 
102
--let $rpl_server_parameters=--log-bin=$master_datadir/master-bin
 
103
--let $keep_include_silent=1
 
104
source include/rpl_start_server.inc;
 
105
--let $keep_include_silent=0
 
106
 
 
107
--echo # Master has restarted successfully
 
108
 
 
109
connection slave;
 
110
--echo # stop slave
 
111
--source include/stop_slave.inc
 
112
--let $rpl_server_number= 2
 
113
--source include/rpl_stop_server.inc
 
114
 
 
115
# switch to master because the slave has been shutdown
 
116
# and relocate_binlogs requires a running server to do
 
117
# SQL operations
 
118
--connection master
 
119
 
 
120
--let $relocate_disable_query_log= 1
 
121
--let $relocate_is_windows= $is_windows
 
122
--let $relocate_from=$slave_datadir
 
123
--let $relocate_into=$tmpdir
 
124
 
 
125
--echo # relocate  binlogs
 
126
--let $relocate_index_file=$slave_datadir/slave-bin.index
 
127
--source include/relocate_binlogs.inc
 
128
 
 
129
--echo # relocate  relay logs
 
130
--let $relocate_index_file=$slave_datadir/slave-relay-bin.index
 
131
--source include/relocate_binlogs.inc
 
132
 
 
133
--echo # Restart slave with options log-bin, relay-log set to the new paths
 
134
--let $rpl_server_parameters=--log-bin=$tmpdir/slave-bin --relay-log=$tmpdir/slave-relay-bin
 
135
--let $keep_include_silent=1
 
136
--let $rpl_server_number= 2
 
137
source include/rpl_start_server.inc;
 
138
--let $keep_include_silent=0
 
139
 
 
140
--connection slave
 
141
 
 
142
--echo # Slave server has restarted successfully
 
143
--source include/start_slave.inc
 
144
--source include/stop_slave.inc
 
145
 
 
146
connection master;
 
147
FLUSH LOGS;
 
148
INSERT INTO t1 VALUES (2);
 
149
INSERT INTO t1 VALUES (2);
 
150
INSERT INTO t1 VALUES (2);
 
151
INSERT INTO t1 VALUES (2);
 
152
 
 
153
FLUSH LOGS;
 
154
 
 
155
connection slave;
 
156
FLUSH LOGS;
 
157
--source include/start_slave.inc
 
158
connection master;
 
159
sync_slave_with_master;
 
160
--let $diff_tables= master:t1,slave:t1
 
161
source include/diff_tables.inc;
 
162
 
 
163
connection master;
 
164
DROP TABLE t1;
 
165
--sync_slave_with_master
 
166
--source include/stop_slave.inc
 
167
--let $rpl_server_number= 2
 
168
--source include/rpl_stop_server.inc
 
169
 
 
170
--connection master
 
171
 
 
172
--let $relocate_from=$tmpdir
 
173
--let $relocate_into=$slave_datadir
 
174
--let $relocate_recreate_index= 1
 
175
 
 
176
# binlogs
 
177
--let $relocate_index_file=$tmpdir/slave-bin.index
 
178
--source include/relocate_binlogs.inc
 
179
 
 
180
# relay logs
 
181
 
 
182
# since the complete fix for the relocation of logs is
 
183
# done in BUG#13428851 it does not help here to try 
 
184
# to start the slave as it would fail (relay-log.info is
 
185
# tainted with the full path in the RELAY_LOG_FILE position).
 
186
# Instead, we reset the slave and let the test clean up.
 
187
--let $relocate_fix_relay_log_info= $slave_datadir/relay-log.info
 
188
--let $relocate_index_file=$tmpdir/slave-relay-bin.index
 
189
--source include/relocate_binlogs.inc
 
190
 
 
191
--echo # remove tmpdir
 
192
--remove_files_wildcard $tmpdir *
 
193
--rmdir $tmpdir
 
194
 
 
195
--echo # restarted with previous slave settings
 
196
--let $rpl_server_parameters=--log-bin=$slave_datadir/slave-bin --relay-log=$slave_datadir/slave-relay-bin
 
197
--let $keep_include_silent=1
 
198
--let $rpl_server_number= 2
 
199
--source include/rpl_start_server.inc
 
200
--let $keep_include_silent=0
 
201
 
 
202
--connection slave
 
203
 
 
204
# The slave will restart if we have fixed the relay-log.info
 
205
# correctly
 
206
--source include/start_slave.inc
 
207
 
 
208
--connection master
 
209
--source include/rpl_end.inc