Concurrent updates to the same row

后端 未结 1 334
日久生厌
日久生厌 2021-01-16 00:41

I\'m trying to figure out what is supposed to happen in MySQL/InnoDB if I issue the following 2 queries from different clients at the same time:

UPDATE tbl S         


        
相关标签:
1条回答
  • 2021-01-16 01:18

    You're right. The two update operations will be serialized one after the other. Their order is very hard to predict, so you should not try.

    If a third query asks SELECT a, b FROM tbl WHERE id=123 at more or less the same time, that query will be serialized, unpredictably, with the others. So it may happen before, between, or after the other two.

    Both update queries will eventually complete. It takes more than these queries to cause a deadlock.

    0 讨论(0)
提交回复
热议问题