mirror of
https://github.com/MariaDB/server.git
synced 2025-02-12 00:15:35 +01:00
![Monty](/assets/img/avatar_default.png)
binlog_space_limit is a variable in Percona server used to limit the total size of all binary logs. This implementation is based on code from Percona server 5.7. In MariaDB we decided to call the variable max-binlog-total-size to be similar to max-binlog-size. This makes it easier to find in the output from 'mariadbd --help --verbose'). MariaDB will also support binlog_space_limit for compatibility with Percona. Some internal notes to explain implementation notes: - When running MariaDB does not delete binary logs that are either used by slaves or have active xid that are not yet committed. Some implementation notes: - max-binlog-total-size is by default 0 (no limit). - max-binlog-total-size can be changed without server restart. - Binlog file sizes are checked on startup, or if max-binlog-total-size is set to a value > 0, not for every log write. The total size of all binary logs is cached and dynamically updated when updating the binary log on binary log rotation. - max-binlog-total-size is checked against existing log files during serverstart, binlog rotation, FLUSH LOGS, when writing to binary log or when max-binlog-total-size changes value. - Option --slave-connections-needed-for-purge with 1 as default added. This allows one to ensure that we do not delete binary logs if there is less than 'slave-connections-needed-for-purge' connected. Without this option max-binlog-total-size would potentially delete binlogs needed by slaves on server startup or when a slave disconnects as there are then no connected slaves to protect active binlogs. - PURGE BINARY LOGS TO ... will be executed as if slave-connectitons-needed-for-purge would be zero. In other words it will do the purge even if there is no slaves connected. If there are connected slaves working on the logs, these will be protected. - If binary log is on and max-binlog-total_size <> 0 then the status variable 'Binlog_disk_use' shows the current size of all old binary logs + the state of the current one. - Removed test of strcmp(log_file_name, log_info.log_file_name) in purge_logs_before_date() as this is tested in can_purge_logs() - To avoid expensive calls of log_in_use() we cache the result for the last log that is in use by a slave. Future calls to can_purge_logs() for this binary log will be quickly detected and false will be returned until a slave starts working on a new log. - Note that after a binary log rotation caused by max_binlog_size, the last log will not be purged directly as it is still in use internally. The next binary log write will purge binlogs if needed. Reviewer:Kristian Nielsen <knielsen@knielsen-hq.org>
103 lines
3.3 KiB
PHP
103 lines
3.3 KiB
PHP
# ==== Purpose ====
|
|
#
|
|
# Test one scenario using a combination of --expire-logs-days and
|
|
# --binlog-expire-logs-seconds. Verify that there are/aren't warnings
|
|
# as expected, and verify that the values of the global variables are
|
|
# as expected.
|
|
#
|
|
# ==== Usage ====
|
|
#
|
|
# --let $ofile = FILE
|
|
# --let $options = SERVER_OPTIONS
|
|
# --let $days = VALUE
|
|
# --let $seconds = VALUE
|
|
# --let $expect_binlog_off_days_and_seconds_warning = [0|1]
|
|
# --let $expect_seconds = VALUE
|
|
# --let $option_invoke_order = [days_then_seconds|seconds_then_days]
|
|
# --let $expect_days = VALUE
|
|
# --source include/binlog_expire_warnings.inc
|
|
#
|
|
# Parameters:
|
|
#
|
|
# $ofile
|
|
# Temporary file to use for the error log.
|
|
#
|
|
# $options
|
|
# Any additional options passed to mysqld during server start.
|
|
#
|
|
# $days
|
|
# The value to set for --expire-logs-days
|
|
#
|
|
# $seconds
|
|
# The value to set for --binlog-expire-logs-seconds
|
|
#
|
|
# $option_invoke_order
|
|
# In which order options --expire-logs-days and
|
|
# --binlog-expire-logs-seconds should be set.
|
|
# values are: days_then_seconds, seconds_then_days
|
|
#
|
|
# $expect_binlog_off_days_and_seconds_warning
|
|
# If zero, assert that there is no warning due to using
|
|
# --expire_logs_days or --binlog_expire_logs_seconds binlog disabled.
|
|
# If nonzero, assert that there is a warning due to using
|
|
# --expire_logs_days or --binlog_expire_logs_seconds binlog disabled.
|
|
#
|
|
# $expect_days
|
|
# Assert that @@global.expire_logs_days has this value.
|
|
#
|
|
# $expect_seconds
|
|
# Assert that @@global.binlog_expire_logs_seconds has this value.
|
|
|
|
|
|
--let $restart_parameters = --log-error=$ofile $options
|
|
if ($option_invoke_order == 'days_then_seconds')
|
|
{
|
|
if ($days != '') {
|
|
--let $restart_parameters = $restart_parameters --expire_logs_days=$days
|
|
}
|
|
if ($seconds != '') {
|
|
--let $restart_parameters = $restart_parameters --binlog-expire-logs-seconds=$seconds
|
|
}
|
|
}
|
|
|
|
if ($option_invoke_order == 'seconds_then_days')
|
|
{
|
|
if ($seconds != '') {
|
|
--let $restart_parameters = $restart_parameters --binlog-expire-logs-seconds=$seconds
|
|
}
|
|
if ($days != '') {
|
|
--let $restart_parameters = $restart_parameters --expire_logs_days=$days
|
|
}
|
|
}
|
|
|
|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
|
--source include/restart_mysqld.inc
|
|
|
|
# For all the assert_grep.inc
|
|
--let $extra_debug_eval = LOAD_FILE("$ofile")
|
|
|
|
if (!$expect_binlog_off_days_and_seconds_warning) {
|
|
--let $assert_text = There shall be no binlog_off+seconds warning
|
|
--let $assert_count = 0
|
|
}
|
|
|
|
if ($expect_binlog_off_days_and_seconds_warning) {
|
|
--let $assert_text = There shall be a binlog_off+seconds warning
|
|
--let $assert_count = 1
|
|
}
|
|
|
|
--let $assert_file = $ofile
|
|
--let $assert_select = You need to use --log-bin to make --expire-logs-days, --binlog-expire-logs-seconds or --max-binlog-total-size work.
|
|
--let $assert_only_after = Shutdown complete
|
|
--source include/assert_grep.inc
|
|
|
|
# For all the assert.inc
|
|
--let $extra_debug_eval = CONCAT("days: ", @@global.expire_logs_days, " seconds: ", @@global.binlog_expire_logs_seconds)
|
|
|
|
--let $assert_text = binlog_expire_logs_seconds shall be $expect_seconds
|
|
--let $assert_cond = @@global.binlog_expire_logs_seconds = $expect_seconds
|
|
--source include/assert.inc
|
|
|
|
--let $assert_text = expire_logs_days shall be $expect_days
|
|
--let $assert_cond = @@global.expire_logs_days = $expect_days
|
|
--source include/assert.inc
|