When is bin-logs expired by expire_log_days?

I have Percona 5.5.25 server running with binlogging, no slaves, and a high change rate (~100GB binlogs/day, 1 to 6 GB/hour varying through the day).

The server is configured with expire_log_days=2 and max_binlog_size=1G.

I expected to see old binlogs be removed more or less in sync with new binlogs being created, but it seems the expiry happens only around four times a day, but not in strictly regular intervals. See the attached graph showing disk usage for the directory containing the binlogs.

Is this a bug or feature, or an artifact of something in my Mysql server that I fail to see? I see that I can work around this by implementing expiry through external cronbased purging, but it would be nice to keep the log handeling interal in Mysql.

kind regards,
-sigurd

attachment

expire_log_days takes into effect in two situations.

  1. During server startup if expire_log_days reached to it’s value.
  2. During log flush if expire_log_days reached to it’s value.

So, when log flushes it expires logs older than 48 hours as you set expire_log_days=2, check here for details http://dev.mysql.com/doc/refman/5.6/en/server-system-variables.html#sysvar_expire_logs_days

The next question then is when are logs flushed?

I know the binlog is flushed when it reaches max_binlog_size, which happens 1 to 6 times an hour on this system. But the flush that expires logs seems to happen only around four times a day, and not at the regualr intervals.