Bug #28603 Invalid log-bin default location
Submitted: 22 May 2007 20:32 Modified: 19 Feb 2008 13:59
Reporter: BJ Dierkes Email Updates:
Status: Closed Impact on me:
Category:MySQL Server: Replication Severity:S2 (Serious)
Version:5.0.41 OS:Linux (Redhat Enterprise Linux ES 4 - i386)
Assigned to: Andrei Elkin CPU Architecture:Any
Tags: bfsm_2007_10_18
Triage: D3 (Medium)

[22 May 2007 20:32] BJ Dierkes
Operating System: Red Hat Enterprise Linux ES release 4 (Nahant Update 5)
Arch: i386

The default location for 'log-bin' does not appear to be correct as of version 5.0.41.  Referencing the MySQL documentation:


"When started with the --log-bin[=base_name]  option, mysqld writes a log file containing all SQL commands that update data. If no base_name value is given, the default name is the name of the host machine followed by -bin. If the basename is given, but not as an absolute pathname, the server writes the file in the data directory. It is recommended that you specify a basename; see Section B.1.8.1, “Open Issues in MySQL”, for the reason."

This would imply that if 'log-bin' is implicitly set in my.cnf (just setting 'log-bin' without '=base_name'), that the binary log will be output to '/var/lib/mysql/<hostname>.XXXXXX'.  However, as of 5.0.41 the log is output to '/var/run/mysqld/mysql-bin.XXXXXX'.  If *explicitly* set, the log outputs to '/var/lib/mysql/<base_name>.XXXXXX' as expected.

Please note that I did read 'http://dev.mysql.com/doc/refman/5.0/en/open-bugs.html' and did not find anything that sounds relative.

In summary, if log-bin is not explicitly configured for a specific log 'base_name', the default 'datadir' is *not* used and the binary log is created in '/var/run/mysqld'.  The following show both configurations:

With log-bin explicitly configured:

[rpm-dev@rhel-i386-es-4_test ~]$ date
Tue May 22 15:19:46 CDT 2007

[rpm-dev@rhel-i386-es-4_test ~]$ cat /etc/my.cnf | grep log-bin

| File            | Position | Binlog_Do_DB | Binlog_Ignore_DB |
| myserver.000001 |       98 |              |                  | 
1 row in set (0.00 sec)

[rpm-dev@rhel-i386-es-4_test ~]$ ls -lah /var/lib/mysql/myserver.000001 
-rw-rw----  1 mysql mysql 98 May 22 15:19 /var/lib/mysql/myserver.000001

With log-bin implicitly set:

[rpm-dev@rhel-i386-es-4_test ~]$ date
Tue May 22 15:09:41 CDT 2007

[rpm-dev@rhel-i386-es-4_test ~]$ cat /etc/my.cnf | grep log-bin

| File              | Position | Binlog_Do_DB | Binlog_Ignore_DB |
| mysqld-bin.000003 |       98 |              |                  | 
1 row in set (0.00 sec)

[rpm-dev@rhel-i386-es-4_test ~]$ ls -lah /var/run/mysqld/mysqld-bin.000003 
-rw-rw----  1 mysql mysql 98 May 22 15:10 /var/run/mysqld/mysqld-bin.000003

The severity is marked as Serious as this issue breaks replication when upgrading to MySQL 5.0.41 (if log-bin is not explicitly set with a base_name).

How to repeat:
Set 'log-bin' in /etc/my.cnf without '=base_name'.  Restart MySQL and verify binary log location.  In this case, the log is output to '/var/run/mysql' and not '/var/lib/mysql'.

Suggested fix:
If no base_name is supplied, the logfile should be created as '<hostname>-bin.XXXXXX' in the datadir (/var/lib/mysql).
[2 Jul 2007 16:53] BJ Dierkes
Sorry.. perhaps the original Synopsis having 'Bogus' in there caused this one to be over looked...  

Any input on this issue?
[7 Jul 2007 0:28] Sveta Smirnova
Thank you for the report.

Verified as described.

How to repeat see bug #28850
[29 Oct 2007 8:57] Sergei Golubchik
Two issues:
1. log name default to mysql-bin instead of hostname.
   it's documentation problem
2. default location. fixed by a patch for BUG#28597
[18 Feb 2008 20:08] Andrei Elkin
The bug was fixed by BUG#28597 patch.
The latter also preserved a way how binlog file name was constructed (after fixes
for bug#20166).
"Fixed with preserving`pidfile_name' (intr.by bug@20166) but stripping
  off its directory part."
Therefore there are no more issues, incl documentation, wrt this bug.
Documentation team, please confirm and close.
[19 Feb 2008 13:59] Jon Stephens
Discussed bug and fix with Andrei; noted in the changelog entry for Bug #28597 that the fix for that bug also fixes this one. 

Added note to -The Binary Log- section in the 5.0/5.1/6.0 Manual advising of the server versions affected by these 2 bugs.

Closed bug report.