celery / django-celery-beat

Celery Periodic Tasks backed by the Django ORM
Other
1.69k stars 429 forks source link

DJANGO_CELERY_BEAT Periodic Task is not getting scheduled if last_run_at is None and the Database Scheduled is Updated. #818

Open Akhilesh-Sirohi opened 1 day ago

Akhilesh-Sirohi commented 1 day ago

Summary:

DJANGO_CELERY_BEAT Periodic Task is not getting scheduled if last_run_at is None and the Database Scheduled is Updated.

Exact steps to reproduce the issue:

  1. Keep the database-schedule max_interval as 5 sec
  2. Create a task to schedule at time x using cron-schedule (task is supposed to run for first time, i.e last_run_at will be None)
  3. Just before 5 sec before time x, update the database.
  4. Now just before the task is supposed to run, the DatabaseScheduler's schedule will start getting updated at time x. (we can also use sleep such that update is going on time x).
  5. After the update, the task will not run.

Detailed information

what is happening here is: if the last_run_at is None then Entry takes the default value as time.now()= time x, so when the is_due fuction checks then it find last_run_at is same as schedule_time, so the task isn't scheduled.

cclauss commented 22 hours ago

Do the last_run_at pull requests solve this issue?