Skip to content

Conversation

itimky
Copy link

@itimky itimky commented Oct 20, 2018

There are cases when row-level deadlocks occur on simultaneous update, celery task & Django view for instance.
If update order is preserved (order by pk) there are no more deadlocks.
Implemented via CTE.
Added "ordered=False" for backward compatibility & keep overhead away if ordering not needed.

@mkomitee
Copy link

mkomitee commented Sep 5, 2019

I'm not sure that it matters much at this point, but this only ensures sorting within batches, so if you use the batch feature you're still exposed to the potential for deadlocks.

@itimky
Copy link
Author

itimky commented Sep 10, 2019

Correct, but it's possible to sort your data before passing it to bulk_update, so the sorting order will be preserved across all batches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants