Bug #68466 Please implement --expire-logs-count=N as an alternate to --expire-logs-days
Submitted: 22 Feb 2013 20:44 Modified: 8 Mar 2013 11:35
Reporter: Chris Calender Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Logging Severity:S4 (Feature request)
Version:All OS:Any
Assigned to: CPU Architecture:Any
Tags: expire_logs_count, expire_logs_days, expire-logs-count, expire-logs-days

[22 Feb 2013 20:44] Chris Calender
Description:
Feature Request:

I would like to please request a new binary log removal option, similar to --expire-logs-days (expire_logs_days), but it would be --expire-logs-count=N, where one could specify the actual # of binary logs to keep.  This would purge binlog files when the count exceeds N.

There are multiple advantages to this new option:

1. You can more accurately account for space requirements this way (i.e., since one would already knwo the max binary log size and now the total number of binary logs that would exist).

2. You avoid the "Got fatal error 1236 from master when reading data from binary log: 'Could not find first log file name in binary log index file'" problem that occurs for those who use --expire-logs-days and use a backup older than --expire-logs-days (i.e., if you do that, which can be common in certain situations, your binary logs will be deleted immediately followed by the above error, and replication breaking.

How to repeat:
N/A

Suggested fix:
New option:

--expire-logs-count=N

1. ./sql/mysqld.h

extern ulong expire_logs_count;

2. ./sql/sys_vars.cc

static Sys_var_ulong Sys_expire_logs_count(
       "expire_logs_count",
       "If non-zero, binary logs will be purged when the count exceeds "
       "expire_logs_count days; possible purges happen at startup and "
       "at binary log rotation",
       GLOBAL_VAR(expire_logs_count),
       CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 99), DEFAULT(0), BLOCK_SIZE(1));

3. ./sql/mysqld.cc

ulong expire_logs_count = 0;
..
call to function like "MYSQL_BIN_LOG::purge_logs_before_date()" but "MYSQL_BIN_LOG::purge_logs_exceeding_count()"

4. ./sql/log.cc

Implement the "MYSQL_BIN_LOG::purge_logs_exceeding_count()" functionality.
[8 Mar 2013 11:35] Erlend Dahl
Thank you for the feature request.