Details
-
Type:
Bug
-
Status: Open
-
Priority:
Minor
-
Resolution: Unresolved
-
Affects Version/s: 5.5.39, 10.0.13
-
Component/s: None
-
Labels:
-
Environment:Debian Wheezy amd64
Description
The logs flushing commands of mysqladmin are issuing queries on the server such as "FLUSH LOGS;" but only display an error message on STDOUT/STDERR and return an error code if the query cannot be issued, not if the query itself returns an error.
The problem could also be present for other commands of mysqladmin.
–
Trying to run "FLUSH SLOW LOGS;" from the CLI returns an error telling that the file is not found :
# mysql -e 'SET GLOBAL slow_query_log_file = "/var/log/mysql/mariadb-slow.log";' # lsof -n |grep -m1 mariadb-slow\.log mysqld 26457 mysql 534w REG 254,0 2467 8636193 /var/log/mysql/mariadb-slow.log # chmod 000 /var/log/mysql/mariadb-slow.log # mysql -e 'FLUSH SLOW LOGS;' ERROR 29 (HY000) at line 1: File '/var/log/mysql/mariadb-slow.log' not found (Errcode: 13) # echo $? 1 # tail /var/log/syslog |tac |grep -m1 mariadb-slow\.log Sep 22 22:24:54 hostname mysqld: 140422 22:24:54 [ERROR] Could not use /var/log/mysql/mariadb-slow.log for logging (error 13). Turning logging off for the whole duration of the MySQL server process. To turn it on again: fix the cause, shutdown the MySQL server and restart it.
Running "mysqladmin flush-slow-log" doesnt return an error code and no error message on STDOUT or STDERR, the only way to know that something went wrong is to check what mysqld logged :
# chmod 600 /var/log/mysql/mariadb-slow.log # mysql -e 'SET GLOBAL slow_query_log_file = "/var/log/mysql/mariadb-slow.log";' # lsof -n |grep -m1 mariadb-slow\.log mysqld 26457 mysql 534w REG 254,0 205 8636193 /var/log/mysql/mariadb-slow.log # chmod 000 /var/log/mysql/mariadb-slow.log # mysqladmin flush-slow-log # echo $? 0 # tail /var/log/syslog |tac |grep -m1 mariadb-slow\.log Sep 22 22:40:32 hostname mysqld: 140422 22:40:32 [ERROR] Could not use /var/log/mysql/mariadb-slow.log for logging (error 13). Turning logging off for the whole duration of the MySQL server process. To turn it on again: fix the cause, shutdown the MySQL server and restart it.
Expected result :
When mysqladmin has an error returned on one of the query it executed, print the error message on STDERR and issue a return code <> 0 so the user or script that ran mysqladmin can be aware that something didnt work as expected without having to manually check the error_log.
nb: the error log is set to syslog on the example server.
Gliffy Diagrams
Attachments
Issue Links
Activity
- All
- Comments
- Work Log
- History
- Activity
- Transitions
It prints the error just fine to me:
Did you run a "clean" test – that is, after trying FLUSH SLOW LOGS via the client, did you made the log file writable, enabled slow_query_log again, and only then tried mysqladmin?
if you didn't, the test is irrelevant – as the error message you quoted says, after you attempted to flush logs for the first time, slow query log was turned off, so subsequent attempts to flush it, be it via the client or mysqladmin, won't fail.