Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

Fix Celery deadlocks by removing all blocking tasks from parent tasks #359

Merged
merged 1 commit into from
Dec 4, 2013

Conversation

gabrtv
Copy link
Member

@gabrtv gabrtv commented Dec 4, 2013

After discussing the issue at length with the helpful folks on IRC, it was confirmed that the upgrade to Celery 3.1.x made this problem much worse for us as "the pool prefetching will (now) write the tasks to the same process that is waiting".

Celery best practice is to not call blocking tasks within other tasks or risk resource starvation and deadlocking, see:
http://docs.celeryproject.org/en/latest/userguide/tasks.html#avoid-launching-synchronous-subtasks

This PR moves much of the blocking subtasks into the model methods. It has the added benefit of simplifying view/task code with a net decrease in total lines of code. While it's possible this introduced a regression, I did heavy testing with a pool of 1.

…t) tasks, and moving the logic to inline model methods

i was able to confirm this works by setting a autoscale pool of 10,1 and watching it scale up/down when handling a large number of tasks.
@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 48ac3ee on fix-celery-deadlock into 252c127 on master.

mboersma added a commit that referenced this pull request Dec 4, 2013
Fix Celery deadlocks by removing all blocking tasks from parent tasks
@mboersma mboersma merged commit 6add94a into master Dec 4, 2013
@mboersma mboersma deleted the fix-celery-deadlock branch December 4, 2013 23:10
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants