django-celery-beat icon indicating copy to clipboard operation
django-celery-beat copied to clipboard

DatabaseScheduler does not drop beat_schedule-equivalent PeriodicTasks that were removed from the beat_schedule dict

Open sanchit-mathew opened this issue 1 year ago • 2 comments

Summary:

The DatabaseScheduler picks up tasks from the beat schedule and creates or updates corresponding PeriodicTask entries on the scheduler's setup but doesn't drop the PeriodicTask entry if the beat schedule entry corresponding to that task is dropped

  • Celery Version: 5.2.3
  • Celery-Beat Version: 2.4.0

Exact steps to reproduce the issue:

  1. Have a CELERYBEAT_SCHEDULE setup in your Django settings with a couple of tasks
  2. Start the Celery Beat service with the scheduler as DatabaseScheduler. There will be PeriodicTask entries created in the DB, corresponding to the CELERYBEAT_SCHEDULE tasks
  3. Stop the Celery Beat service and remove one or more tasks from the CELERYBEAT_SCHEDULE setting
  4. Restart the Celery Beat service with the DatabaseScheduler scheduler. The PeriodicTask entries corresponding to the CELERYBEAT_SCHEDULE tasks still exist and remain enabled

Detailed information

https://github.com/celery/django-celery-beat/blob/1f1c3638170c5d7620fca09221bb2e9aaea7f2b6/django_celery_beat/schedulers.py#L320

  • At this line, we use the default beat_schedule and create/update PeriodicTask entries corresponding to the same but if there are any tasks dropped in the beat_schedule, the PeriodicTask entries corresponding to the same are not deleted/disabled accordingly

sanchit-mathew avatar May 12 '23 09:05 sanchit-mathew

Sounds like the same issue as

  • #248?

ento avatar Jul 22 '23 00:07 ento

Hi, I found a solution - check this out

  • #768

m-r-k-f avatar Jul 10 '24 08:07 m-r-k-f