Bug #72660 relay-log and log-bin settings permitted to use the same namespace
Submitted: 15 May 2014 16:19 Modified: 19 May 2014 6:53
Reporter: Morgan Tocker Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Replication Severity:S3 (Non-critical)
Version:5.6.17 OS:Any
Assigned to: CPU Architecture:Any

[15 May 2014 16:19] Morgan Tocker
Description:
Reported via twitter:
https://twitter.com/mahhyzero/status/466688810110427136

The settings relay-log and log-bin can accidentally be set to the same values, and consume the same namespace, leading to possible data corruption.

How to repeat:
I was not able to reproduce data corruption (due to relay-log and log-bin being at different filenames), but I can see it happening.  This is a 5.6.17 SHOW SLAVE STATUS demonstrating that they are the same namespace:

slave1 [localhost] {msandbox} ((none)) > show slave status\G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 127.0.0.1
                  Master_User: rsandbox
                  Master_Port: 20082
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000011 <--- same
          Read_Master_Log_Pos: 120
               Relay_Log_File: mysql-bin.000025 <--- same
                Relay_Log_Pos: 283
        Relay_Master_Log_File: mysql-bin.000011
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB:
          Replicate_Ignore_DB:
           Replicate_Do_Table:
       Replicate_Ignore_Table:
      Replicate_Wild_Do_Table:
  Replicate_Wild_Ignore_Table:
                   Last_Errno: 0
                   Last_Error:
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 120
              Relay_Log_Space: 497
              Until_Condition: None
               Until_Log_File:
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_SSL_CA_File:
           Master_SSL_CA_Path:
              Master_SSL_Cert:
            Master_SSL_Cipher:
               Master_SSL_Key:
        Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error:
               Last_SQL_Errno: 0
               Last_SQL_Error:
  Replicate_Ignore_Server_Ids:
             Master_Server_Id: 1
                  Master_UUID: e9d84e80-dc48-11e3-9f4c-7744edd874ba
             Master_Info_File: /Users/morgo/sandboxes/rsandbox_5_6_17/node1/data/master.info
                    SQL_Delay: 0

Suggested fix:
It makes sense to do a startup check to see relay-log and log-bin are different.  Neither are dynamic variables.
[15 May 2014 19:39] Rob Rankin
Settings in use that caused the issue:

relay-log = "D:/mysql_logs/server01"
log_bin = "D:/mysql_logs/server01.log"
log-slave-updates
[15 May 2014 19:40] Rob Rankin
Log update/ordering times and sizes

Attachment: Screen Shot 2014-05-14 at 8.59.19 PM.png (image/png, text), 31.13 KiB.

[15 May 2014 19:42] Rob Rankin
Master version:  5.5.33-log
Slave version: 5.5.20-log
[19 May 2014 6:53] MySQL Verification Team
Hello Morgan,

Thank you for the bug report.
Verified as described.

Thanks,
Umesh
[19 May 2014 7:00] MySQL Verification Team
// Master/Slave with 5.6.17
// Setup slave with binary log enabled and log-bin and relay-log sharing common name

mysql> \! more slave.cnf|grep "log-bin =\|relay-log ="
log-bin = master-bin
relay-log = master-bin

mysql> show slave status\G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: XXX.X.X.X
                  Master_User: repl
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: master-bin.000003
          Read_Master_Log_Pos: 813
               Relay_Log_File: master-bin.000005
                Relay_Log_Pos: 284
        Relay_Master_Log_File: master-bin.000003
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes

mysql> \! more /tmp/slave/master-bin.index /tmp/slave/slave-relay-bin.index
::::::::::::::
/tmp/slave/master-bin.index
::::::::::::::
./master-bin.000001
./master-bin.000002
./master-bin.000003
::::::::::::::
/tmp/slave/slave-relay-bin.index
::::::::::::::
./master-bin.000004
./master-bin.000005