Some time ago, Peter Boros at Percona wrote this post: Rotating MySQL slow logs safely. It contains good info, such as that one should use the rename method for rotation (rather than copytruncate), and then connect to mysqld and issue a FLUSH LOGS (rather than send a SIGHUP signal).
So far so good. What I do not agree with is the additional construct to prevent slow queries from being written during log rotation. The author’s rationale is that if too many items get written while the rotation is in process, this can block threads. I understand this, but let’s review what actually happens.
Indeed, if one were to do lots of writes to the slow query log in a short space of time, a write could block while waiting.
Is the risk of this occurring greater during a logrotate operation? I doubt it. A FLUSH LOGS has to …
[Read more]