Mysql – Why is the RDS thesql slow query log full of server restarts

amazon-rdsMySQLperformanceslow-log

One of my RDS mysql databases is giving me warnings about the slow query logs taking up significant space.

The logs are rotated once an hour, and contain a dozen repetitions of:

/rdsdbbin/mysql/bin/mysqld, Version: 5.6.13-log (MySQL Community Server (GPL)). started with:
Tcp port: 3306  Unix socket: /tmp/mysql.sock
Time                 Id Command    Argument

What could be causing this?

Best Answer

This is probably not cause for concern.

MySQL writes a new header to the file each time the logs are flushed. Presumably this is just in case you rotated the log file, so the new file will have a header... but it doesn't actually check whether it's a new file or not. The server does not have to restart to write this entry, so it doesn't mean the server is necessarily restarting.

The rdsadmin user you see in the processlist appears to be the supervisory connection that Amazon uses to monitor and manage each instance. Something -- presumably that connection -- periodically rotates the log files, most likely with some variant of FLUSH LOGS;. It sounds like the flush occurs more often than the rotate, which would exactly explain what you're seeing.

mysql> SHOW STATUS LIKE 'uptime';

This will give you the actual uptime of the instance in seconds. If that value is high, this is just the server writing a new header when the logs are being flushed to disk.