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