Repository navigation
Closed
Description
Checklist
- I have included the output of
celery -A proj reportin the issue.
(if you are not able to do this, then at least specify the Celery
version affected).
software -> celery:4.0.2 (latentcall) kombu:4.0.2 py:3.4.0
billiard:3.5.0.2 redis:2.10.5
platform -> system:Linux arch:64bit, ELF imp:CPython
loader -> celery.loaders.app.AppLoader
settings -> transport:redis results:redis://localhost:6379/0
result_backend: 'redis://localhost:6379/0'
broker_url: 'redis://localhost:6379/0'
- I have verified that the issue exists against the
masterbranch of Celery.
Steps to reproduce
from celery import Celery
app = Celery('vanilla', broker='redis://localhost:6379/0', backend='redis://localhost:6379/0')
app.conf.enable_utc = False
@app.task(bind=True, max_retries=3, default_retry_delay=60)
def Fail(self):
try:
raise AssertionError('Oh My!')
except Exception as e:
self.retry(exc=e)
Expected behavior
A delay of around 60 seconds should happen between retries.
Actual behavior
The retry delay does not take any effect. This problem only occurs when enable_utc is set to False, as in the example above. The retry delay is however respected when enable_utc is left at its default value of True.
[2017-01-10 03:50:20,724: INFO/MainProcess] Received task: vanilla.Fail[8e3928ed-5a6a-4811-b2b6-c4b25ee51c74]
[2017-01-10 03:50:20,749: INFO/MainProcess] Received task: vanilla.Fail[8e3928ed-5a6a-4811-b2b6-c4b25ee51c74] ETA:[2017-01-10 03:51:20.727154+00:00]
[2017-01-10 03:50:20,752: INFO/PoolWorker-4] Task vanilla.Fail[8e3928ed-5a6a-4811-b2b6-c4b25ee51c74] retry: Retry in 60s: AssertionError('Oh My!',)
[2017-01-10 03:50:20,778: INFO/MainProcess] Received task: vanilla.Fail[8e3928ed-5a6a-4811-b2b6-c4b25ee51c74] ETA:[2017-01-10 03:51:20.755246+00:00]
[2017-01-10 03:50:20,779: INFO/PoolWorker-5] Task vanilla.Fail[8e3928ed-5a6a-4811-b2b6-c4b25ee51c74] retry: Retry in 60s: AssertionError('Oh My!',)
[2017-01-10 03:50:20,809: INFO/PoolWorker-2] Task vanilla.Fail[8e3928ed-5a6a-4811-b2b6-c4b25ee51c74] retry: Retry in 60s: AssertionError('Oh My!',)
[2017-01-10 03:50:20,809: INFO/MainProcess] Received task: vanilla.Fail[8e3928ed-5a6a-4811-b2b6-c4b25ee51c74] ETA:[2017-01-10 03:51:20.783516+00:00]
[2017-01-10 03:50:20,812: ERROR/PoolWorker-4] Task vanilla.Fail[8e3928ed-5a6a-4811-b2b6-c4b25ee51c74] raised unexpected: AssertionError('Oh My!',)
Traceback (most recent call last):
File "/auto/firex-ott/moe_4.0.2/lib/python3.4/site-packages/celery/app/trace.py", line 367, in trace_task
R = retval = fun(*args, **kwargs)
File "/auto/firex-ott/moe_4.0.2/lib/python3.4/site-packages/celery/app/trace.py", line 622, in __protected_call__
return self.run(*args, **kwargs)
File "/auto/firex-ott/moe_4.0.2/vanilla.py", line 9, in Fail
self.retry(exc=e)
File "/auto/firex-ott/moe_4.0.2/lib/python3.4/site-packages/celery/app/task.py", line 668, in retry
raise_with_context(exc)
File "/auto/firex-ott/moe_4.0.2/vanilla.py", line 7, in Fail
raise AssertionError('Oh My!')
AssertionError: Oh My!
Metadata
Metadata
Assignees
Labels
No labels
Activity
georgepsarakis commentedon Jan 15, 2017
Did you try configuring a timezone: http://docs.celeryproject.org/en/latest/getting-started/next-steps.html#timezone ?
mabouels commentedon Jan 15, 2017
@georgepsarakis Yes, configuring a timezone when enable_utc is False works, but the retry delays are not respected. This issue is newly introduced in Celery 4+
georgepsarakis commentedon Jan 15, 2017
I cannot reproduce it with Celery 4.0.2 either with Python 3.5.2 or Python 2.7.12 .
What are your locale and timezone settings on the machine where you are running both worker and producer?
mabouels commentedon Jan 15, 2017
In the simplified example above, I am running both worker and producer on the same machine. I just tried setting the app.conf.timezone = 'US/Eastern', which is my machine's locale
You can see that the ETA appearing in the logs are computed correctly, but not respected
mabouels commentedon Jan 15, 2017
For comparison purposes, when enable_utc is left to its default, the retry delay is respected
georgepsarakis commentedon Jan 15, 2017
I think the
app.nowfunction should always return time in UTC. I think the bug is originating from here. What do you think?georgepsarakis commentedon Jan 16, 2017
Changing:
to using UTC:
The retry behavior is correct again.
mabouels commentedon Jan 16, 2017
Yes, that seems to correct the retry behaviour. Thanks. Are you opening a PR @georgepsarakis
georgepsarakis commentedon Jan 16, 2017
Well there are multiple points where a change could modify this behavior. For example here.
Anyway, @mabouels since you discovered the bug I think it would be best if you opened the PR 😃 !
georgepsarakis commentedon Feb 11, 2017
@mabouels will you open a PR for fixing this?
mabouels commentedon Feb 11, 2017
I am just not familiar enough with the code to fully understand the implications of the proposed fix.
georgepsarakis commentedon Feb 27, 2017
@mabouels I think I managed to find a solution, check the linked PR.