There is a table of statistics. It is written per day for each user, game, etc.
I have a unique hash_id index. I just build a hash for the desired values, then check if there is an entry with such a hash_id . And if it is, then you need to update, otherwise insert.
InnoDB table.
Yesterday, it seems that a situation occurred when making a SELECT , there was no record, but at the same time a record was inserted by another process, and Integrity constraint violation was received ...
I wanted to immediately LOCK TABLES , but they write that for InnoDB tables this is wrong.
How to block in this case the table?
Ps INSERT ... ON DUPLICATE UPDATE does not offer, because mysql does not know how to replicate it.