Details
-
Bug
-
Status: Done
-
Medium
-
Resolution: Fixed
-
2.5.0, 2.6.1
-
2
-
Yes
-
Yes
-
[obsolete] Portal
Description
==============Original Ticket======================
On a MySQL Community 5.6 server, slow log rotation is being performed incorrectly.
The agent is using the default setting (server-side config for rotation) and is rotating the slow query log without instructing MySQL server to cleanly handle this.
MySQL details:
$ mysql -Bse "show variables like '%slow%'; show variables like 'long%'; select @@version_comment, @@version" log_slow_admin_statements ON log_slow_slave_statements ON slow_launch_time 2 slow_query_log ON slow_query_log_file /var/lib/mysql/xxx-slow.log long_query_time 0.000000 MySQL Community Server (GPL) 5.6.47-log
Steps to reproduce:
- Configure pmm-agent to monitor MySQL using slowlog
- Monitor the slow log file along with the .old path, e.g.
Example check, log path is configured in full
slowlog=$(mysql -Bse "select @@slow_query_log_file") while [[ ! -f abort-slow-log-check ]] do ls -la "${slowlog}" "${slowlog}.old" | sed "s/^/$(date --iso-8601=seconds)\t/g" sleep 10 done | tee slow-log-check.log
- Run sysbench to rapidly generate content for the slow log, e.g.
Enough to quickly fill default size log
cat <<EOS > ${HOME}/.sysbench-config mysql-socket=/var/lib/mysql/mysql.sock mysql-user=REDACTED mysql-password=REDACTED mysql-db=REDACTED threads=5 tables=5 scale=5 EOS ./tpcc.lua --config-file=${HOME}/.sysbench-config prepare
The log will be rotated whilst still being written to.
=========================================================Original Ticket==============================
Bug Reproduced on 2.9.1/dev-latest, Steps to recreate are enough and detailed, reproduced the scenario with Mysql 8.x latest version, we need to update the documentation to mention the needed permission for slow log rotation.
How to test/QA?
add mysql instance for monitoring with slowlog enabled. In case of a mysql user that doesn't have reload privileges pmm agent will have the following error message in the log saying "RELOAD grant not enabled cannot rotate slowlog", if the mysql user is granted the RELOAD privilege this log message should disappear and slowlog rotation will continue