所以我遇到类似in this SO question
的问题我认为下面会导致死锁,因为他们将id 1,2和3锁定在一个圆圈内。
- 交易1
UPDATE season_end_date SET ... WHERE id = 1
UPDATE season_end_date SET ... WHERE id = 2
- 交易2
UPDATE season_end_date SET ... WHERE id = 2
UPDATE season_end_date SET ... WHERE id = 3
- 交易3
UPDATE season_end_date SET ... WHERE id = 3
UPDATE season_end_date SET ... WHERE id = 1
但是,如果我按ID订购更新怎么办,那就像是:
- 交易1
UPDATE season_end_date SET ... WHERE id = 1
UPDATE season_end_date SET ... WHERE id = 2
- 交易2
UPDATE season_end_date SET ... WHERE id = 2
UPDATE season_end_date SET ... WHERE id = 3
- 交易3
UPDATE season_end_date SET ... WHERE id = 1
UPDATE season_end_date SET ... WHERE id = 3
这会解决死锁问题吗?我想是这样,因为T3现在应该能够运行,之后,T2可以运行,最后一个T1。