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

fix: simplify task fetching by removing crontab exclusion #956

Open ncimino opened this issue 3 months ago • 6 comments

Removed crontab exclusion logic from task fetching. Filters were created to limit window to +/-2 hours for crontab, but tasks are never refetched - must either implement refetching protocol or (as implemented here) remove the filter entirely.

ncimino avatar Oct 08 '25 17:10 ncimino

can not verify this as there is no appropriate test cases. and the CI is failing. i think it would be better to implement improved protocol

@auvipy / @alirafiei75 any suggestions on how/when the tasks should be getting refetched/parsed from the DB? The code obviously expected this behavior, but it is not happening. I'm also curious if there are other tests that we expected to cover this code originally?

ncimino avatar Oct 09 '25 04:10 ncimino

can not verify this as there is no appropriate test cases. and the CI is failing. i think it would be better to implement improved protocol

I think that mechanism with sliding window is not bad, we just need to force this sliding every hour or less. In 2.8.1 was added code that seems forces full reload every 5 minutes. So it seems its not a problem anymore https://github.com/celery/django-celery-beat/blob/6427286d59466b4af931739fb47cf61404b14560/django_celery_beat/schedulers.py#L519-L531

kamyanskiy avatar Nov 06 '25 09:11 kamyanskiy

but we need a proper solution with appropriate tests

auvipy avatar Nov 06 '25 12:11 auvipy

That 5 minute force refresh is not happening for crontab. Some code runs, but the reload never rereads/refreshes from the database.

This code you are referring to as the fix has been there since before v2.8.1 and the issue presents in v2.8.1: https://github.com/celery/django-celery-beat/blame/v2.8.1/django_celery_beat/schedulers.py#L515-L527

As @auvipy has indicated, I think testing (if representative of client crontab use case) will be quite revealing.

ncimino avatar Nov 06 '25 14:11 ncimino

@ncimino @auvipy I would say that on 2.8.1 its not an issue anymore - just look at my logs - I showed that its work here https://github.com/celery/django-celery-beat/issues/956#issuecomment-3496313051

so sliding window works (at least with celery 5.5.3), you can see how it forces reload crontab schedules every 300sec and it works as well, my tasks those were planned out of sliding window, finally loaded in memory when window overlaps it, so I can see crontab tasks in my schedule in (-2 +2h) period. Looks good.

kamyanskiy avatar Nov 06 '25 16:11 kamyanskiy

@ncimino @auvipy I would say that on 2.8.1 its not an issue anymore - just look at my logs - I showed that its work here #956 (comment)

so sliding window works (at least with celery 5.5.3), you can see how it forces reload crontab schedules every 300sec and it works as well, my tasks those were planned out of sliding window, finally loaded in memory when window overlaps it, so I can see crontab tasks in my schedule in (-2 +2h) period. Looks good.

thanks for verifying

auvipy avatar Nov 06 '25 16:11 auvipy