Bug #33693 general log name and location depend on PID file, not on predefined values
Submitted: 4 Jan 2008 15:48 Modified: 12 Nov 2009 19:51
Reporter: Giuseppe Maxia Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Logging Severity:S2 (Serious)
Version:5.0.45,5.1.23,6.0 OS:Any (Linux and Mac OS X)
Assigned to: Magne Mæhre CPU Architecture:Any
Tags: datadir, general, hostname, log, pid

[4 Jan 2008 15:48] Giuseppe Maxia
Description:
According to the manual, unless explicitly set, the general log is located in the data directory, and it is named after the hostname. 
http://dev.mysql.com/doc/refman/5.1/en/query-log.html

That is true only if there is no explicitly named PID file. If there is, the general log is named after the PID file, and it is located in the same directory.

For example, adding the following directives to the configuration file:

[mysqld]
pid-file=/tmp/unusual.pid
log

The general log will be located under /tmp/ and named "unusual.log"

There is a risk of denial of service, if the PID file is located in a directory with limited storage, which will be filled rapidly by a growing general log.

How to repeat:
Add the following directives to a configuration file:

[mysqld]
pid-file=/tmp/unusual.pid
log

if you are using 5.1, you can activate the general log on the fly instead of using the configuration file, and it will be named after the PID file anyway.

Suggested fix:
As a workaround, always specify the general log name.

The fix should differentiate between location of the PID file and the general log.
[4 Jan 2008 16:16] MySQL Verification Team
Thank you for the bug report.
[23 Jan 2008 23:39] Sveta Smirnova
Same problem with binary and relay logs.

See also bug #33881
[22 Oct 2008 18:57] Giuseppe Maxia
Bug#40263 was marked as duplicate of this one.
[31 Mar 2009 17:01] 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/70935

2760 Magne Mahre	2009-03-31
      Bug #33693 general log name and location depend on PID file, not on predefined values
            
      The default name of the PID file was constructed, as documented, 
      based on the hostname.  This name was subsequently used as the
      base for the general log file name.   If the name of the PID
      file was overridden in the configuration, and no explicit name
      was set for the general log file, the path location for the
      PID file was used also for the general log file.
            
      A new variable, 'def_logfile_name', has been introduced.  This name
      is constructed based on the hostname, and is then used to
      construct both the PID file and the general log file.
            
      The general log file will now, unless explicitly set, be
      located in the server data directory (as documentated in
      the server docs)
[1 Apr 2009 18:00] 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/71127

2761 Magne Mahre	2009-04-01
      Bug #33693 general log name and location depend on PID file, 
                 not on predefined values
                  
      The default name of the PID file was constructed, as documented, 
      based on the hostname.  This name was subsequently used as the
      base for the general log file name.   If the name of the PID
      file was overridden in the configuration, and no explicit name
      was set for the general log file, the path location for the
      PID file was used also for the general log file.
                  
      A new variable, 'default_logfile_name', has been introduced.  This name
      is constructed based on the hostname, and is then used to
      construct both the PID file and the general log file.
                  
      The general log file will now, unless explicitly set, be
      located in the server data directory (as documentated in
      the server docs)
     @ mysql-test/t/log_state.test
        run/mysqld.log was created as a consequence of this bug.
        After the fix it is no longer created, and will thus not
        be deleted.
[16 May 2009 8:41] Bugs System
Pushed into 6.0.12-alpha (revid:alik@sun.com-20090516083402-0avycdy7w6dnn0tv) (version source revid:serg@mysql.com-20090512164111-jz224w5781lhe7wd) (merge vers: 6.0.12-alpha) (pib:6)
[8 Jun 2009 19:53] Paul DuBois
Noted in 6.0.12 changelog.

The default values for the general query log and slow query log file
are documented to be based on the server host name and located in the
data directory. However, they were in fact being based on the 
basename and location of the process ID (PID) file. The name and
location defaults for the PID file are based on the server host name
and data directory, so if it was not assigned a different name
explicitly, its defaults were used and the general query log and slow
query log file defaults were as documented. But if the PID file was
assigned a value with the --pid-file option, the defaults for the
general query log and slow query log file were incorrect. This has
been rectified so that the defaults for all three files are based on
the server host name and data directory.

A remaining problem is that the binary log and relay log .NNNNNN and 
.index basename defaults are based on the PID file basename, contrary
to the documentation. This issue is to be addressed as Bug#45359.
[12 Oct 2009 13:35] 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/86582

2911 Magne Mahre	2009-10-12
      Bug #33693 general log name and location depend on PID file, 
                 not on predefined values
      
      The default name of the PID file was constructed, as documented, 
      based on the hostname.  This name was subsequently used as the
      base for the general log file name.   If the name of the PID
      file was overridden in the configuration, and no explicit name
      was set for the general log file, the path location for the
      PID file was used also for the general log file.
                        
      A new variable, 'default_logfile_name', has been introduced.  This name
      is constructed based on the hostname, and is then used to
      construct both the PID file and the general log file.
                        
      The general log file will now, unless explicitly set, be
      located in the server data directory (as documentated in
      the server docs)
     @ mysql-test/t/log_state.test
        run/mysqld.log was created as a consequence of this bug.
        After the fix it is no longer created, and will thus not
        be deleted.
[12 Oct 2009 13:36] Magne Mæhre
Pushed to 5.5.0
[12 Oct 2009 15:09] Paul DuBois
Noted in 5.5.0 changelog.
[3 Nov 2009 7:16] Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20091102151658-j9o4wgro47m5v84d) (version source revid:alik@sun.com-20091023064702-2f8jdmny61bdl94u) (merge vers: 6.0.14-alpha) (pib:13)
[3 Nov 2009 15:27] Paul DuBois
Already fixed in earlier 6.0.x release.
[12 Nov 2009 8:21] Bugs System
Pushed into 5.5.0-beta (revid:alik@sun.com-20091110093229-0bh5hix780cyeicl) (version source revid:mikael@mysql.com-20091103113702-p61dlwc6ml6fxg18) (merge vers: 5.5.0-beta) (pib:13)