Bug #32748 Inconsistent handling of assignments to general_log_file/slow_query_log_file
Submitted: 27 Nov 2007 1:54 Modified: 20 May 2008 23:15
Reporter: Paul Dubois Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Logging Severity:S3 (Non-critical)
Version:5.1 OS:Any
Assigned to: Alexander Nozdrin
Tags: general_log_file, slow_query_log_file
Triage: D3 (Medium)

[27 Nov 2007 1:54] Paul Dubois
Description:
The general_log_file and slow_query_log_file system variables indicate the names of the general query log and slow log files. These variables are dynamic and changing their values changes the name of the file to which the server writes the corresponding log.

However, it appears that there is some inconsistency about the treatment of relative filenames when you attempt to change their values. Sometimes it works, sometimes it does not.

How to repeat:
Start the server with the logs enabled, logging to files in the default
location (the data directory, which for my server is /usr/local/mysql/data):

[mysqld]
log-output=FILE
log=query-log
log-slow-queries=slow-log

Start the server and check the current values of the log file
variables:

mysql> SHOW VARIABLES LIKE '%log_file';
+---------------------+-----------+
| Variable_name       | Value     |
+---------------------+-----------+
| general_log_file    | query-log |
| slow_query_log_file | slow-log  |
+---------------------+-----------+
2 rows in set (0.00 sec)

I can set the log file variables to a relative value using
their current values:

mysql> SET GLOBAL general_log_file = 'query-log';
Query OK, 0 rows affected (0.01 sec)

mysql> SET GLOBAL slow_query_log_file = 'slow-log';
Query OK, 0 rows affected (0.00 sec)

But I cannot set the log file variables using a different relative
value:

mysql> SET GLOBAL general_log_file = 'query-log-new';
ERROR 1231 (42000): Variable 'general_log_file' can't be set to the value of
'query-log-new'                
mysql> SET GLOBAL slow_query_log_file = 'slow-log-new';
ERROR 1231 (42000): Variable 'slow_query_log_file' can't be set to the value
of 'slow-log-new'           

On the other hand, if I use the equivalent absolute filenames, it works:

mysql> SET GLOBAL general_log_file = '/usr/local/mysql/data/query-log-new';
Query OK, 0 rows affected (0.00 sec)

mysql> SET GLOBAL slow_query_log_file = '/usr/local/mysql/data/slow-log-new';
Query OK, 0 rows affected (0.00 sec)

mysql> SHOW VARIABLES LIKE '%log_file';
+---------------------+-------------------------------------+
| Variable_name       | Value                               |
+---------------------+-------------------------------------+
| general_log_file    | /usr/local/mysql/data/query-log-new |
| slow_query_log_file | /usr/local/mysql/data/slow-log-new  |
+---------------------+-------------------------------------+
2 rows in set (0.00 sec)

Suggested fix:
Allow relative pathnames consistently, and interpret them the same way the server does for the --log and --log-slow-queries options: Relative to the data directory.
[27 Nov 2007 11:09] Miguel Solorzano
Thank you for the bug report. Verified as described.
[28 Mar 2008 18:45] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/44616

ChangeSet@1.2579, 2008-03-28 21:46:18+03:00, anozdrin@quad.opbmk +3 -0
  Fix for Bug#32748: Inconsistent handling of assignments to
  general_log_file/slow_query_log_file.
  
  The problem was that log file path was rejected if directory
  path was empty. The fix is to reject log file path only if it
  is entirely empty.
[20 Apr 2008 13:00] Bugs System
Pushed into 6.0.6-alpha
[21 Apr 2008 17:34] Paul Dubois
Noted in 6.0.6 changelog.

Assignment of relative pathnames to general_log_file or
slow_query_log_file did not always work.

Resetting report to PQ waiting for push into 5.1.x.
[20 May 2008 18:23] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/46886

ChangeSet@1.2650, 2008-05-20 22:23:58+04:00, kostja@bodhi.(none) +7 -0
  A number of fixes after a merge from the main 5.1 tree:
  the local tree contains a fix for 
  Bug#32748 "Inconsistent handling of assignments to 
  general_log_file/slow_query_log_file",
  which changes output of a number of tests.
[20 May 2008 21:22] Bugs System
Pushed into 5.1.25-rc
[20 May 2008 23:15] Paul Dubois
Noted in 5.1.25 changelog.
[22 May 2008 9:49] Bugs System
Pushed into 6.0.6-alpha
[28 Jul 2008 16:52] Bugs System
Pushed into 5.1.25-rc  (revid:sp1r-kostja@bodhi.(none)-20080520182358-10647) (version source revid:sp1r-kostja@bodhi.(none)-20080520182358-10647) (pib:3)
[30 Jan 2013 10:15] Melvyn Sopacua
For those arriving here like me, you will also get this cryptic message when your target directy does not exist or cannot be reached by the mysql user (ESEARCH or ENOENT) or when mysql does not have permission to write in the target directory (EPERM or EACCESS).