Slow query log is rotated before it should when using max_slowlog_size
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Percona Server moved to https://jira.percona.com/projects/PS |
Fix Released
|
Medium
|
Sergei Glushchenko | ||
5.5 |
Fix Released
|
Medium
|
Sergei Glushchenko | ||
5.6 |
Fix Released
|
Medium
|
Sergei Glushchenko |
Bug Description
While using max_slowlog_size, the slow query log is rotated every time slow_query_log is enabled, not really checking if the current slow log is indeed bigger than max_slowlog_size or not. The queries are being correctly logged in the slow log, though I don't show that here, to keep it short.
See the following outputs to reproduce.
mysql> show variables like '%version%';
+------
| Variable_name | Value |
+------
| innodb_version | 5.6.22-rel71.0 |
| protocol_version | 10 |
| slave_type_
| version | 5.6.22-71.0-log |
| version_comment | Percona Server (GPL), Release 71.0, Revision 726 |
| version_
| version_compile_os | Linux |
+------
7 rows in set (0.00 sec)
mysql> show variables like 'max_slowlog_%';
+------
| Variable_name | Value |
+------
| max_slowlog_files | 0 |
| max_slowlog_size | 8192 |
+------
2 rows in set (0.00 sec)
mysql> show variables like 'slow_query_log%';
+------
| Variable_name | Value |
+------
| slow_query_log | ON |
| slow_query_
| slow_query_log_file | /home/agustin.
| slow_query_
| slow_query_
| slow_query_
+------
6 rows in set (0.00 sec)
shell> ls -o msandbox-slow-log*
-rw-rw---- 1 agustin.gallego 250 Jan 30 19:32 msandbox-
mysql> set global slow_query_log=0;
Query OK, 0 rows affected (0.00 sec)
mysql> set global slow_query_log=1;
Query OK, 0 rows affected (0.00 sec)
shell> ls -o msandbox-slow-log*
-rw-rw---- 1 agustin.gallego 250 Jan 30 19:32 msandbox-
-rw-rw---- 1 agustin.gallego 250 Jan 30 19:34 msandbox-
shell> cat msandbox-
/home/agustin.
Tcp port: 5622 Unix socket: /tmp/mysql_
Time Id Command Argument
This is also happening with latest percona server 5.5.
Let me know if you need any other outputs.
Agustín.
Hi Agustin, I'm unable to reproduce the same with PS 5.6.22 and 5.5.40 . Whenever I'm enable/disable slow log , it's not creating another slow log but add msg to the same file even if max_slowlog_size is 0 OR 8192. Is there anything specific in my.cnf which I need to mentioned?
For PS 5.6.22,
root@desktop: /var/lib/ mysql# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 37
Server version: 5.6.22-71.0-log Percona Server (GPL), Release 71.0, Revision 726
Copyright (c) 2009-2014 Percona LLC and/or its affiliates
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show variables like '%version%'; ------- ------- -----+- ------- ------- ------- ------- ------- ------- ------- + ------- ------- -----+- ------- ------- ------- ------- ------- ------- ------- + conversions | | compile_ machine | x86_64 | ------- ------- -----+- ------- ------- ------- ------- ------- ------- ------- +
+------
| Variable_name | Value |
+------
| innodb_version | 5.6.22-71.0 |
| protocol_version | 10 |
| slave_type_
| version | 5.6.22-71.0-log |
| version_comment | Percona Server (GPL), Release 71.0, Revision 726 |
| version_
| version_compile_os | debian-linux-gnu |
+------
7 rows in set (0.00 sec)
mysql> show variables like 'max_slowlog_%'; ------- ------+ ------- + ------- ------+ ------- + ------- ------+ ------- +
+------
| Variable_name | Value |
+------
| max_slowlog_files | 0 |
| max_slowlog_size | 8192 |
+------
2 rows in set (0.01 sec)
mysql> show variables like 'slow_query_log%'; ------- ------- ------- ------- --+---- ------- ------- ------- ------- -+ ------- ------- ------- ------- --+---- ------- ------- ------- ------- -+ log_always_ write_time | 10.000000 | mysql/desktop- slow.log | log_timestamp_ always | OFF | log_timestamp_ precision | second | log_use_ global_ control | | ------- ------- ------- ------- --+---- ------- ------- ------- ------- -+
+------
| Variable_name | Value |
+------
| slow_query_log | ON |
| slow_query_
| slow_query_log_file | /var/lib/
| slow_query_
| slow_query_
| slow_query_
+------
6 rows in set (0.00 sec)
mysql> set global slow_query_log=0;
Query OK, 0 rows affected (0.00 sec)
mysql> set global slow_query_log=1;
Query OK, 0 rows affected (0.00 sec)
mysql> set global slow_query_log=0;
Query OK, 0 rows affected (0.00 sec)
mysql> set global slow_query_log=1;
Query OK, 0 rows affected (0.00 sec)
mysql> set global slow_query_log=0...