Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

celery beat timedetal interval does not work #8813

Open
5 of 18 tasks
Su-yj opened this issue Jan 22, 2024 · 0 comments
Open
5 of 18 tasks

celery beat timedetal interval does not work #8813

Su-yj opened this issue Jan 22, 2024 · 0 comments

Comments

@Su-yj
Copy link

Su-yj commented Jan 22, 2024

Checklist

  • I have verified that the issue exists against the main branch of Celery.
  • This has already been asked to the discussions forum first.
  • I have read the relevant section in the
    contribution guide
    on reporting bugs.
  • I have checked the issues list
    for similar or identical bug reports.
  • I have checked the pull requests list
    for existing proposed fixes.
  • I have checked the commit log
    to find out if the bug was already fixed in the main branch.
  • I have included all related issues and possible duplicate issues
    in this issue (If there are none, check this box anyway).

Mandatory Debugging Information

  • I have included the output of celery -A proj report in the issue.
    (if you are not able to do this, then at least specify the Celery
    version affected).
  • I have verified that the issue exists against the main branch of Celery.
  • I have included the contents of pip freeze in the issue.
  • I have included all the versions of all the external dependencies required
    to reproduce this bug.

Optional Debugging Information

  • I have tried reproducing the issue on more than one Python version
    and/or implementation.
  • I have tried reproducing the issue on more than one message broker and/or
    result backend.
  • I have tried reproducing the issue on more than one version of the message
    broker and/or result backend.
  • I have tried reproducing the issue on more than one operating system.
  • I have tried reproducing the issue on more than one workers pool.
  • I have tried reproducing the issue with autoscaling, retries,
    ETA/Countdown & rate limits disabled.
  • I have tried reproducing the issue after downgrading
    and/or upgrading Celery and its dependencies.

Related Issues and Possible Duplicates

Related Issues

Possible Duplicates

  • None

Environment & Settings

Celery version: 5.3.4 or 5.3.6

celery report Output:

[2024-01-22 15:44:26,090: DEBUG/MainProcess] Setting default socket timeout to 30
[2024-01-22 15:44:26,090: INFO/MainProcess] beat: Starting...
[2024-01-22 15:44:26,097: DEBUG/MainProcess] DatabaseScheduler: initial read
[2024-01-22 15:44:26,097: DEBUG/MainProcess] Writing entries...
[2024-01-22 15:44:26,098: DEBUG/MainProcess] DatabaseScheduler: Fetching database schedule
[2024-01-22 15:44:26,116: DEBUG/MainProcess] Current schedule:
<ModelEntry: celery.backend_cleanup celery.backend_cleanup(*[], **{}) <crontab: 0 4 * * * (m/h/dM/MY/d)>>
<ModelEntry: collect_doc framework_file.tasks.collect_doc(*[], **{}) <crontab: 0 2 * * * (m/h/dM/MY/d)>>
<ModelEntry: job_check_auth_file_expire framework_file.tasks.job_check_auth_file_expire(*[], **{}) <crontab: 30 8 * * * (m/h/dM/MY/d)>>
<ModelEntry: job_update_calendar core.tasks.job_update_calendar(*[], **{}) <crontab: 30 3 * * * (m/h/dM/MY/d)>>
<ModelEntry: job_sync_gpm efficiency_processor.processor_gpm.tasks.job_sync_gpm(*[], **{}) <crontab: 0 6 * * 6 (m/h/dM/MY/d)>>
<ModelEntry: job_remind_submit_new efficiency.tasks.job_remind_submit_new(*[], **{}) <crontab: 0,30 16,17 * * * (m/h/dM/MY/d)>>
<ModelEntry: job_update_mobile_info testing.tasks.job_update_mobile_info(*[], **{}) <freq: 3.00 minutes>>
<ModelEntry: job_sync_rdm efficiency_processor.processor_rdm.tasks.job_sync_rdm(*[], **{}) <crontab: 0 4 * * * (m/h/dM/MY/d)>>
<ModelEntry: job_clean_expire_task testing.tasks.job_clean_expire_task(*[], **{}) <freq: 3.00 minutes>>
<ModelEntry: 清理 testing 空间 testing.tasks.job_maintain_space(*[], **{}) <crontab: 0 6 * * * (m/h/dM/MY/d)>>
<ModelEntry: job_clean_invalid_rate_task testing_tool.tasks.job_clean_invalid_rate_task(*[], **{}) <crontab: 0 1 * * * (m/h/dM/MY/d)>>
<ModelEntry: job_test efficiency.tasks.test(*[], **{}) <freq: 1.00 minute>>
[2024-01-22 15:44:26,182: INFO/MainProcess] DatabaseScheduler: Schedule changed.
[2024-01-22 15:44:26,182: DEBUG/MainProcess] Writing entries...
[2024-01-22 15:44:26,182: DEBUG/MainProcess] DatabaseScheduler: Fetching database schedule
[2024-01-22 15:44:26,192: DEBUG/MainProcess] Current schedule:
<ModelEntry: celery.backend_cleanup celery.backend_cleanup(*[], **{}) <crontab: 0 4 * * * (m/h/dM/MY/d)>>
<ModelEntry: collect_doc framework_file.tasks.collect_doc(*[], **{}) <crontab: 0 2 * * * (m/h/dM/MY/d)>>
<ModelEntry: job_check_auth_file_expire framework_file.tasks.job_check_auth_file_expire(*[], **{}) <crontab: 30 8 * * * (m/h/dM/MY/d)>>
<ModelEntry: job_update_calendar core.tasks.job_update_calendar(*[], **{}) <crontab: 30 3 * * * (m/h/dM/MY/d)>>
<ModelEntry: job_sync_gpm efficiency_processor.processor_gpm.tasks.job_sync_gpm(*[], **{}) <crontab: 0 6 * * 6 (m/h/dM/MY/d)>>
<ModelEntry: job_remind_submit_new efficiency.tasks.job_remind_submit_new(*[], **{}) <crontab: 0,30 16,17 * * * (m/h/dM/MY/d)>>
<ModelEntry: job_update_mobile_info testing.tasks.job_update_mobile_info(*[], **{}) <freq: 3.00 minutes>>
<ModelEntry: job_sync_rdm efficiency_processor.processor_rdm.tasks.job_sync_rdm(*[], **{}) <crontab: 0 4 * * * (m/h/dM/MY/d)>>
<ModelEntry: job_clean_expire_task testing.tasks.job_clean_expire_task(*[], **{}) <freq: 3.00 minutes>>
<ModelEntry: 清理 testing 空间 testing.tasks.job_maintain_space(*[], **{}) <crontab: 0 6 * * * (m/h/dM/MY/d)>>
<ModelEntry: job_clean_invalid_rate_task testing_tool.tasks.job_clean_invalid_rate_task(*[], **{}) <crontab: 0 1 * * * (m/h/dM/MY/d)>>
<ModelEntry: job_test efficiency.tasks.test(*[], **{}) <freq: 1.00 minute>>
[2024-01-22 15:44:26,193: DEBUG/MainProcess] beat: Ticking with max interval->5.00 seconds
[2024-01-22 15:44:26,228: DEBUG/MainProcess] beat: Waking up in 5.00 seconds.
[2024-01-22 15:44:31,229: DEBUG/MainProcess] beat: Synchronizing schedule...
[2024-01-22 15:44:31,230: DEBUG/MainProcess] Writing entries...
[2024-01-22 15:44:31,235: DEBUG/MainProcess] beat: Waking up in 5.00 seconds.

Steps to Reproduce

Required Dependencies

  • Minimal Python Version: 3.11.6
  • Minimal Celery Version: 5.3.6
  • Minimal Kombu Version: 5.3.5
  • Minimal Broker Version: RabbitMQ 3.12.4 or redis 5.0.10 has the same issue
  • Minimal Result Backend Version: mysql 8
  • Minimal OS and/or Kernel Version: Linux ed3982f191b1 3.10.0-1160.49.1.el7.x86_64 #1 SMP Tue Nov 30 15:51:32 UTC 2021 x86_64 GNU/Linux ( run in docker, the image build with python:buster )
  • Minimal Broker Client Version: N/A or Unknown
  • Minimal Result Backend Client Version: N/A or Unknown

Python Packages

pip freeze Output:

alabaster==0.7.13
amqp==5.1.1
asgiref==3.7.2
Babel==2.13.0
bcrypt==4.0.1
billiard==4.2.0
celery==5.3.6
celery-error-emails==0.3
certifi==2023.7.22
cffi==1.16.0
charset-normalizer==3.3.0
click==8.1.7
click-didyoumean==0.3.0
click-plugins==1.1.1
click-repl==0.3.0
cron-descriptor==1.4.0
cryptography==41.0.4
Django==3.2.23
django-bulk-update-or-create==0.3.0
django-celery-beat==2.5.0
django-celery-results==2.5.1
django-cors-headers==4.3.0
django-cron==0.6.0
django-filter==21.1
django-fullclean==0.0.5
django-redis==5.4.0
django-scaffold-tools==0.0.63
django-timezone-field==6.0.1
django-uuslug==2.0.0
djangogrpcframework==0.2.1
djangorestframework==3.14.0
djangorestframework-queryfields==1.0.0
djangorestframework-simplejwt==5.3.0
djangorestframework-yaml==2.0.0
docutils==0.16
docxcompose==1.4.0
docxtpl==0.16.7
drf-dynamic-fields==0.4.0
et-xmlfile==1.1.0
gevent==23.9.1
greenlet==3.0.3
grpcio==1.59.0
grpcio-reflection==1.59.0
grpcio-tools==1.59.0
idna==3.4
imagesize==1.4.1
Jinja2==3.1.2
kombu==5.3.5
lxml==5.1.0
MarkupSafe==2.1.3
multi-key-dict==2.0.3
mysqlclient==2.2.1
numpy==1.26.3
opencv-python==4.8.1.78
openpyxl==3.1.2
packaging==23.2
pandas==1.5.3
paramiko==2.12.0
pbr==5.11.1
Pillow==10.1.0
prompt-toolkit==3.0.39
protobuf==4.24.4
pyasn1==0.5.0
pyasn1-modules==0.3.0
pycparser==2.21
pycryptodome==3.20.0
pyDes==2.0.1
PyExecJS==1.5.1
Pygments==2.16.1
PyJWT==2.8.0
PyNaCl==1.5.0
PySocks==1.7.1
python-consul==1.1.0
python-crontab==3.0.0
python-dateutil==2.8.2
python-docx==1.1.0
python-gitlab==2.10.1
python-jenkins==1.8.2
python-ldap==3.4.3
python-pptx==0.6.23
python-slugify==8.0.1
pytz==2023.3.post1
PyYAML==6.0.1
pyzbar==0.1.9
redis==4.6.0
requests==2.31.0
requests-toolbelt==1.0.0
scipy==1.11.3
selenium==3.141.0
simplejson==3.19.2
six==1.16.0
snowballstemmer==2.2.0
Sphinx==3.5.4
sphinx-rtd-theme==0.5.2
sphinxcontrib-applehelp==1.0.4
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==2.0.1
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.5
sqlparse==0.4.4
text-unidecode==1.3
typing_extensions==4.9.0
tzdata==2023.3
urllib3==2.0.6
uWSGI==2.0.22
vine==5.1.0
wcwidth==0.2.8
xlrd==1.2.0
XlsxWriter==1.4.5
zope.event==5.0
zope.interface==6.1

Other Dependencies

N/A

Minimally Reproducible Test Case

Expected Behavior

The schedule job run every 180 seconds.

Actual Behavior

There have tow situations.

Situation one: the database has old periodictask

When the job set the schedule by timedelta(seconds=180), it does not work.
And when I set the job by crontab(minute='*/3'), it`s working.

Situation tow: clear Clean up data related to django_celery_result and django_celery_beat

When I clear up the data from database, and I set the job by app.conf.beat_schedule like this

app.conf.beat_schedule = {
    'job_test': dict(
        task='efficiency.tasks.test',
        schedule=timedelta(minutes=1),
    )
}

the celery beat will always sending due task.

[2024-01-22 16:23:00,973: DEBUG/MainProcess] Setting default socket timeout to 30
[2024-01-22 16:23:00,973: INFO/MainProcess] beat: Starting...
[2024-01-22 16:23:00,979: DEBUG/MainProcess] DatabaseScheduler: initial read
[2024-01-22 16:23:00,979: DEBUG/MainProcess] Writing entries...
[2024-01-22 16:23:00,979: DEBUG/MainProcess] DatabaseScheduler: Fetching database schedule
[2024-01-22 16:23:00,990: DEBUG/MainProcess] Current schedule:
[2024-01-22 16:23:01,051: INFO/MainProcess] DatabaseScheduler: Schedule changed.
[2024-01-22 16:23:01,051: DEBUG/MainProcess] Writing entries...
[2024-01-22 16:23:01,051: DEBUG/MainProcess] DatabaseScheduler: Fetching database schedule
[2024-01-22 16:23:01,061: DEBUG/MainProcess] Current schedule:
<ModelEntry: celery.backend_cleanup celery.backend_cleanup(*[], **{}) <crontab: 0 4 * * * (m/h/dM/MY/d)>>
<ModelEntry: job_test efficiency.tasks.test(*[], **{}) <freq: 1.00 minute>>
[2024-01-22 16:23:01,061: DEBUG/MainProcess] beat: Ticking with max interval->5.00 seconds
[2024-01-22 16:23:01,101: INFO/MainProcess] Scheduler: Sending due task job_test (efficiency.tasks.test)
[2024-01-22 16:23:01,120: DEBUG/MainProcess] beat: Synchronizing schedule...
[2024-01-22 16:23:01,120: DEBUG/MainProcess] Writing entries...
[2024-01-22 16:23:01,136: DEBUG/MainProcess] efficiency.tasks.test sent. id->72db9987-3c09-4413-8112-3fd88a7f574f
[2024-01-22 16:23:01,145: INFO/MainProcess] Scheduler: Sending due task job_test (efficiency.tasks.test)
[2024-01-22 16:23:01,147: DEBUG/MainProcess] efficiency.tasks.test sent. id->d611506a-eb94-43df-95ea-6eff47d4814c
[2024-01-22 16:23:01,152: INFO/MainProcess] Scheduler: Sending due task job_test (efficiency.tasks.test)
[2024-01-22 16:23:01,154: DEBUG/MainProcess] efficiency.tasks.test sent. id->02d60712-d49a-4356-b4ca-79bfe5ebb850
[2024-01-22 16:23:01,161: INFO/MainProcess] Scheduler: Sending due task job_test (efficiency.tasks.test)
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant