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

photoid=15545|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 [url]MySQL :: MySQL 5.6 Reference Manual :: 5.1.7 Server System Variables

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.