[MDEV-9921] DELETE of rows in child tables are not logged in the binary log Created: 2016-04-14 Updated: 2016-04-16 Resolved: 2016-04-16 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Documentation, Replication, Storage Engine - InnoDB |
| Fix Version/s: | N/A |
| Type: | Task | Priority: | Minor |
| Reporter: | Karl E. Jørgensen | Assignee: | Ian Gilfillan |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | replication, upstream | ||
| Description |
|
When we have InnoDB tables with foreign key constraints (ON DELETE CASCADE) defined, deleting rows from the parent table will (correctly) delete rows from the child table. But the rows deleted from the child table do not appear in the binary log, and will thus not be replicated downstream. This is a problem, since downstream slaves may or may not have the same foreign keys defined. Or they may use a storage engine which does not do foreign keys (e.g. MyISAM or TokuDB...). As a result, the slave will drift out of sync with the master... For example:
The above behaves as expected on the master - the row in the book table is correctly deleted. But it does not appear in the binary log! |
| Comments |
| Comment by Karl E. Jørgensen [ 2016-04-14 ] |
|
I could reproduce the problem both on mariadb 10.0.23 and mariadb-galera 10.0.16. In both cases with binlog_format = ROW. (haven't tried binlog_format=STATEMENT yet..) |
| Comment by Elena Stepanova [ 2016-04-15 ] |
|
This is explicitly documented behavior of InnoDB in regard to replication: http://dev.mysql.com/doc/refman/5.7/en/innodb-and-mysql-replication.html
(see the full explanation and examples in the manual). The corresponding upstream bug report was https://bugs.mysql.com/bug.php?id=32506 , although it's marked as "closed", in fact it only caused the addition to the documentation mentioned above. It also says that a worklog for a feature request had been created. I cannot find the worklog, it is probably internal at Oracle, but if it ever gets implemented, the change will be considered for merging into MariaDB. Doing it on MariaDB side only might cause more harm than good when it comes to cross-version replication, see for example a somewhat similar (yet different issue) here: http://bugs.mysql.com/bug.php?id=80821. |
| Comment by Karl E. Jørgensen [ 2016-04-15 ] |
|
In that case, it may be worth documenting this in MariaDB too. Although I realise there is an enormous overlap between MySQL and MariaDB functionality (and oddities), I didn't think to search for only MySQL here... I'm sure others may be caught out too... |
| Comment by Ian Gilfillan [ 2016-04-16 ] |
|
This has now been documented at https://mariadb.com/kb/en/mariadb/replication-and-foreign-keys/ |