What I do when a replicated database slave's relay log partition has filled up

You have a replicated database but the slave’s relay log partition has filled up (probably because Ubuntu default partitioning has /var/log in its own partition). You now have a broken slave with corrupt logs. What do you do?

  1. Move relay log file position (it’s the relay-log setting) in my.cnf and restart MySQL.
  2. Open a MySQL root client (# mysql -u root -p)
  3. Run SHOW SLAVE STATUS\G to get the current Exec_Master_Log_Pos and Master_Log_File
  4. Use CHANGE MASTER TO and set the MASTER_LOG_FILE and MASTER_LOG_POS to the settings from #3.
  5. Run START SLAVE; to get things going again.

This works because of this piece of documentation:

CHANGE MASTER deletes all relay log files and starts a new one, unless you specify RELAY_LOG_FILE or RELAY_LOG_POS. In that case, relay logs are kept; the relay_log_purge global variable is set silently to 0.

It’s not Ruby, but it is Rails; not everything in Rails is programming.