Bug #69191 replicate-rewrite-db configuration not shown in SHOW SLAVE STATUS output
Submitted: 10 May 2013 9:41 Modified: 8 Jul 2014 5:35
Reporter: Simon Mudd (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Replication Severity:S3 (Non-critical)
Version:5.5.23 OS:Any
Assigned to: CPU Architecture:Any

[10 May 2013 9:41] Simon Mudd
Description:
As per the synopsis the replicate-rewrite-db is not visible visible in the SHOW SLAVE STATUS output, so it's not apparent if it's configured or not. This is a setting which may not be used much but not showing the setting is even worse as once it's configured the setting is invisible.

How to repeat:
While setting up a new master which will have some of the tables of an existing replication chain, and the db that is going to be used is different I have to use the replicate-rewrite-db setting. This works great. (Thanks), but it's configuration is not visible anywhere.

root@myserver [ed]> show slave status\G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: mymaster
                  Master_User: myuser
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: binlog.001420
          Read_Master_Log_Pos: 720009576
               Relay_Log_File: relaylog.004140
                Relay_Log_Pos: 47364997
        Relay_Master_Log_File: binlog.001420
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB: 
          Replicate_Ignore_DB: 
           Replicate_Do_Table: 
       Replicate_Ignore_Table: 
      Replicate_Wild_Do_Table: mysql.%,bp.table1,bp.table2,ed.table1,ed.table2
  Replicate_Wild_Ignore_Table: 
                   Last_Errno: 0
                   Last_Error: 
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 720009576
              Relay_Log_Space: 156275388
              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: 187225014
1 row in set (0.00 sec)

root@myserver [ed]> exit
Bye
[root@myserver ~]# grep rewrite /etc/my.cnf
replicate-rewrite-db=bp->ed
[root@myserver ~]# 

I've checked a 5.6.11 slave I have and this does not appear to have the replicate-rewrite-db entry either.

Suggested fix:
1. Ensure the replicate-rewrite-db setting is visible in SHOW SLAVE STATUS output.
2. More generally make a I_S or mysql table SLAVE_STATUS which shows this same data so it is easier to query than using SHOW SLAVE STATUS.
3. Please make changing these settings dynamic. Having to stop and start the server for a simple change like this should really not be necessary. I'm currently setting up a new serve so I can do that but sometimes I want to change the configuration of live slaves and restarting mysqld is most intrusive.
[10 May 2013 10:37] Arnaud Adant
Hi Simon,

Thank you for the bug report. I verified it.

About the dynamic variables, see http://bugs.mysql.com/bug.php?id=29703
BUG 11746919 - REPLICATE-* RULES SHOULD BE DYNAMICALLY CONFIGURABLE 

Best regards,
[10 May 2013 10:41] Arnaud Adant
About the I_S tables, why not displaying the variables as part of the SHOW GLOBAL VARIABLES ? 

I suppose it is Bug #53777 	Include all options and variables in SHOW GLOBAL VARIABLES output, a duplicate of the previous bug.
[10 May 2013 11:26] Simon Mudd
My comment about using a I_S table or mysql tables was for the whole of the current SHOW SLAVE STATUS output, not for this specific option.

Why? because you can not extract the information from the SHOW SLAVE STATUS output with the same flexibility you can with a normal SELECT statement. So use SQL for what it's designed for and make the interfaces to the current "special" commands work using normal SQL syntax.

So a theoretical SELECT * FROM mysql.slave_status , or SELECT * FROM INFORMATION_SCHEMA.SLAVE_STATUS is just as easy to understand but doing something like:

INSERT INTO mydb.SLAVE_STATUS_HISTORY SELECT * FROM  mysql.slave_status can be done the new way but not directly using the current tools.
The request to make the slave configuration dynamic would lead me to want to put the table in the mysql db, as then you could do:

STOP SLAVE;
UPDATE SLAVE_STATUS SET setting = 'bp->de' WHERE NAME = 'replicate-rewrite-db';
START SLAVE;

This is easy to understand and it makes it easy to add new configuration settings.
It would almost make the change master command obsolete, or just a wrapper around the type of code above.

So first let's get the missing replication configuration entries into SHOW SLAVE STATUS output and while doing that consider the other enhancements mentioned.
[10 May 2013 11:35] Simon Mudd
Note also that the current SHOW SLAVE STATUS output shows a mix of 'configuration settings' and 'status settings', that is the configuration settings are "static", don't change over time and the "status" settings are while replication is running expected to change over time. The later information is important so unlike the SHOW GLOBAL STATUS "counters" which can be lost or reset without any issues, these values can not be lost. However from a configuration management point of view mixing them all in the same output is not identical, as storage for historical analysis or change management purposes needs to be done differently.
[8 Jul 2014 5:35] Erlend Dahl
[3 Jul 2014 23:12] Venkatesh Duggirala

Starting from 5.7.3, Replicate-Rewrite-db is part of "Show Slave status"
output.

Please refer the following link for more details:
http://dev.mysql.com/doc/refman/5.7/en/show-slave-status.html