fix(submissions): prevent silent submission losses#2408
Open
AybH26 wants to merge 1 commit into
Open
Conversation
Member
Collaborator
|
"CELERY_BEAT_SCHEDULE published refresh_compute_worker_health (does not exist) → KeyError killed the consumer channel" This is correct, it's an artefact from the last compute worker monitoring deployment and this is fixed in the next PR for worker monitoring (#2395). |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Title
fix(submissions): prevent silent submission losses
Summary
Fixes the silent submission-loss incident first reported in 2025 (~30 %
of submissions stuck in
Submitting/Submitted/Scoringwith notraceable error).
Root causes
The incident wasn't one bug — it was a chain of five compounding issues
across the Django site worker, Celery beat, and the compute worker.
Each could silently drop a submission on its own; combined they turned
idle traffic into a ~30 % loss rate.
watchmedowrapped Celery prefork → SIGTERM not forwarded → channel torn down without acking the in-flightrun_submissionCELERY_BEAT_SCHEDULEpublishedrefresh_compute_worker_health(does not exist) →KeyErrorkilled the consumer channelSubmittingrows,celery_task_id=NoneScoring/Runningafter a worker crash — they stayed stuck foreverurllib3.Retryexcludes PATCH by default — the finalPATCH status=Finishedwas never retried. (b)_update_statusswallowed every exception, sotask_acks_late=Trueacked tasks whose terminal update had failed.Changes
F1 —
docker-compose.ymlwatchmedowrapper around the Celery prefork pool onsite_worker.site-workerand the defaultceleryqueue so beat-published tasks land where the worker consumes.F2 —
src/settings/base.pyrefresh_compute_worker_healthbeat entry (task does not exist anywhere in the codebase).F3 —
docker-compose.ymlsite_workermemory limit from256Mto1G.M1.A —
src/apps/competitions/tasks.py+src/settings/base.pyreaper_stuck_scoringCelery task onsite-workerqueue, soft limit 5 min.Scoring/Runningpaststarted_when + execution_time_limit + threshold_minutes.CELERY_BEAT_SCHEDULEwiththreshold_minutes=30.Submission.status_detailswith a reaper marker for/adminand API visibility.M1.B —
compute_worker/compute_worker.pyrequestssession adapter:Retry(total=5, backoff_factor=2, status_forcelist=(500,502,503,504), allowed_methods=frozenset((..., PATCH)))._update_statusnow re-raises whenstatus == FINISHEDso Celery (withtask_acks_late=True) requeues the job.Intermediate states (
Running,Scoring) stay best-effort to avoid killing a scoring run for a transient glitch.Failedalready has araisein every caller, so the requeue path is covered.