search

Home  >  Q&A  >  body text

php - Ask me about mysql transactions, locks and transactions?

For example, if the account balance is 100 yuan, if the balance is greater than the transaction amount during the transaction, the transaction will be successful.
Now assuming that this user has multiple transactions at the same time, there will be problems during detection.

question:

  1. I would like to ask if using the SERIERLIZED isolation level of the transaction can solve this problem at this time.

  2. Or lock this row of data. How to add this lock?

代言代言2757 days ago967

reply all(1)I'll reply

  • 阿神

    阿神2017-06-24 09:43:23

    1. This problem can be solved, but the performance may drop drastically

    2. You can add optimistic lock

    reply
    0
  • Cancelreply