Bug #23225 Slow query log: settiing slow_query_log_file writes to wrong file
Submitted: 12 Oct 2006 18:20 Modified: 8 Mar 2007 3:16
Reporter: Paul DuBois Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Logging Severity:S3 (Non-critical)
Version:5.1 bk OS:Linux (Linux)
Assigned to: Tomash Brechko CPU Architecture:Any
Tags: rt_q1_2007

[12 Oct 2006 18:20] Paul DuBois
Description:
If you set the general_log_file or slow_query_log file
system variables with the general log or slow query
log enabled, log output should go to the new file.
This works for general_log_file, but not for
slow_query_log_file. What happens instead is
that slow log output goes to the general log.

The example below shows how to demonstrate
this. Note that the example is restricted only to
showing that the initial slow log header lines go
to the general log. I suppose it's possible that
further slow log output would actually go to the
slow log, but there is still a bug.

How to repeat:
Initial configuration is that I have logging to files enabled for the general
query log and the slow query log:

mysql> show variables like '%log%';
...
| general_log                     | ON                            | 
| general_log_file                | qlog                          | 
...
| log                             | ON                            | 
| log_output                      | FILE                          | 
| log_slow_queries                | ON                            | 
...
| slow_query_log                  | ON                            | 
| slow_query_log_file             | slow-log                      | 
...

Now, switch to a different general log file:

mysql> set global general_log_file='/tmp/mylog';
Query OK, 0 rows affected (0.40 sec)

/tmp/mylog is created and its contents at this point look like this:

% cat /tmp/mylog
/var/mysql/50113/libexec/mysqld, Version: 5.1.13-beta-debug-log (Source distribution). started with:
Tcp port: 50113  Unix socket: /var/mysql/50113/mysql.sock
Time                 Id Command    Argument

Now, switch to a different slow query log file:

mysql> set global slow_query_log_file='/tmp/myslowlog';
Query OK, 0 rows affected (0.04 sec)

/tmp/myslowlog is *not* created, and the header lines that should
have been written to it have gone to /tmp/mylog:

% cat /tmp/mylog
/var/mysql/50113/libexec/mysqld, Version: 5.1.13-beta-debug-log (Source distribution). started with:
Tcp port: 50113  Unix socket: /var/mysql/50113/mysql.sock
Time                 Id Command    Argument
061012 12:47:53    1 Query      set global slow_query_log_file='/tmp/myslowlog'
/var/mysql/50113/libexec/mysqld, Version: 5.1.13-beta-debug-log (Source distribution). started with:
Tcp port: 50113  Unix socket: /var/mysql/50113/mysql.sock
Time                 Id Command    Argument

Now, switch to a different slow query log file again:

mysql> set global slow_query_log_file='/tmp/myslowlog2';
Query OK, 0 rows affected (0.03 sec)

Again, /tmp/myslowlog is *not* created, and the header lines that should
have been written to it have gone to /tmp/mylog:

% cat /tmp/mylog
/var/mysql/50113/libexec/mysqld, Version: 5.1.13-beta-debug-log (Source distribution). started with:
Tcp port: 50113  Unix socket: /var/mysql/50113/mysql.sock
Time                 Id Command    Argument
061012 12:47:53    1 Query      set global slow_query_log_file='/tmp/myslowlog'
/var/mysql/50113/libexec/mysqld, Version: 5.1.13-beta-debug-log (Source distribution). started with:
Tcp port: 50113  Unix socket: /var/mysql/50113/mysql.sock
Time                 Id Command    Argument
061012 12:48:12    1 Query      set global slow_query_log_file='/tmp/myslowlog2'
/var/mysql/50113/libexec/mysqld, Version: 5.1.13-beta-debug-log (Source distribution). started with:
Tcp port: 50113  Unix socket: /var/mysql/50113/mysql.sock
Time                 Id Command    Argument
[20 Oct 2006 19:50] Sveta Smirnova
Thank you for the report.

Verified as described on Linux using last BK sources.
[2 Feb 2007 11:28] 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/19234

ChangeSet@1.2416, 2007-02-02 14:21:04+03:00, kroki@moonlight.home +1 -0
  BUG#23225: Slow query log: setting slow_query_log_file writes to
             wrong file
  
  After execution of SET GLOBAL SLOW_QUERY_LOG_FILE=...; slow query log
  data would go into the general log file.
  
  The problem was in the bogus cut-n-paste in the code.
[3 Feb 2007 11:53] Tomash Brechko
The patch was reviewed and approved by e-mail.

Queued to 5.1-runtime.
[7 Mar 2007 22:06] Konstantin Osipov
Pushed into 5.1.17
[8 Mar 2007 3:16] Paul DuBois
Noted in 5.1.17 changelog.