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
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
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
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;
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
32
--let $master_datadir= `select @@datadir`
34
--let $slave_datadir= `select @@datadir`
36
--let $dirname= `select uuid()`
37
--let $tmpdir= $MYSQLTEST_VARDIR/tmp/$dirname
40
CREATE TABLE t1 (a INT);
41
# flush to generate one more binlog file.
43
INSERT INTO t1 VALUES (1);
45
sync_slave_with_master;
51
--echo # Shutdown master
52
--let $rpl_server_number=1
53
source include/rpl_stop_server.inc;
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
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
66
--echo # Master has restarted successfully
69
# Test master can handle old format with directory path in index file
71
--let $is_windows= `select convert(@@version_compile_os using latin1) in ('Win32', 'Win64', 'Windows')`
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
79
--let $write_var= .\\\\master-bin.000001\n.\\\\master-bin.000002\n.\\\\master-bin.000003\n
83
--let $write_var= ./master-bin.000001\n./master-bin.000002\n./master-bin.000003\n
86
source include/write_var_to_file.inc;
89
--echo # Shutdown master
90
--let $rpl_server_number=1
91
source include/rpl_stop_server.inc;
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
98
--echo # Remove the unneeded master-bin.index file
99
--remove_file $tmpdir/master-bin.index
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
107
--echo # Master has restarted successfully
111
--source include/stop_slave.inc
112
--let $rpl_server_number= 2
113
--source include/rpl_stop_server.inc
115
# switch to master because the slave has been shutdown
116
# and relocate_binlogs requires a running server to do
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
125
--echo # relocate binlogs
126
--let $relocate_index_file=$slave_datadir/slave-bin.index
127
--source include/relocate_binlogs.inc
129
--echo # relocate relay logs
130
--let $relocate_index_file=$slave_datadir/slave-relay-bin.index
131
--source include/relocate_binlogs.inc
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
142
--echo # Slave server has restarted successfully
143
--source include/start_slave.inc
144
--source include/stop_slave.inc
148
INSERT INTO t1 VALUES (2);
149
INSERT INTO t1 VALUES (2);
150
INSERT INTO t1 VALUES (2);
151
INSERT INTO t1 VALUES (2);
157
--source include/start_slave.inc
159
sync_slave_with_master;
160
--let $diff_tables= master:t1,slave:t1
161
source include/diff_tables.inc;
165
--sync_slave_with_master
166
--source include/stop_slave.inc
167
--let $rpl_server_number= 2
168
--source include/rpl_stop_server.inc
172
--let $relocate_from=$tmpdir
173
--let $relocate_into=$slave_datadir
174
--let $relocate_recreate_index= 1
177
--let $relocate_index_file=$tmpdir/slave-bin.index
178
--source include/relocate_binlogs.inc
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
191
--echo # remove tmpdir
192
--remove_files_wildcard $tmpdir *
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
204
# The slave will restart if we have fixed the relay-log.info
206
--source include/start_slave.inc
209
--source include/rpl_end.inc