MySQL slave server not removing old relay binlogs

The expire_logs_days setting controls binary logging, not relay logging.

Normally, the relay logs are purged when the slave has finished applying the data from them. This can be changed with relay-log-purge, but it's default is 1.

If your slave is simply behind, it will continue to accumulate relay logs by design. You might want to consider setting relay-log-space-limit to prevent out of disk space problems. This setting provides a disk space limit for the IO thread to use for storing relay logs.


Make sure you haven't set relay_log_purge=0 in your configuration. I had set this option while troubleshooting a replication issue and forgot to remove it. Later we found the logs disk was filling up sue to the relay logs not being purged after being applied.

You can check and set the state of this variable dynamically like this:

> SELECT @@global.relay_log_purge;
+--------------------------+
| @@global.relay_log_purge |
+--------------------------+
|                        0 |
+--------------------------+

> SET @@global.relay_log_purge = 1;
Query OK, 0 rows affected (0.04 sec)

> SELECT @@global.relay_log_purge;
+--------------------------+
| @@global.relay_log_purge |
+--------------------------+
|                        1 |
+--------------------------+