All I read about table locks in MySQL concerns different sessions, so one session cannot interfere with another one. But what if I want multiple transactions from the same session to be mutually exclusive? SELECT ... FOR UPDATE
only locks certain rows but I want the whole table to be locked.
In other words: If a specific transaction is running, no other transaction should be able to start, no matter which session it is from. When the first transaction finishes, the second one should start.
Asked
Active
Viewed 81 times
0

Kai
- 1
- 1
-
Have you considered `BEGIN` and `COMMIT`? – Barry Carter Jul 03 '22 at 13:08
-
1The same session cannot have multiple parallel transactions (MySQL doesn't even support nested transactions). Please clarify what you mean by that, e.g. what you are trying to do. – Solarflare Jul 03 '22 at 19:06
-
Maybe this subject will help you : https://stackoverflow.com/questions/32473928/mysql-multiple-transactions-incrementing-same-row As @Solarflare said, you can't have parallel transactions. So the following transactions will only work if the previous one is committed or roll back. – LPK Jul 05 '22 at 14:40