Bug #44752 binary log corruption with RBR and trigger
Submitted: 8 May 2009 14:46 Modified: 12 May 2009 7:10
Reporter: Matthew Lord Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Row Based Replication ( RBR ) Severity:S1 (Critical)
Version:5.1.34 OS:Any
Assigned to: Assigned Account CPU Architecture:Any
Tags: binary log, corruption, RBR, row based replication

[8 May 2009 14:46] Matthew Lord
Description:
The combination of RBR, an INSERT and an AFTER INSERT TRIGGER causes binary
log corruption.

How to repeat:
start mysqld with binlog-format=ROW 

mysql test
mysql> source test-20090507110352.sql;
mysql> flush logs;
mysql> source insert.sql;
mysql> show master status;

You can now see the corruption when using mysqlbinlog with the new
binary log.

Suggested fix:
n/a
[12 May 2009 7:10] Mats Kindahl
Duplicate of BUG#42749

Watch:
$ mysqlbinlog master-bin.000002
...
# at 106
...
# at 174
ERROR: Error in Log_event::read_log_event(): 'read error', data_len: 19200, event_type: 74
ERROR: Could not read entry at offset 677: Error in log format or read error.
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;

$ od -t x1 -j106 -N19 var/mysqld.1/data/master-bin.000002 
0000152 bc 1d 09 4a 02 01 00 00 00 44 00 00 00 ae 00 00
        ^^^^^^^^^^^                ^^^^^^^^^^^
         timestamp                    length
0000172 00 00 00
0000175

$ expr 106 + 68
174
$ od -t x1 -j174 -N19 var/mysqld.1/data/master-bin.000002 
0000256 bc 1d 09 4a 13 01 00 00 00 f7 01 00 00 a5 02 00
        ^^^^^^^^^^^                ^^^^^^^^^^^
         timestamp                    length
0000276 00 00 00
0000301

$ expr 174 + 503             # 0x1f7 == 503
677
$ od -t x1 -j677 -N19 var/mysqld.1/data/master-bin.000002 
0001245 03 bc 1d 09 4a 13 01 00 00 00 4b 00 00 ae 43 02
        ^^^^^^^^^^^ **             ^^^^^^^^^^^
         timestamp                    length
0001265 00 00 00
0001270

Length reported by mysqlbinlog: 19200 == 0x4b200
Type reported by mysqlbinlog: 74 == 0x4a (* above, just after timestamp)