Bug #34739 unexpected binlog file name when --log-bin is set to a directory name
Submitted: 21 Feb 2008 17:45 Modified: 12 Mar 2010 17:50
Reporter: Andrei Elkin Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Replication Severity:S2 (Serious)
Version:5.1-bk OS:Any
Assigned to: Daogang Qu
Triage: Triaged: D3 (Medium)

[21 Feb 2008 17:45] Andrei Elkin
Description:
There happened two artifacts when
--log-bin was set to a directory name.

1. if there is the trailing "/" at the end of the dir name
   the bare name of the binlog is empty so that the file ls:s like
   .000001
2. if there is no "/" symbol 
   there is  File '$dir.index' not found (Errcode: 13) error,
   where $dir is the path to the directory

What is expected an error/warning that --log-bin's path is a directory not a file name, for either case, and the name is set according to --pid-file or gethostname(), if the former is not set.
 
Get that on Linux-ubuntu 7.10 but it should not be linux-peculiar.

How to repeat:
mysqld --log-bin=/some/existing/directory/

and

mysqld --log-bin=/some/existing/directory

to get
cd /some/existing/directory/ && ls -a
.000001
.index

and

File '/some/existing/directory.index' not found (Errcode: 13) error
[22 Feb 2008 7:28] Jon Stephens
Verified results on SuSE 10.2.

I really don't think that we want to create files named '.000001' and '.index', do we?

Case 1 (trailing slash): Whether or not we issue a warning (and I'm not sure it's necessary or even appropriate to do so), we should use the pid filename.

Case 2 (no trailing slash): The portion following the final slash in the path should be treated as the base filename.
[9 Jul 2008 8:01] Geert Vanderkelen
And verified with 5.1 from bazaar tree today.

Really shouldn't make hidden files like that.
[29 Oct 2009 3:49] Daogang Qu
The following error is not exist:

2. if there is no "/" symbol 
   there is  File '$dir.index' not found (Errcode: 13) error,
   where $dir is the path to the directory

The binlog file name is extracted rightly as 'master-bin' base name,  
Please check the following test result:

daogangqu@daogangqu-desktop:/var/tmp$ ls -a
.  ..  master-bin.000003  master-bin.000007  master-bin.000011  master-bin.000012  master-bin.index
daogangqu@daogangqu-desktop:/var/tmp$

The above test result is produced by executing the following command:
./mtr rpl_view --mysqld=--log-bin=/var/tmp/master-bin --record
[29 Oct 2009 7: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/88558

3165 Dao-Gang.Qu@sun.com	2009-10-29
      Bug #34739  	unexpected binlog file name when --log-bin is set to a directory name
      
      If --log-bin is set to a directory name with the trailing "/", 
      the bare name of the binlog is empty so that the created files 
      named '.000001' and '.index'. It is not expected.
      
      To resolve the problem, the program should report an error and 
      aborte, so that the user can get a clear prompt for correcting 
      it in time.
     @ sql/mysqld.cc
        Add a check for the value of the --log-bin argument, if it's 
        a directory, reports an error and aborts.
[29 Oct 2009 7:31] Daogang Qu
The above patch is tested by the following test case:

daogangqu@daogangqu-desktop:~/mysql/bzrwork/bug34739/mysql-5.1-bugteam/mysql-test$ ./mtr rpl_view --mysqld=--log-bin=/var/tmp/ --record
Logging: ./mtr  rpl_view --mysqld=--log-bin=/var/tmp/ --record
091029 14:52:53 [Note] Plugin 'FEDERATED' is disabled.
091029 14:52:53 [Note] Plugin 'ndbcluster' is disabled.
MySQL Version 5.1.41
Checking supported features...
 - using ndbcluster when necessary, mysqld supports it
 - SSL connections supported
 - binaries are debug compiled
Collecting tests...
 - adding combinations for rpl
vardir: /home/daogangqu/mysql/bzrwork/bug34739/mysql-5.1-bugteam/mysql-test/var
Checking leftover processes...
Removing old var directory...
Creating var directory '/home/daogangqu/mysql/bzrwork/bug34739/mysql-5.1-bugteam/mysql-test/var'...
Installing system database...
Using server port 37038
worker[1] Using MTR_BUILD_THREAD 300, with reserved ports 13000..13009

==============================================================================

TEST                                      RESULT   TIME (ms)
------------------------------------------------------------

worker[1] mysql-test-run: WARNING: Process [mysqld.1 - pid: 14063, winpid: 14063, exit: 256] died
rpl.rpl_view 'row'                       [ fail ]
        Test ended at 2009-10-29 14:52:54

Server log is:
091029  9:52:54 [ERROR] File '/var/tmp/' is a directory not a file name, please specify a file name, like '/var/tmp/master-bin', for the --log-bin's path.
091029  9:52:54 [ERROR] Aborting

091029  9:52:54 [Note] Debug sync points hit:                   0
091029  9:52:54 [Note] Debug sync points executed:              0
091029  9:52:54 [Note] Debug sync points max active per thread: 0
091029  9:52:54 [Note] /home/daogangqu/mysql/bzrwork/bug34739/mysql-5.1-bugteam/sql/mysqld: Shutdown complete
[29 Oct 2009 9:12] 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/88566

3165 Dao-Gang.Qu@sun.com	2009-10-29
      Bug #34739  unexpected binlog file name when --log-bin is set to a directory name
      
      If --log-bin is set to a directory name with the trailing 'FN_LIBCHAR', 
      which will be '/' on Unix like systems, and '\\' on Windows like systems. 
      the basename of the binlog is empty so that the created files named 
      '.000001' and '.index'. It is not expected.
      
      To resolve the problem, the program should report an error and abort.
     @ sql/mysqld.cc
        Added a check for the value of the --log-bin argument, if it's 
        a directory, reports an error and aborts.
[30 Oct 2009 2:38] Daogang Qu
The above patch is tested by the following test case:

daogangqu@daogangqu-desktop:~/mysql/bzrwork/bug34739/mysql-5.1-bugteam/mysql-test$ ./mtr rpl_view --mysqld=--log-bin=/var/tmp/ --record
Logging: ./mtr  rpl_view --mysqld=--log-bin=/var/tmp/ --record
091029 16:49:07 [Note] Plugin 'FEDERATED' is disabled.
091029 16:49:07 [Note] Plugin 'ndbcluster' is disabled.
MySQL Version 5.1.41
Checking supported features...
 - using ndbcluster when necessary, mysqld supports it
 - SSL connections supported
 - binaries are debug compiled
Collecting tests...
 - adding combinations for rpl
vardir: /home/daogangqu/mysql/bzrwork/bug34739/mysql-5.1-bugteam/mysql-test/var
Checking leftover processes...
Removing old var directory...
Creating var directory '/home/daogangqu/mysql/bzrwork/bug34739/mysql-5.1-bugteam/mysql-test/var'...
Installing system database...
Using server port 60298
worker[1]  - 'localhost:13000' was not free
worker[1] Using MTR_BUILD_THREAD 301, with reserved ports 13010..13019

==============================================================================

TEST                                      RESULT   TIME (ms)
------------------------------------------------------------

worker[1] mysql-test-run: WARNING: Process [mysqld.1 - pid: 18822, winpid: 18822, exit: 256] died
rpl.rpl_view 'row'                       [ fail ]
        Test ended at 2009-10-29 16:49:08

Server log is:
091029 11:49:08 [ERROR] Path '/var/tmp/' is a directory name, please specify a file name for --log-bin option
091029 11:49:08 [ERROR] Aborting

091029 11:49:08 [Note] Debug sync points hit:                   0
091029 11:49:08 [Note] Debug sync points executed:              0
091029 11:49:08 [Note] Debug sync points max active per thread: 0
091029 11:49:08 [Note] /home/daogangqu/mysql/bzrwork/bug34739/mysql-5.1-bugteam/sql/mysqld: Shutdown complete
[3 Nov 2009 5:39] 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/89024

3165 Dao-Gang.Qu@sun.com	2009-11-03
      Bug #34739  unexpected binlog file name when --log-bin is set to a directory name
      
      If --log-bin is set to a directory name with the trailing 'FN_LIBCHAR', 
      which will be '/' on Unix like systems, and '\\' on Windows like systems. 
      the basename of the binlog is empty so that the created files named 
      '.000001' and '.index'. It is not expected. 
      The same thing happened to --log-bin-index, --relay-log and 
      --relay-log-index options.
      
      To resolve the problem, in these cases the program should report an error 
      and abort.
     @ sql/mysqld.cc
        Added a check for the value of the --log-bin and --log-bin-index arguments, 
        if it's a directory, reports an error and aborts.
     @ sql/rpl_rli.cc
        Added a check for the value of the --relay-log and --relay-log-index arguments, 
        if it's a directory, reports an error and aborts.
[3 Nov 2009 7:25] Daogang Qu
The above patch is tested by the following test cases:

Testing --relay-log option as the following test1:
daogangqu@daogangqu-desktop:~/mysql/bzrwork/bug34739/mysql-5.1-bugteam/mysql-test$ ./mtr rpl_trigger --mysqld=--relay-log=/var/tmp/ --record

......
==============================================================================

TEST                                      RESULT   TIME (ms)
------------------------------------------------------------

rpl.rpl_trigger 'row'                    [ skipped ]  Doesn't support --binlog-format='row'
rpl.rpl_trigger 'row+innodb_plugin'      [ skipped ]  Doesn't support --binlog-format='row'
rpl.rpl_trigger 'stmt'                   [ fail ]
        Test ended at 2009-11-03 10:53:50

CURRENT_TEST: rpl.rpl_trigger
mysqltest: In included file "./include/master-slave-reset.inc": At line 35: query 'start slave' failed: 1201: Could not initialize master info structure; more error messages can be found in the MySQL error log

daogangqu@daogangqu-desktop:~/mysql/bzrwork/bug34739/mysql-5.1-bugteam/mysql-test$ cat var/log/mysqld.2.err

......
091103  5:53:49 [ERROR] Path '/var/tmp/' is a directory name, please specify a file name for --relay-log option
091103  5:53:49 [ERROR] Failed to initialize the master info structure
091103  5:53:49 [Note] Event Scheduler: Loaded 0 events
091103  5:53:49 [Note] /home/daogangqu/mysql/bzrwork/bug34739/mysql-5.1-bugteam/sql/mysqld: ready for connections.
Version: '5.1.41-debug-log'  socket: '/home/daogangqu/mysql/bzrwork/bug34739/mysql-5.1-bugteam/mysql-test/var/tmp/mysqld.2.sock'  port: 13041  Source distribution
091103  5:53:50 [ERROR] Path '/var/tmp/' is a directory name, please specify a file name for --relay-log option

Testing --relay-log-index option as the following test2:

daogangqu@daogangqu-desktop:~/mysql/bzrwork/bug34739/mysql-5.1-bugteam/mysql-test$ ./mtr rpl_trigger --mysqld=--relay-log-index=/var/tmp/ --record

......
==============================================================================

TEST                                      RESULT   TIME (ms)
------------------------------------------------------------

rpl.rpl_trigger 'row'                    [ skipped ]  Doesn't support --binlog-format='row'
rpl.rpl_trigger 'row+innodb_plugin'      [ skipped ]  Doesn't support --binlog-format='row'
rpl.rpl_trigger 'stmt'                   [ fail ]
        Test ended at 2009-11-03 11:00:19

CURRENT_TEST: rpl.rpl_trigger
mysqltest: In included file "./include/master-slave-reset.inc": At line 35: query 'start slave' failed: 1201: Could not initialize master info structure; more error messages can be found in the MySQL error log

daogangqu@daogangqu-desktop:~/mysql/bzrwork/bug34739/mysql-5.1-bugteam/mysql-test$ cat var/log/mysqld.2.err

......
091103  6:00:19  InnoDB: Started; log sequence number 0 0
091103  6:00:19 [ERROR] Path '/var/tmp/' is a directory name, please specify a file name for --relay-log-index option
091103  6:00:19 [ERROR] Failed to initialize the master info structure
091103  6:00:19 [Note] Event Scheduler: Loaded 0 events
091103  6:00:19 [Note] /home/daogangqu/mysql/bzrwork/bug34739/mysql-5.1-bugteam/sql/mysqld: ready for connections.
Version: '5.1.41-debug-log'  socket: '/home/daogangqu/mysql/bzrwork/bug34739/mysql-5.1-bugteam/mysql-test/var/tmp/mysqld.2.sock'  port: 13041  Source distribution
091103  6:00:19 [ERROR] Path '/var/tmp/' is a directory name, please specify a file name for --relay-log-index option

Testing --log-bin-index option as the following test3:

daogangqu@daogangqu-desktop:~/mysql/bzrwork/bug34739/mysql-5.1-bugteam/mysql-test$ ./mtr rpl_view --mysqld=--log-bin-index=/var/tmp/ --record

......
==============================================================================

TEST                                      RESULT   TIME (ms)
------------------------------------------------------------

rpl.rpl_view 'stmt'                      [ skipped ]  Doesn't support --binlog-format='statement'
rpl.rpl_view 'mix'                       [ skipped ]  Doesn't support --binlog-format='mixed'
worker[1] mysql-test-run: WARNING: Process [mysqld.1 - pid: 4135, winpid: 4135, exit: 256] died
rpl.rpl_view 'row'                       [ fail ]
        Test ended at 2009-11-03 11:17:47

Server log is:
091103  6:17:47 [ERROR] Path '/var/tmp/' is a directory name, please specify a file name for --log-bin-index option
091103  6:17:47 [ERROR] Aborting

091103  6:17:47 [Note] Debug sync points hit:                   0
091103  6:17:47 [Note] Debug sync points executed:              0
091103  6:17:47 [Note] Debug sync points max active per thread: 0
091103  6:17:47 [Note] /home/daogangqu/mysql/bzrwork/bug34739/mysql-5.1-bugteam/sql/mysqld: Shutdown complete

Testing --log-bin option as the following test4:

daogangqu@daogangqu-desktop:~/mysql/bzrwork/bug34739/mysql-5.1-bugteam/mysql-test$ ./mtr rpl_view --mysqld=--log-bin=/var/tmp/ --record

......
==============================================================================

TEST                                      RESULT   TIME (ms)
------------------------------------------------------------

rpl.rpl_view 'stmt'                      [ skipped ]  Doesn't support --binlog-format='statement'
rpl.rpl_view 'mix'                       [ skipped ]  Doesn't support --binlog-format='mixed'
worker[1] mysql-test-run: WARNING: Process [mysqld.1 - pid: 4156, winpid: 4156, exit: 256] died
rpl.rpl_view 'row'                       [ fail ]
        Test ended at 2009-11-03 11:18:43

Server log is:
091103  6:18:43 [ERROR] Path '/var/tmp/' is a directory name, please specify a file name for --log-bin option
091103  6:18:43 [ERROR] Aborting

091103  6:18:43 [Note] Debug sync points hit:                   0
091103  6:18:43 [Note] Debug sync points executed:              0
091103  6:18:43 [Note] Debug sync points max active per thread: 0
091103  6:18:43 [Note] /home/daogangqu/mysql/bzrwork/bug34739/mysql-5.1-bugteam/sql/mysqld: Shutdown complete
[4 Nov 2009 8:27] Daogang Qu
2. if there is no "/" symbol 
   there is  File '$dir.index' not found (Errcode: 13) error,
   where $dir is the path to the directory

The above 'Errcode: 13' error is caused by permission denied. 

Actually, the case works fine if the directory is writable.
Please check the following test result:
(The binlog file name is extracted rightly even if 
the '/var/tmp/master-bin' path is a directory.)
daogangqu@daogangqu-desktop:/var/tmp$ ls
master-bin         master-bin.000003  master-bin.000011  master-bin.index
master-bin.000002  master-bin.000007  master-bin.000012
daogangqu@daogangqu-desktop:/var/tmp$

The above test result is produced by executing the following command:
./mtr rpl_view --mysqld=--log-bin=/var/tmp/master-bin --record
[5 Nov 2009 6:10] 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/89406

3195 Dao-Gang.Qu@sun.com	2009-11-05
      Bug #34739  unexpected binlog file name when --log-bin is set to a directory name
      
      If --log-bin is set to a directory name with the trailing 'FN_LIBCHAR', 
      which will be '/' on Unix like systems, and '\\' on Windows like systems. 
      the basename of the binlog is empty so that the created files named 
      '.000001' and '.index'. It is not expected. 
      The same thing happened to --log-bin-index, --relay-log and 
      --relay-log-index options.
      
      To resolve the problem, in these cases the program should report an error 
      and abort.
     @ sql/mysqld.cc
        Added a check for the value of the --log-bin and --log-bin-index arguments, 
        if it's a directory, reports an error and aborts.
     @ sql/rpl_rli.cc
        Added a check for the value of the --relay-log and --relay-log-index arguments, 
        if it's a directory, reports an error and aborts.
[5 Nov 2009 6:37] 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/89409

3666 Dao-Gang.Qu@sun.com	2009-11-05 [merge]
      Bug #34739  unexpected binlog file name when --log-bin is set to a directory name
      
      If --log-bin is set to a directory name with the trailing 'FN_LIBCHAR', 
      which will be '/' on Unix like systems, and '\\' on Windows like systems. 
      the basename of the binlog is empty so that the created files named 
      '.000001' and '.index'. It is not expected. 
      The same thing happened to --log-bin-index, --relay-log and 
      --relay-log-index options.
      
      To resolve the problem, in these cases the program should report an error 
      and abort.
     @ sql/mysqld.cc
        Added a check for the value of the --log-bin and --log-bin-index arguments, 
        if it's a directory, reports an error and aborts.
     @ sql/rpl_rli.cc
        Added a check for the value of the --relay-log and --relay-log-index arguments, 
        if it's a directory, reports an error and aborts.
[5 Nov 2009 6:50] Daogang Qu
The patch has been pushed to mysql-5.1-bugteam and mysql-pe.
[2 Dec 2009 8:06] Bugs System
Pushed into 5.1.42 (revid:joro@sun.com-20091202080033-mndu4sxwx19lz2zs) (version source revid:kristofer.pettersson@sun.com-20091109223504-xvwgsdqiyuve6frt) (merge vers: 5.1.41) (pib:13)
[4 Dec 2009 1:51] Paul Dubois
Note in 5.1.42 changelog.

If the --log-bin server option was set to a directory name with a
trailing component separator character, the basename of the binary
log files was empty so that the created files were named .000001 and
.index. The same thing occurred with the --log-bin-index,
--relay-log, and --relay-log-index options. Now the server reports
and error and exits. 

Setting report to NDI pending push to 5.6.x+.
[16 Dec 2009 8:40] Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20091216083311-xorsasf5kopjxshf) (version source revid:alik@sun.com-20091214191830-wznm8245ku8xo702) (merge vers: 6.0.14-alpha) (pib:14)
[16 Dec 2009 8:47] Bugs System
Pushed into 5.5.0-beta (revid:alik@sun.com-20091216082430-s0gtzibcgkv4pqul) (version source revid:alexey.kopytov@sun.com-20091124081906-6pqi7e7sajimog71) (merge vers: 5.5.0-beta) (pib:14)
[16 Dec 2009 8:54] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20091216083231-rp8ecpnvkkbhtb27) (version source revid:alik@sun.com-20091212203859-fx4rx5uab47wwuzd) (merge vers: 5.6.0-beta) (pib:14)
[16 Dec 2009 15:40] Paul Dubois
Noted in 5.5.1, 6.0.14 changelogs.
[12 Mar 2010 14:15] Bugs System
Pushed into 5.1.44-ndb-7.0.14 (revid:jonas@mysql.com-20100312135944-t0z8s1da2orvl66x) (version source revid:jonas@mysql.com-20100312115609-woou0te4a6s4ae9y) (merge vers: 5.1.44-ndb-7.0.14) (pib:16)
[12 Mar 2010 14:31] Bugs System
Pushed into 5.1.44-ndb-6.2.19 (revid:jonas@mysql.com-20100312134846-tuqhd9w3tv4xgl3d) (version source revid:jonas@mysql.com-20100312060623-mx6407w2vx76h3by) (merge vers: 5.1.44-ndb-6.2.19) (pib:16)
[12 Mar 2010 14:47] Bugs System
Pushed into 5.1.44-ndb-6.3.33 (revid:jonas@mysql.com-20100312135724-xcw8vw2lu3mijrhn) (version source revid:jonas@mysql.com-20100312103652-snkltsd197l7q2yg) (merge vers: 5.1.44-ndb-6.3.33) (pib:16)