Open jcushman opened 3 weeks ago
Be a notch more selective in when to update bonus_links in Folder.save() -- I'm not sure how often this matters.
Oh, I suspect this would have made the difference here! The deadlock is on this line:
And the deadlocked call was "UPDATE "perma_linkuser" SET "bonus_links" = NULL WHERE "perma_linkuser"."id" = %s", which suggests bonus_links weren't in play. So moving the save() up into the if block above would have prevented it entirely.
I think the other important question is, is this select_for_update still doing anything?
If that was just to protect the bonus_links count I think we can lose it, but maybe it's for something else too, in which case we could make it more specific.
This is a quick sketch to try to reduce opportunities for deadlocks in saving or moving links.
Sketch: