Bug #79664 Binary log replaced instead of incremented
Submitted: 16 Dec 2015 10:36 Modified: 16 Dec 2015 11:01
Reporter: Cédric Bruderer Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Replication Severity:S3 (Non-critical)
Version:5.7.10 OS:Any
Assigned to: CPU Architecture:Any

[16 Dec 2015 10:36] Cédric Bruderer
Description:
I changed the 'log_bin' in my.cnf and restarted the server. I expected the binlog to be increment (.000001, .000002, ...). What happened was, that the binary log got replaced.

It happened when 'log_bin' was set to 'master_mysql-5.7.10_binlog'.

Within the MySQL CLI I saw several binlogs ...
+------------------+-----------+
| Log_name         | File_size |
+------------------+-----------+
| master_mysql-5.7 |       154 |
| master_mysql-5.7 |       154 |
| master_mysql-5.7 |       154 |
| master_mysql-5.7 |       154 |
| master_mysql-5.7 |       154 |
| master_mysql-5.7 |       154 |
| master_mysql-5.7 |       154 |
| master_mysql-5.7 |       154 |
+------------------+-----------+
8 rows in set (0.01 sec)

... but on the file system was only one.
-rw-r----- 1 mysql mysql       201 Dec 14 21:11 master_mysql-5.7
-rw-r----- 1 mysql mysql       152 Dec 14 21:11 master_mysql-5.index

And when I checked the index file, it looked like this:
./master_mysql-5.7
./master_mysql-5.7
./master_mysql-5.7
./master_mysql-5.7
./master_mysql-5.7
./master_mysql-5.7
./master_mysql-5.7
./master_mysql-5.7

It did not happen when 'log_bin' was set to 'hermes_test201512_binlog'. With the setting like this, it worked as expected.
-rw-r----- 1 mysql mysql       460 Dec 14 20:43 hermes_test201512_binlog.000001
-rw-r----- 1 mysql mysql       177 Dec 14 20:43 hermes_test201512_binlog.000002
-rw-r----- 1 mysql mysql       216 Dec 14 20:48 hermes_test201512_binlog.000003
-rw-r----- 1 mysql mysql       216 Dec 14 20:48 hermes_test201512_binlog.000004
-rw-r----- 1 mysql mysql       216 Dec 14 21:11 hermes_test201512_binlog.000005
-rw-r----- 1 mysql mysql       177 Dec 14 21:11 hermes_test201512_binlog.000006
-rw-r----- 1 mysql mysql       204 Dec 14 21:11 hermes_test201512_binlog.index

How to repeat:
Set the following line in 'my.cnf':

log_bin = master_mysql-5.7.10_binlog

Start the server and do some log rotates with 'FLUSH LOGS'.

Now do a 'SHOW BINARY LOGS'. They all have the same name.

Do a 'ls -al' in the directory of the binlogs. There is only one binlog and the index file.

Suggested fix:
1) Allow dots ( . ) in the name of binary logs.
2) Strictly refuse dots in the name of binary logs.
[16 Dec 2015 11:01] Umesh Shastry
Hello Cédric Bruderer,

Thank you for the report.

Thanks,
Umesh
[16 Dec 2015 11:03] Umesh Shastry
// Start mysqld with --log_bin=master_mysql-5.7.10_binlog --server_id=1

mysql> show binary logs;
+------------------+-----------+
| Log_name         | File_size |
+------------------+-----------+
| master_mysql-5.7 |       154 |
+------------------+-----------+
1 row in set (0.00 sec)

mysql> flush logs;
Query OK, 0 rows affected (0.00 sec)

mysql> flush logs;
Query OK, 0 rows affected (0.00 sec)

mysql> show binary logs;
+------------------+-----------+
| Log_name         | File_size |
+------------------+-----------+
| master_mysql-5.7 |       154 |
| master_mysql-5.7 |       154 |
| master_mysql-5.7 |       154 |
+------------------+-----------+
3 rows in set (0.00 sec)

mysql> \! cat ./79656/master_mysql-5.index
./master_mysql-5.7
./master_mysql-5.7
./master_mysql-5.7