Mysql replication with filtering is dangerous _ mysql, galera cluster and mariadb support and services

From time to time we see in customer engagements that MySQL Master/Slave replication is set-up doing schema or table level replication filtering. Data recovery cheap This can be done either on Master or on Slave. Database of state incentives for renewables and efficiency If filtering is done on the Master (by the binlog_{do|ignore}_db settings), the binary log becomes incomplete and cannot be used for a proper Point-in-Time-Recovery. Data recovery usb stick Therefore FromDual recommends AGAINST this approach.

The replication filtering rules vary depending on the binary log format ( ROW and STATEMENT) See also: How Servers Evaluate Replication Filtering Rules.

For reasons of data consistency between Master and Slave FromDual recommends to use only the binary log format ROW. Database companies This is also stated in the MySQL documentation: All changes can be replicated. Database application This is the safest form of replication. Database online Especially dangerous is binary log filtering with binary log format MIXED. Database high availability This binary log format FromDual strongly discourages users to use.

The binary log format ROW affects only DML statements ( UPDATE, INSERT, DELETE, etc.) but NOT DDL statements ( CREATE, ALTER, DROP, etc.) and NOT DCL statements ( CREATE, GRANT, REVOKE, DROP, etc.). Database utility So how are those statements replicated? They are replicated in STATEMENT binary log format even though binlog_format is set to ROW. Data recovery zagreb This has the consequences that the binary log filtering rules of STATEMENT based replication and not the ones of ROW based replication apply when running one of those DDL or DCL statements.

This can easily cause problems. Database javascript If you are lucky, they will cause the replication to break sooner or later, which you can detect and fix – but they may also cause inconsistencies between Master and Slave which may remain undetected for a long time.

We see, that the user intest was replicated and the user inmysql was not. Database administrator jobs And we have clearly an unwanted data inconsistency between Master and Slave.

we get the following error message on the Slave and are wondering, why this user or the query appears on the Slave: mysql> SHOW SLAVE STATUS\G

Last_SQL_Error: Error ‘Operation ALTER USER failed for ‘innone’@’%” on query. Data recovery for iphone Default database: ”. Data recovery victoria bc Query: ‘ALTER USER ‘innone’@’%’ IDENTIFIED WITH ‘mysql_native_password’ AS ‘*14E65567ABDB5135D0CFD9A70B3032C179A49EE7”

The Slave wants to tell us in a complicated way, that the user innone does not exist on the Slave… 10k database Scenario B: Filtering on tmp or similar schema

An other scenario we have seen recently is that the customer is filtering out tables with temporary data located in the tmp schema. Data recovery software mac Similar scenarios are cache, session or log tables. Cost of data recovery from hard drive He did it as follows on the Master: mysql> use tmp;

As he has learned in FromDual trainings he emptied the table with the TRUNCATE TABLE command instead of a DELETE FROM tmp.test command which is much less efficient than the TRUNCATE TABLE command. S cerevisiae database What he did not consider is, that the TRUNCATE TABLE command is a DDL command and not a DML command and thus the STATEMENT based replication filtering rules apply. Snl database His filtering rules on the Slave were as follows: mysql> SHOW SLAVE STATUS\G

Last_Error: Could not execute Write_rows event on table tmp.test; Duplicate entry ‘1’ for key ‘PRIMARY’, Error_code: 1062; handler error HA_ERR_FOUND_DUPP_KEY; the event’s master log laptop4_qa57master_binlog.000042, end_log_pos 1572

See also our earlier bug report of a similar topic: Option “replicate_do_db” does not cause “create table” to replicate (‘row’ log) Conclusion

Binary log filtering is extremely dangerous when you care about data consistency and thus FromDual recommends to avoid binary log filtering by all means. Database 4500 If you really have to do binary log filtering you should exactly know what you are doing, carefully test your set-up, check your application and your maintenance jobs and also review your future code changes regularly. Data recovery miami fl Otherwise you risk data inconsistencies in your MySQL Master/Slave replication.