| 1 |
# Test of options max_binlog_size and max_relay_log_size and |
| 2 |
# how they act (if max_relay_log_size == 0, use max_binlog_size |
| 3 |
# for relay logs too). |
| 4 |
# Test of manual relay log rotation with FLUSH LOGS. |
| 5 |
|
| 6 |
# Requires statement logging |
| 7 |
-- source include/master-slave.inc |
| 8 |
|
| 9 |
connection slave; |
| 10 |
stop slave; |
| 11 |
connection master; |
| 12 |
|
| 13 |
--echo # |
| 14 |
--echo # Generate a big enough master's binlog to cause relay log rotations |
| 15 |
--echo # |
| 16 |
|
| 17 |
create table t1 (a int); |
| 18 |
let $1=800; |
| 19 |
disable_query_log; |
| 20 |
begin; |
| 21 |
while ($1) |
| 22 |
{ |
| 23 |
# eval means expand $ expressions |
| 24 |
eval insert into t1 values( $1 ); |
| 25 |
dec $1; |
| 26 |
} |
| 27 |
enable_query_log; |
| 28 |
drop table t1; |
| 29 |
save_master_pos; |
| 30 |
connection slave; |
| 31 |
reset slave; |
| 32 |
|
| 33 |
--echo # |
| 34 |
--echo # Test 1 |
| 35 |
--echo # |
| 36 |
|
| 37 |
set @my_max_binlog_size= @@global.max_binlog_size, @my_max_relay_log_size=@@global.max_relay_log_size; |
| 38 |
set global max_binlog_size=8192; |
| 39 |
set global max_relay_log_size=8192-1; # mapped to 4096 |
| 40 |
select @@global.max_relay_log_size; |
| 41 |
start slave; |
| 42 |
sync_with_master; |
| 43 |
--source include/check_slave_is_running.inc |
| 44 |
|
| 45 |
--echo # |
| 46 |
--echo # Test 2 |
| 47 |
--echo # |
| 48 |
|
| 49 |
stop slave; |
| 50 |
reset slave; |
| 51 |
set global max_relay_log_size=(5*4096); |
| 52 |
query_vertical select @@global.max_relay_log_size; |
| 53 |
start slave; |
| 54 |
sync_with_master; |
| 55 |
--source include/check_slave_is_running.inc |
| 56 |
|
| 57 |
--echo # |
| 58 |
--echo # Test 3: max_relay_log_size = 0 |
| 59 |
--echo # |
| 60 |
|
| 61 |
stop slave; |
| 62 |
reset slave; |
| 63 |
set global max_relay_log_size=0; |
| 64 |
query_vertical select @@global.max_relay_log_size; |
| 65 |
start slave; |
| 66 |
sync_with_master; |
| 67 |
--source include/check_slave_is_running.inc |
| 68 |
|
| 69 |
--echo # |
| 70 |
--echo # Test 4: Tests below are mainly to ensure that we have not coded with wrong assumptions |
| 71 |
--echo # |
| 72 |
|
| 73 |
stop slave; |
| 74 |
reset slave; |
| 75 |
# test of relay log rotation when the slave is stopped |
| 76 |
# (to make sure it does not crash). |
| 77 |
flush logs; |
| 78 |
|
| 79 |
--echo # |
| 80 |
--echo # Test 5 |
| 81 |
--echo # |
| 82 |
|
| 83 |
reset slave; |
| 84 |
start slave; |
| 85 |
sync_with_master; |
| 86 |
# test of relay log rotation when the slave is started |
| 87 |
flush logs; |
| 88 |
# We have now easy way to be sure that the SQL thread has now deleted the |
| 89 |
# log we just closed. But a trick to achieve this is do an update on the master. |
| 90 |
connection master; |
| 91 |
create table t1 (a int); |
| 92 |
sync_slave_with_master; |
| 93 |
--source include/check_slave_is_running.inc |
| 94 |
|
| 95 |
--echo # |
| 96 |
--echo # Test 6: one more rotation, to be sure Relay_Log_Space is correctly updated |
| 97 |
--echo # |
| 98 |
|
| 99 |
flush logs; |
| 100 |
connection master; |
| 101 |
drop table t1; |
| 102 |
sync_slave_with_master; |
| 103 |
--source include/check_slave_is_running.inc |
| 104 |
|
| 105 |
connection master; |
| 106 |
# test that the absence of relay logs does not make a master crash |
| 107 |
flush logs; |
| 108 |
source include/show_master_status.inc; |
| 109 |
|
| 110 |
# Restore max_binlog_size |
| 111 |
connection slave; |
| 112 |
set global max_binlog_size= @my_max_binlog_size; |
| 113 |
set global max_relay_log_size= @my_max_relay_log_size; |
| 114 |
|
| 115 |
--echo # |
| 116 |
--echo # End of 4.1 tests |
| 117 |
--echo # |
| 118 |
--source include/rpl_end.inc |