Skip to content

Docs: notes on a killed beat, clock skew, and handlers on a lost process - #11094

Open
ChristianMurphy wants to merge 3 commits into
celery:mainfrom
ChristianMurphy:docs/beat-sync-after-kill
Open

ChristianMurphy wants to merge 3 commits into
celery:mainfrom
ChristianMurphy:docs/beat-sync-after-kill

Conversation

@ChristianMurphy

@ChristianMurphy ChristianMurphy commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Note: Before submitting this pull request, please review our contributing
guidelines
& Anti AI spamming Guidelines. Before opening an AI based PR make sure you asked
in the discussion forum or in the related open issues first.

Description

Three notes for long-standing behaviour the docs don't mention. Docs only, 27 lines, two commits. This PR now includes #11095, as I offered on #11091, so there is one docs PR to review.

  • beat_sync_every (configuration): a beat that is killed between two writes of its schedule file starts again from the older file and sends a run a second time.
  • countdown and expires (calling guide): both depend on the sender's and the worker's clocks agreeing.
  • on_failure() and after_return() (task guide): neither is called when the pool process that runs the task is lost.
Measurements on main (9c2f238): a killed beat
celery beat with one crontab(minute='*') entry, stopped 5 s after a send and started again After the restart
Killed with SIGKILL The same minute was sent again, 2 of 2 runs
Stopped with SIGTERM No run was sent again, 1 of 1
Killed with SIGKILL, beat_sync_every = 1 No run was sent again, 1 of 1

kombu main (445027e), Redis broker, the default PersistentScheduler. The cause is in Scheduler.should_sync() (celery/beat.py:416): with the default, beat syncs on the first send after a start and then when 3 minutes have passed.

Measurements on main (9c2f238): clock skew, and a lost pool process
Clocks 10 s apart Result, 2 of 2 runs each
countdown=5, worker ahead Started 0.0 s after the call
expires=5, worker ahead Discarded as REVOKED, never ran
expires=2 behind a 5 s task, worker behind Started 5.0 s after the call, SUCCESS

With equal clocks the countdown started after 5.0 s, and the expires=2 task was discarded. The calling guide says a task is guaranteed to run after its ETA. The note goes right below that.

When the pool process that runs a task is lost, FAILURE is stored, the errback runs and task_failure is sent, but Task.on_failure() and after_return() are not called, in 2 of 2 runs. Since 5.7 a hard time limit calls both handlers from the main process. If you'd rather have a lost process do the same, I can look at that in place of the note.

beat writes its schedule file on the first send after a start, then
every three minutes, and at a clean stop. A beat that is killed in
between starts again from the older file and sends the last run of an
entry a second time. The beat_sync_every docs describe the timing of the
sync and not this effect.
…st process

countdown and a numeric expires become a time on the sender's clock, and
the worker compares it with its own clock: with skewed clocks a task can
start early, or be discarded early or run after its expiry.

When the pool process that runs a task is lost, FAILURE is stored,
errbacks run and task_failure is sent from the main process, but
Task.on_failure and after_return are not called.
@ChristianMurphy ChristianMurphy changed the title Docs: say that a killed beat can send a run again Docs: notes on a killed beat, clock skew, and handlers on a lost process Nov 19, 2026
@auvipy
auvipy self-requested a review November 19, 2026 03:29
@auvipy auvipy added this to the 5.7.x milestone Nov 19, 2026

This branch has not been deployed

No deployments
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