Bug #53561 HA_EXTRA_WRITE_CAN_REPLACE does not work with row based replication
Submitted: 11 May 2010 12:20 Modified: 14 May 2010 15:04
Reporter: Zardosht Kasheff (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.1.46, 5.5 OS:Any
Assigned to: Assigned Account CPU Architecture:Any

[11 May 2010 12:20] Zardosht Kasheff
Description:
Bug filed as result of this discussion on internals list: http://lists.mysql.com/internals/37907

The flag HA_EXTRA_WRITE_CAN_REPLACE, according to the comments, means:
  /*
    Informs handler that write_row() which tries to insert new row into the
    table and encounters some already existing row with same primary/unique
    key can replace old row with new row instead of reporting error (basically
    it informs handler that we do REPLACE instead of simple INSERT).
    Off by default.
  */

If on a master, the storage engine finds a duplicate, and decides to replace the old row with the new row, then replication will fail on the slave. The slave will not know that a replace is occurring, and will encounter a duplicate key error.

How to repeat:
n/a

Suggested fix:
Enough information should be stored in row based replication to simulate a replace. If the master has the flag HA_EXTRA_WRITE_CAN_REPLACE set, then this should be saved in the binary log, and the slave should know that if a duplicate key error is found, that a replace should occur.
[14 May 2010 15:04] Susanne Ebrecht
Many thanks for writing a bug report.

Verified as described and by reading comments from Mats.