Bug #68808 Documentation does not reflect dependency of log file locations on pid_file
Submitted: 28 Mar 2013 19:56 Modified: 1 Apr 2013 18:12
Reporter: Kolbe Kegel Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version:5.0, 5.1 OS:Any
Assigned to: Paul DuBois CPU Architecture:Any

[28 Mar 2013 19:56] Kolbe Kegel
Description:
The Reference Manual at https://dev.mysql.com/doc/refman/5.1/en/query-log.html and http://dev.mysql.com/doc/refman/5.1/en/slow-query-log.html continues to state "The server creates the file in the data directory unless an absolute path name is given to specify a different directory" despite the conclusion in http://bugs.mysql.com/bug.php?id=33693 that the location of these files in fact depend on the value of pid_file.

How to repeat:
Start MySQL with --pid-file=/tmp/mysqld.pid --general-log --slow-query-log and observe that those logs are created in /tmp alongside the pid file.

Suggested fix:
The documentation for MySQL 5.0 and 5.1 should be updated to reflect that the location of various log files, including the general log and slow query log depend on the value of pid_file.
[28 Mar 2013 20:12] Kolbe Kegel
It's not just coincidental that the location of these log files depends on pid_file, either, it's very explicit in the source code (sql/mysqld.cc):

char *make_default_log_name(char *buff,const char* log_ext)
{
  strmake(buff, pidfile_name, FN_REFLEN-5);
  return fn_format(buff, buff, mysql_data_home, log_ext,
                   MYF(MY_UNPACK_FILENAME|MY_REPLACE_EXT));
}

  FIX_LOG_VAR(opt_logname,
              make_default_log_name(buff, ".log"));
  FIX_LOG_VAR(opt_slow_logname,
              make_default_log_name(buff, "-slow.log"));
[29 Mar 2013 9:03] MySQL Verification Team
Hello Kolbe,

Thank you for the report.
Verified as described.

Thanks,
Umesh
[29 Mar 2013 9:04] MySQL Verification Team
### Confirmed in 5.1.68(latest GA)

[root@cluster-repo mysql-5.1.68]# bin/mysqld_safe --datadir=/tmp/data --user=mysql --pid-file=/tmp/mysqld.pid --general-log --slow-query-log &
[1] 5900
[root@cluster-repo mysql-5.1.68]# 130330 12:30:32 mysqld_safe Logging to '/var/log/mysqld.log'.
130330 12:30:32 mysqld_safe Starting mysqld daemon with databases from /tmp/data

[root@cluster-repo mysql-5.1.68]# ls -l /tmp/
drwx------ 4 mysql root    4096 Mar 30 12:30 data
-rw-rw---- 1 mysql mysql    209 Mar 30 12:30 mysqld.log
-rw-rw---- 1 mysql mysql      5 Mar 30 12:30 mysqld.pid
-rw-rw---- 1 mysql mysql    209 Mar 30 12:30 mysqld-slow.log

###

mysql> show global variables like 'pid_file';
+---------------+-----------------+
| Variable_name | Value           |
+---------------+-----------------+
| pid_file      | /tmp/mysqld.pid |
+---------------+-----------------+
1 row in set (0.00 sec)

mysql> show global variables like 'datadir';
+---------------+------------+
| Variable_name | Value      |
+---------------+------------+
| datadir       | /tmp/data/ |
+---------------+------------+
1 row in set (0.00 sec)

mysql> show global variables like 'slow_query_log_file';
+---------------------+----------------------+
| Variable_name       | Value                |
+---------------------+----------------------+
| slow_query_log_file | /tmp/mysqld-slow.log |
+---------------------+----------------------+
1 row in set (0.00 sec)

mysql> show global variables like 'general_log_file';
+------------------+-----------------+
| Variable_name    | Value           |
+------------------+-----------------+
| general_log_file | /tmp/mysqld.log |
+------------------+-----------------+
1 row in set (0.00 sec)

mysql> select version();
+------------+
| version()  |
+------------+
| 5.1.68-log |
+------------+
1 row in set (0.00 sec)
[1 Apr 2013 18:12] Paul DuBois
Thank you for your bug report. This issue has been addressed in the documentation. The updated documentation will appear on our website shortly, and will be included in the next release of the relevant products.