[the problem is not established] Why deadlocks occur among successive insert under multiple processes in mysql

Sorry, there is a mistake in the question. An explanation has been made in the answer

the scenario is that there is a script task, that starts multiple processes

these processes operate on multiple tables at the same time (only insert, for these tables, but may insert multiple times for a table), start a transaction from the first table, and commit the transaction after the last table, such as

.

table1
table2
table3
table4

the order in which these tables can be manipulated is fixed, only from top to bottom, but the number of operations is uncertain (for example, process 1 operations 1, 4, process 2 operations 2, 4)

the storage engine used is innodb

mysql error message is
Deadlock found when trying to get lock; try restarting transactionin
error number 1213

Aug.27,2021

I'll answer it myself. It's kind of an own goal.

No two questions were found to affect the analysis:

1. The operation on the table is not only insert but also update, uses insert. On duplicate update..
2. Cannot be considered from the point of view of locking tables (it is not right to consider a more stringent situation, but deadlocks are often caused by fine-grained)

the scene that appears is:

12table1table1insert/update:

1:1->2->3
2:3->2->1

in short, you have to think more about the scenario with transactions, and then try to be as concise as possible

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b347a1-2b464.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b347a1-2b464.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?