here is the problem:
I have a table like
byUserDailyStatistics:
All requests are
INSERT INTO byEmailDailyStatistics
(date, idUser, metric1, metric2)
VALUES (:date, :user:, 1, 1)
ON DUPLICATE KEY UPDATE
metric1 = metric1 + 1,
metric2 = metric2 +1
And sometimes, the replication breaks with message like
could not execute Write_rows event on table stats.byUserDailyStatistics; Duplicate entry '6447412-2016-01-06' for key 'UNIQUE', Error_code: 1062; handler error HA_ERR_FOUND_DUPP_KEY; the event's master log mysql-bin.035580, end_log_pos 279798813
What could be the origin of this issue?
You are trying to write the same idUser, date
pair to both your replicas at the same time.
In the last step the same pair exists on both server under different primary keys; different rows but the secondary unique key is the same.