mirror of
https://github.com/MariaDB/server.git
synced 2025-01-31 19:11:46 +01:00
27601fc5ee
FLUSH LOGS now rotates relay logs, and a new variable max_relay_log_size. Plus a very small bit of code cleaning. libmysqld/lib_sql.cc: open_log has no default arguments anymore. mysql-test/r/rpl_flush_log_loop.result: result update now that FLUSH LOGS rotates relay logs. mysql-test/r/rpl_log.result: result update now that FLUSH LOGS rotates relay logs. mysql-test/r/rpl_rotate_logs.result: result update now that max_binlog_size is 4096. mysql-test/t/rpl_rotate_logs-master.opt: now max_binlog_size must be a multiple of 4096 (see change in mysqld.cc) sql/log.cc: Got rid of default arguments of various MYSQL_LOG methods (the default arguments made code reading uneasy). Set max_size in ::init(). New function set_max_size() to set max_size of a MYSQL_LOG on-the-fly. More DBUG info. sql/mysql_priv.h: no defaults in open_log(). New variables max_relay_log_size. sql/mysqld.cc: New variable and option max_relay_log_size. max_binlog_size and max_relay_log_size are multiples of IO_SIZE. No more default arguments for log functions. sql/set_var.cc: New variable max_relay_log_size. If it is 0, then max_binlog_size will apply to relay logs. When one of these variables is changed, fix_max_%log_size is called to update max_size of the binary and/or relay logs. sql/slave.cc: New function rotate_relay_log(). sql/slave.h: New function rotate_relay_log(). sql/sql_class.h: New member max_size of MYSQL_LOG (for automatic rotation). New method set_max_size() for setting on-the-fly. sql/sql_parse.cc: Flush the relay log in FLUSH LOGS.
81 lines
1.9 KiB
Text
81 lines
1.9 KiB
Text
# Test of options max_binlog_size and max_relay_log_size and
|
|
# how they act (if max_relay_log_size == 0, use max_binlog_size
|
|
# for relay logs too).
|
|
# Test of manual relay log rotation with FLUSH LOGS.
|
|
|
|
source include/master-slave.inc;
|
|
connection slave;
|
|
stop slave;
|
|
connection master;
|
|
# Generate a big enough master's binlog to cause relay log rotations
|
|
create table t1 (a int);
|
|
let $1=800;
|
|
disable_query_log;
|
|
begin;
|
|
while ($1)
|
|
{
|
|
# eval means expand $ expressions
|
|
eval insert into t1 values( $1 );
|
|
dec $1;
|
|
}
|
|
enable_query_log;
|
|
drop table t1;
|
|
save_master_pos;
|
|
connection slave;
|
|
reset slave;
|
|
set global max_binlog_size=8192;
|
|
set global max_relay_log_size=8192-1; # mapped to 4096
|
|
select @@global.max_relay_log_size;
|
|
start slave;
|
|
sync_with_master;
|
|
show slave status;
|
|
stop slave;
|
|
reset slave;
|
|
set global max_relay_log_size=(5*4096);
|
|
select @@global.max_relay_log_size;
|
|
start slave;
|
|
sync_with_master;
|
|
show slave status;
|
|
stop slave;
|
|
reset slave;
|
|
set global max_relay_log_size=0;
|
|
select @@global.max_relay_log_size;
|
|
start slave;
|
|
sync_with_master;
|
|
show slave status;
|
|
|
|
# Tests below are mainly to ensure that we have not coded with wrong assumptions
|
|
|
|
stop slave;
|
|
reset slave;
|
|
# test of relay log rotation when the slave is stopped
|
|
# (to make sure it does not crash).
|
|
flush logs;
|
|
show slave status;
|
|
|
|
reset slave;
|
|
start slave;
|
|
sync_with_master;
|
|
# test of relay log rotation when the slave is started
|
|
flush logs;
|
|
# We have now easy way to be sure that the SQL thread has now deleted the
|
|
# log we just closed. But a trick to achieve this is do an update on the master.
|
|
connection master;
|
|
create table t1 (a int);
|
|
save_master_pos;
|
|
connection slave;
|
|
sync_with_master;
|
|
show slave status;
|
|
# one more rotation, to be sure Relay_log_space is correctly updated
|
|
flush logs;
|
|
connection master;
|
|
drop table t1;
|
|
save_master_pos;
|
|
connection slave;
|
|
sync_with_master;
|
|
show slave status;
|
|
|
|
connection master;
|
|
# test that the absence of relay logs does not make a master crash
|
|
flush logs;
|
|
show master status;
|