My database is mysql5.7, innodb, isolation level is READ COMMITTED. I am afraid of deadlock, so I keep mysql sql statement simple, only have:
insert into ... where ...
insert into ... where ... on duplicate key update ...
update ... where ...
delete from ... where ...
select * from ... where ...
Each sql will have only one statement of above. for example:
A connection exec insert into ... where ...;
for once, never exec multi statement insert ... where ...; update ... where ...;
The where
statement have unique index constraint to assure operating only one row except select.
Only the select operation will involve multi rows.
I have 64 or more mysql connections, and I separate mysql operation to assure each connection operating different row.
With the autocommit=1 configuration, will deadlock happen? If the deadlock probability is not zero, what is the scene to enter deadlock? and Why? I need help. Thank you.
If your updates will use multi rows operations or you don't have proper indexes and if you are doing multiple operations on same row at a time and then high possibilities for deadlock.
In case you see then check statement for deadlock with below command once.
SHOW ENGINE=InnoDB STATUS;