Do PDO transactions until all other transactions are completed?

If I am right, PDO transactions are not really transactions: they just disable auto-commands (see the documentation ).

So, if I have a transaction A that deletes a row and a transaction B that modifies the same row, the following may happen.

  • Transaction A starts and disables auto-update.
  • Transaction B starts and disables auto-update.
  • Transaction A deletes a row.
  • Transaction B modifies the same row.
  • Transaction A completes and commits the changes.
  • Transaction B completes and commits the changes.

But in step 6, the row was already deleted in step 5. What will happen?

Also, how can I ensure that transaction B is locked until transaction A? FYI, I am using PDO with mysql with innoDB.

Thanks.

+4
source share
1 answer

As @eggyal noted, transactions can occur simultaneously, but stat DELETE puts an exclusive lock on the line until the transaction is completed, so transaction B will be automatically locked in step 4 until transaction A is committed. The exclusive blocking block writes and also reads.

0
source

Source: https://habr.com/ru/post/1484531/


All Articles