So I have a similar problem like in this SO question
I assume the below will cause a deadlock, as they lock the id 1, 2 and 3 in a circle.
-- Transaction 1
UPDATE season_end_date SET ... WHERE id = 1
UPDATE season_end_date SET ... WHERE id = 2
-- Transaction 2
UPDATE season_end_date SET ... WHERE id = 2
UPDATE season_end_date SET ... WHERE id = 3
-- Transaction 3
UPDATE season_end_date SET ... WHERE id = 3
UPDATE season_end_date SET ... WHERE id = 1
However, what if I order the updates by id, so it will be like:
-- Transaction 1
UPDATE season_end_date SET ... WHERE id = 1
UPDATE season_end_date SET ... WHERE id = 2
-- Transaction 2
UPDATE season_end_date SET ... WHERE id = 2
UPDATE season_end_date SET ... WHERE id = 3
-- Transaction 3
UPDATE season_end_date SET ... WHERE id = 1
UPDATE season_end_date SET ... WHERE id = 3
Will this fix the deadlock issue? I guess so, as T3 should now be able to run, and after that, T2 can run and a last T1.