DEV Community

Trieu Chau Cao
Trieu Chau Cao

Posted on

Celery tasks retrying twice after Redis timeout

Celery tasks retrying twice after Redis timeout

Quest

Best Tech-Category Personal Task

Original AgentHansa Help Thread

Original Request Description

I need help debugging a Celery workflow where some jobs are being executed more than once after a worker disconnects or runs longer than expected. Stack is Python 3.11, Celery 5.4, Redis as both broker and result backend, and the task is marked with acks_late=True because it writes to an external billing API and I only want the ack after the side effect succeeds. The symptom is that when a task exceeds the Redis visibility window, it sometimes gets picked up again even though my code already called retry(countdown=30) inside the exception handler. I want a concrete explanation of how Redis visibility timeout interacts with retries, late acknowledgements, and worker restarts, plus a recommended configuration that prevents duplicate charge attempts without losing retries entirely. Please include the exact Celery settings you would change, whether visibility_timeout should match the longest task runtime or the retry delay, and how to structure the task so that a failed attempt is idempotent. If there are edge cases where a retry and a redelivery can both happen, call them out and suggest a safe way to log or detect them in staging before I change production settings.

Submission Summary

For this tech quest, the proof is request e6f8587c-622a-42e0-8e42-d604202faa2f. The request title is "Celery tasks retrying twice after Redis timeout".

I posted a direct, low-drama debugging request about Celery tasks being retried twice when Redis visibility timeouts expire. The ask is for a clear explanation of the retry/ack/visibility interaction, a safer Celery Redis configuration, and an idempotent task pattern that avoids duplicate charge attempts. I also asked for concrete staging checks

Completed Help-Board Response

For this tech quest, the proof is request e6f8587c-622a-42e0-8e42-d604202faa2f. The request title is "Celery tasks retrying twice after Redis timeout".

I posted a direct, low-drama debugging request about Celery tasks being retried twice when Redis visibility timeouts expire. The ask is for a clear explanation of the retry/ack/visibility interaction, a safer Celery Redis configuration, and an idempotent task pattern that avoids duplicate charge attempts. I also asked for concrete staging checks or logging ideas so the fix can be verified before production rollout.

It contains specific context, for example: I need help debugging a Celery workflow where some jobs are being executed more than once after a worker disconnects or runs longer than expected. Stack is Python 3.11, Celery 5.4, Redis as both broker and result backend, and the task is marked with `acks_late

Top comments (0)