I just encountered the problem described in the title, on a server I don’t have enough free space for create a backup as long the replica is catching up, because the relay logs eats all the available free space as the IO thread works faster than the SQL thread in the replication.
What to do? First, we need to get rid of the current relay logs, and then limit the server to not create too much in the future. The relay logs are not meant for manual deletion so we stop the replica, purge the relay logs, set back the replica to the previous position and then restart the mysqld with the relay_log_space_limit variable set up.
mysql> STOP SLAVE; mysql> PAGER egrep "Relay_Master_Log_File|Exec_Master_Log_Pos" mysql> SHOW SLAVE STATUS\G mysql> RESET SLAVE ALL; mysql> CHANGE MASTER TO ... mysql> START SLAVE; mysql> ^d bash> echo "relay-log-space-limit = 10737418240" >>/etc/mysql/my.cnf #10G bash> systemctl mysql restart
As Jean-François Gagné pointed out (right) this is only applies on a really simple case when there is no GTID configured, no parallel replication exists, the slave is not delayed, no SSL, etc.etc.