Our system is doing about 50 inserts per second. During ~2 hour period we are seeing up to 3 of "Deadlock found when trying to get lock; try restarting transaction" conditions. Yes, the client restarts the transaction so it's not catastrophic.
Is this something I should start looking into, like ensuring order of accesses, or it's inevitable to have deadlocks at some concurrency level with InnoDB?
With C/C++ I didn't have much of a problem ensuring order of acquisitions of mutexes, but with SQL it's not obvious to me how to ensure orderly locking nor how to locate problem areas. For instance, is there a log-level I can turn on in MySQL that will show what concurrent SQL statement held a lock that prevented "this" statement to rollback (my error.log is empty). I understand this can have something to do with my indexes, but I'm not sure where to start.
One more question: if I split read accesses like reports and delegate them to read-only DB replicas, would that be helpful in avoiding deadlocks on inserts?
Now my deadlock has its own post: Simple conditional update causing a deadlock hints at MySQL bug