Triggers from Innodb to MyISAM Table will not correctly apply on slave nodes
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
MySQL patches by Codership |
New
|
Undecided
|
Unassigned |
Bug Description
Here's a test case on a two node cluster: PXC 5.5.29, wsrep_provider_
create database if not exists bugs;
use bugs;
drop table if exists parent;
drop table if exists child_innodb;
drop table if exists child_myisam;
CREATE TABLE parent (id INT PRIMARY KEY, data VARCHAR(100) ) ENGINE=Innodb;
CREATE TABLE child_innodb (id INT PRIMARY KEY, data VARCHAR(100) ) ENGINE=Innodb;
CREATE TABLE child_myisam (id INT PRIMARY KEY, data VARCHAR(100) ) ENGINE=MyISAM;
# Innodb trigger
DROP TRIGGER IF EXISTS `bugs`.
DELIMITER &&
CREATE TRIGGER `bugs`.
BEGIN INSERT INTO child_innodb (id, data) VALUES (NEW.id, NEW.data); END&&
DELIMITER ;
insert into parent (id, data) VALUES( 1, 'child_innodb trigger');
# MyISAM trigger
DROP TRIGGER IF EXISTS `bugs`.
DELIMITER &&
CREATE TRIGGER `bugs`.
BEGIN INSERT INTO child_myisam (id, data) VALUES (NEW.id, NEW.data); END&&
DELIMITER ;
insert into parent (id, data) VALUES( 2, 'child_myisam trigger');
# Trigger on both (RBR)
DROP TRIGGER IF EXISTS `bugs`.
DELIMITER &&
CREATE TRIGGER `bugs`.
BEGIN
INSERT INTO child_myisam (id, data) VALUES (NEW.id, NEW.data);
INSERT INTO child_innodb (id, data) VALUES (NEW.id, NEW.data);
END&&
DELIMITER ;
insert into parent (id, data) VALUES( 3, 'trigger into both tables');
# Same, but with SBR
set binlog_
insert into parent (id, data) VALUES( 4, 'both tables -- SBR');
# on the master node
node1 mysql> select * from parent;
+----+-
| id | data |
+----+-
| 1 | child_innodb trigger |
| 2 | child_myisam trigger |
| 3 | trigger into both tables |
| 4 | both tables -- SBR |
+----+-
4 rows in set (0.00 sec)
node1 mysql> select * from child_myisam;
+----+-
| id | data |
+----+-
| 2 | child_myisam trigger |
| 3 | trigger into both tables |
| 4 | both tables -- SBR |
+----+-
3 rows in set (0.00 sec)
node1 mysql> select * from child_innodb;
+----+-
| id | data |
+----+-
| 1 | child_innodb trigger |
| 3 | trigger into both tables |
| 4 | both tables -- SBR |
+----+-
3 rows in set (0.00 sec)
# On other node in the cluster:
node3 mysql> select * from parent;
+----+-
| id | data |
+----+-
| 1 | child_innodb trigger |
| 2 | child_myisam trigger |
| 3 | trigger into both tables |
| 4 | both tables -- SBR |
+----+-
4 rows in set (0.00 sec)
node3 mysql> select * from child_myisam;
+----+-
| id | data |
+----+-
| 4 | both tables -- SBR |
+----+-
1 row in set (0.00 sec)
node3 mysql> select * from child_innodb;
+----+-
| id | data |
+----+-
| 1 | child_innodb trigger |
| 3 | trigger into both tables |
| 4 | both tables -- SBR |
+----+-
3 rows in set (0.00 sec)
So, the bug is that Innodb tables with triggers will not replicate DML into non-Innodb tables (i.e., TOI tables), unless I switch the entire transaction STATEMENT replication (which isn't safe for Innodb)
binary log on each node (with log-bin and log-slave-updates running) for test #2 captured with 'mysqlbinlog -vvv'.
On the master node:
/*!40019 SET @@session. max_insert_ delayed_ threads= 0*/; _TYPE=@ @COMPLETION_ TYPE,COMPLETION _TYPE=0* /; AAGsAAAABAAQANS 41LjI5LWxvZwAAA AAAAAAAAAAAAAAA AAAAAAAAAAAAAAA A AAAAAAAAAEzgNAA gAEgAEBAQEEgAAV AAEGggAAAAICAgC AA== 1360088041/ *!*/; pseudo_ thread_ id=9/*! */; foreign_ key_checks= 1, @@session. sql_auto_ is_null= 0, @@session. unique_ checks= 1, @@session. autocommit= 1/*!*/; sql_mode= 0/*!*/; auto_increment_ increment= 2, @@session. auto_increment_ offset= 2/*!*/; character_ set_client= 33,@@session. collation_ connection= 33,@@session. collation_ server= 8/*!*/; lc_time_ names=0/ *!*/; collation_ database= DEFAULT/ *!*/; `child_ myisam` mapped to number 42
/*!50003 SET @OLD_COMPLETION
DELIMITER /*!*/;
# at 4
#130205 13:13:52 server id 1 end_log_pos 107 Start: binlog v 4, server v 5.5.29-log created 130205 13:13:52
# Warning: this binlog is either in use or was not closed properly.
BINLOG '
4EsRUQ8BAAAAZwA
AAAAAAAAAAAAAAA
'/*!*/;
# at 107
#130205 13:14:01 server id 1 end_log_pos 180 Query thread_id=9 exec_time=0 error_code=0
SET TIMESTAMP=
SET @@session.
SET @@session.
SET @@session.
SET @@session.
/*!\C utf8 *//*!*/;
SET @@session.
SET @@session.
SET @@session.
BEGIN
/*!*/;
# at 180
# at 234
#130205 13:14:01 server id 1 end_log_pos 234 Table_map: `bugs`.
#130205 13:14:01 server id 1 end_log_pos 289 Write_rows: table id 42 flags: STMT_END_F
BINLOG ' AAOoAAAAAACoAAA AAAAEABGJ1Z3MAD GNoaWxkX215aXNh bQACAw8CZAAC AACEBAAAAACoAAA AAAAEAAv/ 8AgAAABRjaGlsZF 9teWlzYW0gdHJpZ 2dlcg== 1360088041/ *!*/; 1360088041/ *!*/;
6UsRURMBAAAANgA
6UsRURcBAAAANwA
'/*!*/;
### INSERT INTO bugs.child_myisam
### SET
### @1=2 /* INT meta=0 nullable=0 is_null=0 */
### @2='child_myisam trigger' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
# at 289
#130205 13:14:01 server id 1 end_log_pos 363 Query thread_id=9 exec_time=0 error_code=0
SET TIMESTAMP=
COMMIT
/*!*/;
# at 363
#130205 13:14:01 server id 1 end_log_pos 436 Query thread_id=9 exec_time=0 error_code=0
SET TIMESTAMP=
BEGIN
/*!*/;
# at 436
# at 484
#130205 13:14:01 server id 1 end_log_pos 484 Table_map: `bugs`.`parent` mapped to number 41
#130205 13:14:01 server id 1 end_log_pos 539 Write_rows: table id 41 flags: STMT_END_F
BINLOG ' AAOQBAAAAACkAAA AAAAEABGJ1Z3MAB nBhcmVudAACAw8C ZAAC AABsCAAAAACkAAA AAAAEAAv/ 8AgAAABRjaGlsZF 9teWlzYW0gdHJpZ 2dlcg== TYPE=@OLD_ COMPLETION_ TYPE*/;
6UsRURMBAAAAMAA
6UsRURcBAAAANwA
'/*!*/;
### INSERT INTO bugs.parent
### SET
### @1=2 /* INT meta=0 nullable=0 is_null=0 */
### @2='child_myisam trigger' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
# at 539
#130205 13:14:01 server id 1 end_log_pos 566 Xid = 455045
COMMIT/*!*/;
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_
On the slave node:
/*!40019 SET @@session. max_insert_ delayed_ threads= 0*/; _TYPE=@ @COMPLETION_ TYPE,COMPLETION _TYPE=0* /; AA...
/*!50003 SET @OLD_COMPLETION
DELIMITER /*!*/;
# at 4
#130205 13:13:52 server id 1 end_log_pos 107 Start: binlog v 4, server v 5.5.29-log created 130205 13:13:52
# Warning: this binlog is either in use or was not closed properly.
BINLOG '
4EsRUQ8BAAAAZwA