MySQL 5.7 – Do Log_Slave_Updates Fail Replication in Linux?

innodbmy.cnfMySQLmysql-5.7replication

I have a Master Master replication setup in RHEL for 2 Nodes.One server is acting as Master as well as slave for another Server ( which is also Master and Slave )
Let us say A server and B server

I have enabled log_slave_updates on B server so that all the statements receiving from master ( Server A) should get logged to binary logs of server B .

I was expecting Replication , will get fail because :

         1. Created a Table on Server A.
         2. It get replicated to Server B.

Now Binary log from Slave B will go to Server A and this should break the replication saying "table already exist". but it didn't

What is the logic here ?

Edit Part :

  1. Server id on both servers are different

Best Answer

ASPECT #1

Please make sure ServerA and ServerB have log_slave_updates enabled.

ASPECT #2

This setup will not break replication because every time a transaction is logged in the binary logs, the server_id of the transaction is written as well.

Let's say server_id=10 for ServerA and server_id=20 for ServerB

So, when you run this on ServerA

INSERT INTO mytable (col) VALUES (1);

The transaction will include server_id 10. When ServerB looks into its relay logs and sees server_id 10, it will compare that with its own server_id (20). Since there is no match, it is OK to execute.

ServerB records that transaction in its binary logs. ServerA will pick that transaction up from its relay logs. When ServerA looks into its relay logs and sees server_id 10, it will compare that with its own server_id (10). Since there is a match, it refuses to execute.

I discussed this before in my past answers