Skip to content

Fix duplicate recurring enqueues when multiple schedulers run#54

Merged
knifecake merged 1 commit intomainfrom
fix/recurring-duplicate-enqueue-52
Apr 21, 2026
Merged

Fix duplicate recurring enqueues when multiple schedulers run#54
knifecake merged 1 commit intomainfrom
fix/recurring-duplicate-enqueue-52

Conversation

@knifecake
Copy link
Copy Markdown
Owner

@knifecake knifecake commented Apr 21, 2026

Summary

  • fix recurring execution recording to use create semantics instead of update_or_create
  • raise/catch RecurringExecution.AlreadyRecorded to skip duplicate runs
  • keep enqueue + recurring execution record in one transaction so duplicate inserts rollback
  • add regression test for same-task/same-run_at double enqueue
  • add CHANGELOG entry under Unreleased

Why

When two scheduler instances enqueue the same recurring task at the same run_at, update_or_create allowed both jobs to be enqueued and the second worker only updated the record. This caused duplicate job execution.

This aligns behavior with Solid Queue's AlreadyRecorded flow.

Closes #52

Validation

  • uv run python manage.py test tests.test_recurring_execution --keepdb
  • uv run python manage.py test tests.test_recurring_task tests.test_recurring_execution --keepdb
  • uv run ruff check steady_queue/models/recurring_execution.py steady_queue/models/recurring_task.py tests/test_recurring_execution.py

@knifecake knifecake merged commit a86af79 into main Apr 21, 2026
3 checks passed
@knifecake knifecake deleted the fix/recurring-duplicate-enqueue-52 branch April 21, 2026 07:15
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.

Recurring task run twice when there is two instances of steady queue

1 participant