Say, I we have master-master replication with only one master active at a time.

We have users table:

create table users (
 id int auto_increment,
 email varchar(255),

 primary key id(id),
 unique key email(email)

and web application cluster which inserts new record for new users.

Now we got error which stopped replication:

Error 'Duplicate entry 'something@example.com-' for key 'email'' on query. Default database: 'xxx'. Query: 'INSERT INTO users  ...

Question is: is that true that this error in this setup is impossible, and probable reason of error is that we had two masters active at same time?

1 Answer 1


Do not see the problem. When somebody enters the email address a second time then this happens. Nothing to do with replication. This is what the unique key is used for.

If this error would break the replication then I do not understand how replication could ever work. Every user could easily break the replication by, in this case, entering an email address 2 times.

I am not an MySQL expert but I think that the doc relates to errors other then maintaining data integrity. Perhaps somebody with more in-depth knowledge of clustering can help you on how to configure master-master clustering.

  • according to docs: dev.mysql.com/doc/refman/5.5/en/… "If a statement produces the same error (identical error code) on both the master and the slave, the error is logged, but replication continues. If a statement produces different errors on the master and the slave, the slave SQL thread terminates, and the slave writes a message to its error log and waits for the database administrator to decide what to do about the error" So replication won't break on simple duplicate entry error.
    – vsespb
    Jul 20, 2016 at 9:05
  • Wrong. The replication you're using is "master-master" not "master-slave" if you want to skip "Duplicate entry" errors, you have to use slave-skip-errors = 1062 in your my.cnf file. This is not recommended since you won't be able to look for keys problems.
    – oNare
    Jul 20, 2016 at 16:33
  • But master-master replication with one master active is "master-slave" replication.
    – vsespb
    Jul 20, 2016 at 16:39
  • 1
    Don't use slave-skip-errors, that just lets the two servers get more and more out of sync!
    – Rick James
    Jul 20, 2016 at 21:59
  • @vsespb - true, but M-S is also setup in the other direction, yet no data is flowing that way.
    – Rick James
    Jul 20, 2016 at 22:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.