-
-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(exports): tasks stuck in processing TASK-1243 (#5436)
### 📣 Summary Fixes occasional problem where tasks end up showing as 'Processing' forever. ### 💭 Notes Tasks were failing when the celery task started too quickly and tried to fetch the task before it had actually hit the database. This PR implements 2 guards against this: 1. Call the tasks from within an on_commit block to ensure they only start after the task object has made it to the database 2. Automatically catch ObjectDoesNotExist exceptions and retry the task a hardcoded number of times. `task.retry` takes care of putting some time in between retries ### 👀 Preview steps This bug tends to only appear in low traffic when the celery queue is empty. Make sure `CELERY_TASK_ALWAYS_EAGER` is false. 1. ℹ️ have an account and a project 3. Export the project submissions 4. 🔴 [on main] The job will show as 'Processing' indefinitely. In the worker logs, you'll see `kpi.models.import_export_task.SubmissionExportTask.DoesNotExist: SubmissionExportTask matching query does not exist` 5. 🟢 [on PR] The job will only show as 'Processing' for a few seconds and then will complete.
- Loading branch information
Showing
8 changed files
with
77 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters